Compare commits
6 Commits
arnaudb/cs
...
wip/ebassi
Author | SHA1 | Date | |
---|---|---|---|
|
bb37613711 | ||
|
908ebf2b23 | ||
|
715dd26260 | ||
|
83d41b32e9 | ||
|
9bf52a274c | ||
|
4aae883fe8 |
@@ -1,11 +0,0 @@
|
||||
# See https://wiki.apertis.org/Guidelines/Coding_conventions#Code_formatting
|
||||
BasedOnStyle: GNU
|
||||
AlwaysBreakAfterDefinitionReturnType: All
|
||||
BreakBeforeBinaryOperators: None
|
||||
BinPackParameters: false
|
||||
SpaceAfterCStyleCast: true
|
||||
# Our column limit is actually 80, but setting that results in clang-format
|
||||
# making a lot of dubious hanging-indent choices; disable it and assume the
|
||||
# developer will line wrap appropriately. clang-format will still check
|
||||
# existing hanging indents.
|
||||
ColumnLimit: 0
|
128
.gitlab-ci.yml
128
.gitlab-ci.yml
@@ -1,9 +1,7 @@
|
||||
stages:
|
||||
- build
|
||||
- analysis
|
||||
- docs
|
||||
- flatpak
|
||||
- deploy
|
||||
# - deploy
|
||||
|
||||
.cache-paths: &cache-paths
|
||||
paths:
|
||||
@@ -14,45 +12,16 @@ stages:
|
||||
- subprojects/libepoxy/
|
||||
- subprojects/pango/
|
||||
|
||||
# Common variables
|
||||
variables:
|
||||
COMMON_MESON_FLAGS: "--fatal-meson-warnings --werror"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 2
|
||||
|
||||
.only-default:
|
||||
only:
|
||||
- branches
|
||||
except:
|
||||
- tags
|
||||
|
||||
style-check-diff:
|
||||
extends: .only-default
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: .pre
|
||||
allow_failure: true
|
||||
script:
|
||||
- .gitlab-ci/run-style-check-diff.sh
|
||||
|
||||
fedora-x86_64:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/master:v6
|
||||
stage: build
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
|
||||
script:
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS}
|
||||
-Dx11-backend=true
|
||||
-Dwayland-backend=true
|
||||
-Dbroadway-backend=true
|
||||
-Dvulkan=yes
|
||||
-Dprofiler=true
|
||||
_build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build
|
||||
- bash -x ./.gitlab-ci/test-docker.sh
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
junit:
|
||||
- "${CI_PROJECT_DIR}/_build/report.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report.xml"
|
||||
name: "gtk-${CI_COMMIT_REF_NAME}"
|
||||
paths:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
@@ -60,38 +29,6 @@ fedora-x86_64:
|
||||
- "${CI_PROJECT_DIR}/_build/report.html"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap"
|
||||
cache:
|
||||
key: "$CI_JOB_NAME"
|
||||
<<: *cache-paths
|
||||
|
||||
release-build:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: build
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS}
|
||||
-Dx11-backend=true
|
||||
-Dwayland-backend=true
|
||||
-Dbroadway-backend=true
|
||||
-Dvulkan=yes
|
||||
_build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
junit:
|
||||
- "${CI_PROJECT_DIR}/_build/report.xml"
|
||||
name: "gtk-${CI_COMMIT_REF_NAME}"
|
||||
paths:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
- "${CI_PROJECT_DIR}/_build/report.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report.html"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap"
|
||||
cache:
|
||||
key: "$CI_JOB_NAME"
|
||||
<<: *cache-paths
|
||||
@@ -116,9 +53,6 @@ msys2-mingw32:
|
||||
.flatpak-defaults: &flatpak-defaults
|
||||
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
|
||||
stage: flatpak
|
||||
allow_failure: true
|
||||
tags:
|
||||
- flatpak
|
||||
artifacts:
|
||||
paths:
|
||||
- "${APPID}-dev.flatpak"
|
||||
@@ -167,41 +101,19 @@ flatpak-master:icon-browser:
|
||||
APPID: org.gtk.IconBrowser4
|
||||
<<: *flatpak-master
|
||||
|
||||
static-scan:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: analysis
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug"
|
||||
script:
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} _scan_build
|
||||
- ninja -C _scan_build scan-build
|
||||
artifacts:
|
||||
paths:
|
||||
- _scan_build/meson-logs
|
||||
allow_failure: true
|
||||
|
||||
reference:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
stage: docs
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true _build
|
||||
- ninja -C _build gdk4-doc gsk4-doc gtk4-doc
|
||||
- mkdir -p _reference/
|
||||
- mv _build/docs/reference/gdk/html/ _reference/gdk/
|
||||
- mv _build/docs/reference/gsk/html/ _reference/gsk/
|
||||
- mv _build/docs/reference/gtk/html/ _reference/gtk/
|
||||
artifacts:
|
||||
paths:
|
||||
- _reference
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
- mv _reference/ public/
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
only:
|
||||
- master
|
||||
#pages:
|
||||
# image: registry.gitlab.gnome.org/gnome/gtk/master:v6
|
||||
# stage: deploy
|
||||
# script:
|
||||
# - meson -Dgtk_doc=true _build .
|
||||
# - ninja -C _build
|
||||
# - ninja -C _build gdk4-doc gsk4-doc gtk4-doc
|
||||
# - mkdir -p public/
|
||||
# - mv _build/docs/reference/gtk/html/ public/gtk/
|
||||
# - mv _build/docs/reference/gdk/html/ public/gdk/
|
||||
# - mv _build/docs/reference/gsk/html/ public/gsk/
|
||||
# artifacts:
|
||||
# paths:
|
||||
# - public
|
||||
# only:
|
||||
# - master
|
||||
|
@@ -1,6 +1,7 @@
|
||||
FROM fedora:31
|
||||
FROM fedora:30
|
||||
|
||||
RUN dnf -y install \
|
||||
hicolor-icon-theme \
|
||||
adwaita-icon-theme \
|
||||
atk-devel \
|
||||
at-spi2-atk-devel \
|
||||
@@ -8,15 +9,11 @@ RUN dnf -y install \
|
||||
cairo-devel \
|
||||
cairo-gobject-devel \
|
||||
ccache \
|
||||
clang \
|
||||
clang-analyzer \
|
||||
colord-devel \
|
||||
cups-devel \
|
||||
dbus-daemon \
|
||||
dbus-x11 \
|
||||
dejavu-sans-mono-fonts \
|
||||
desktop-file-utils \
|
||||
diffutils \
|
||||
elfutils-libelf-devel \
|
||||
fribidi-devel \
|
||||
gcc \
|
||||
@@ -26,7 +23,6 @@ RUN dnf -y install \
|
||||
gettext \
|
||||
git \
|
||||
glib2-devel \
|
||||
glib2-static \
|
||||
glibc-devel \
|
||||
glibc-headers \
|
||||
gobject-introspection-devel \
|
||||
@@ -36,7 +32,6 @@ RUN dnf -y install \
|
||||
gstreamer1-plugins-bad-free-devel \
|
||||
gstreamer1-plugins-base-devel \
|
||||
gtk-doc \
|
||||
hicolor-icon-theme \
|
||||
iso-codes \
|
||||
itstool \
|
||||
json-glib-devel \
|
||||
@@ -57,7 +52,6 @@ RUN dnf -y install \
|
||||
libxkbcommon-devel \
|
||||
libXrandr-devel \
|
||||
libXrender-devel \
|
||||
libXtst-devel \
|
||||
libxslt \
|
||||
mesa-dri-drivers \
|
||||
mesa-libEGL-devel \
|
||||
@@ -65,15 +59,12 @@ RUN dnf -y install \
|
||||
ninja-build \
|
||||
pango-devel \
|
||||
pcre-devel \
|
||||
pcre-static \
|
||||
python3 \
|
||||
python3-jinja2 \
|
||||
python3-pip \
|
||||
python3-pygments \
|
||||
python3-wheel \
|
||||
redhat-rpm-config \
|
||||
sassc \
|
||||
sysprof-devel \
|
||||
systemtap-sdt-devel \
|
||||
vulkan-devel \
|
||||
wayland-devel \
|
||||
@@ -82,7 +73,7 @@ RUN dnf -y install \
|
||||
xorg-x11-server-Xvfb \
|
||||
&& dnf clean all
|
||||
|
||||
RUN pip3 install meson==0.53.1
|
||||
RUN pip3 install meson==0.50.1
|
||||
|
||||
ARG HOST_USER_ID=5555
|
||||
ENV HOST_USER_ID ${HOST_USER_ID}
|
@@ -1,38 +0,0 @@
|
||||
## GTK CI infrastructure
|
||||
|
||||
GTK uses different CI images depending on platform and jobs.
|
||||
|
||||
The CI images are Docker containers, generated either using `docker` or
|
||||
`podman`, and pushed to the GitLab [container registry][registry].
|
||||
|
||||
Each Docker image has a tag composed of two parts:
|
||||
|
||||
- `${image}`: the base image for a given platform, like "fedora" or
|
||||
"debian-stable"
|
||||
- `${number}`: an incremental version number, or `latest`
|
||||
|
||||
See the [container registry][registry] for the available images for each
|
||||
branch, as well as their available versions.
|
||||
|
||||
### Checklist for Updating a CI image
|
||||
|
||||
- [ ] Update the `${image}.Dockerfile` file with the dependencies
|
||||
- [ ] Run `./run-docker.sh build --base ${image} --base-version ${number}`
|
||||
- [ ] Run `./run-docker.sh push --base ${image} --base-version ${number}`
|
||||
once the Docker image is built; you may need to log in by using
|
||||
`docker login` or `podman login`
|
||||
- [ ] Update the `image` keys in the `.gitlab-ci.yml` file with the new
|
||||
image tag
|
||||
- [ ] Open a merge request with your changes and let it run
|
||||
|
||||
### Checklist for Adding a new CI image
|
||||
|
||||
- [ ] Write a new `${image}.Dockerfile` with the instructions to set up
|
||||
a build environment
|
||||
- [ ] Add the `pip3 install meson` incantation
|
||||
- [ ] Run `./run-docker.sh build --base ${image} --base-version ${number}`
|
||||
- [ ] Run `./run-docker.sh push --base ${image} --base-version ${number}`
|
||||
- [ ] Add the new job to `.gitlab-ci.yml` referencing the image
|
||||
- [ ] Open a merge request with your changes and let it run
|
||||
|
||||
[registry]: https://gitlab.gnome.org/GNOME/gtk/container_registry
|
@@ -1,133 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# === clang-format-diff.py - ClangFormat Diff Reformatter ---*- python -*-=== #
|
||||
#
|
||||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
# ===---------------------------------------------------------------------=== #
|
||||
|
||||
"""
|
||||
This script reads input from a unified diff and reformats all the changed
|
||||
lines. This is useful to reformat all the lines touched by a specific patch.
|
||||
Example usage for git/svn users:
|
||||
|
||||
git diff -U0 --no-color HEAD^ | clang-format-diff.py -p1 -i
|
||||
svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import argparse
|
||||
import difflib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
from io import StringIO
|
||||
else:
|
||||
from io import BytesIO as StringIO
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('-i', action='store_true', default=False,
|
||||
help='apply edits to files instead of displaying a '
|
||||
'diff')
|
||||
parser.add_argument('-p', metavar='NUM', default=0,
|
||||
help='strip the smallest prefix containing P slashes')
|
||||
parser.add_argument('-regex', metavar='PATTERN', default=None,
|
||||
help='custom pattern selecting file paths to reformat '
|
||||
'(case sensitive, overrides -iregex)')
|
||||
parser.add_argument('-iregex', metavar='PATTERN',
|
||||
default=r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hh|hpp|m|mm|inc'
|
||||
r'|js|ts|proto|protodevel|java|cs)',
|
||||
help='custom pattern selecting file paths to reformat '
|
||||
'(case insensitive, overridden by -regex)')
|
||||
parser.add_argument('-sort-includes', action='store_true', default=False,
|
||||
help='let clang-format sort include blocks')
|
||||
parser.add_argument('-v', '--verbose', action='store_true',
|
||||
help='be more verbose, ineffective without -i')
|
||||
parser.add_argument('-style',
|
||||
help='formatting style to apply (LLVM, Google, '
|
||||
'Chromium, Mozilla, WebKit)')
|
||||
parser.add_argument('-binary', default='clang-format',
|
||||
help='location of binary to use for clang-format')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Extract changed lines for each file.
|
||||
filename = None
|
||||
lines_by_file = {}
|
||||
for line in sys.stdin:
|
||||
match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
|
||||
if match:
|
||||
filename = match.group(2)
|
||||
if filename is None:
|
||||
continue
|
||||
|
||||
if args.regex is not None:
|
||||
if not re.match('^%s$' % args.regex, filename):
|
||||
continue
|
||||
else:
|
||||
if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
|
||||
continue
|
||||
|
||||
match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line)
|
||||
if match:
|
||||
start_line = int(match.group(1))
|
||||
line_count = 1
|
||||
if match.group(3):
|
||||
line_count = int(match.group(3))
|
||||
if line_count == 0:
|
||||
continue
|
||||
end_line = start_line + line_count - 1
|
||||
lines_by_file.setdefault(filename, []).extend(
|
||||
['-lines', str(start_line) + ':' + str(end_line)])
|
||||
|
||||
# Reformat files containing changes in place.
|
||||
# We need to count amount of bytes generated in the output of
|
||||
# clang-format-diff. If clang-format-diff doesn't generate any bytes it
|
||||
# means there is nothing to format.
|
||||
format_line_counter = 0
|
||||
for filename, lines in lines_by_file.items():
|
||||
if args.i and args.verbose:
|
||||
print('Formatting {}'.format(filename))
|
||||
command = [args.binary, filename]
|
||||
if args.i:
|
||||
command.append('-i')
|
||||
if args.sort_includes:
|
||||
command.append('-sort-includes')
|
||||
command.extend(lines)
|
||||
if args.style:
|
||||
command.extend(['-style', args.style])
|
||||
p = subprocess.Popen(command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=None,
|
||||
stdin=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
stdout, _ = p.communicate()
|
||||
if p.returncode != 0:
|
||||
sys.exit(p.returncode)
|
||||
|
||||
if not args.i:
|
||||
with open(filename) as f:
|
||||
code = f.readlines()
|
||||
formatted_code = StringIO(stdout).readlines()
|
||||
diff = difflib.unified_diff(code, formatted_code,
|
||||
filename, filename,
|
||||
'(before formatting)',
|
||||
'(after formatting)')
|
||||
diff_string = ''.join(diff)
|
||||
if diff_string:
|
||||
format_line_counter += sys.stdout.write(diff_string)
|
||||
|
||||
if format_line_counter > 0:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -4,19 +4,20 @@ set -e
|
||||
|
||||
appid=$1
|
||||
|
||||
builddir=flatpak_app
|
||||
builddir=app
|
||||
repodir=repo
|
||||
|
||||
flatpak-builder \
|
||||
--user --disable-rofiles-fuse \
|
||||
--stop-at=gtk \
|
||||
${builddir} \
|
||||
build-aux/flatpak/${appid}.json
|
||||
|
||||
flatpak build ${builddir} meson \
|
||||
--prefix=/app \
|
||||
--libdir=/app/lib \
|
||||
--buildtype=release \
|
||||
flatpak-builder \
|
||||
--run ${builddir} build-aux/flatpak/${appid}.json \
|
||||
meson \
|
||||
--prefix /app \
|
||||
--libdir /app/lib \
|
||||
--buildtype debug \
|
||||
-Dx11-backend=true \
|
||||
-Dwayland-backend=true \
|
||||
-Dprint-backends=file \
|
||||
@@ -24,12 +25,13 @@ flatpak build ${builddir} meson \
|
||||
-Dbuild-examples=false \
|
||||
-Dintrospection=false \
|
||||
-Ddemos=true \
|
||||
_flatpak_build
|
||||
|
||||
flatpak build ${builddir} ninja -C _flatpak_build install
|
||||
_build .
|
||||
|
||||
flatpak-builder \
|
||||
--run ${builddir} build-aux/flatpak/${appid}.json \
|
||||
ninja -C _build install
|
||||
|
||||
flatpak-builder \
|
||||
--user --disable-rofiles-fuse \
|
||||
--finish-only \
|
||||
--repo=${repodir} \
|
||||
${builddir} \
|
||||
@@ -38,5 +40,5 @@ flatpak-builder \
|
||||
flatpak build-bundle \
|
||||
${repodir} \
|
||||
${appid}-dev.flatpak \
|
||||
--runtime-repo=https://nightly.gnome.org/gnome-nightly.flatpakrepo \
|
||||
--runtime-repo=https://flathub.org/repo/flathub.flatpakrepo \
|
||||
${appid}
|
||||
|
@@ -138,25 +138,22 @@ ul.images li {
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>{{ report.project_name }}/{{ report.branch_name }} :: Test Reports</h1>
|
||||
<h1>{{ report.project_name }} :: Test Reports</h1>
|
||||
<div class="report-meta">
|
||||
<p><strong>Branch:</strong> {{ report.branch_name }}</p>
|
||||
<p><strong>Date:</strong> <time datetime="{{ report.date.isoformat() }}">{{ report.locale_date }}</time></p>
|
||||
{% if report.job_id %}<p><strong>Job ID:</strong> {{ report.job_id }}</p>{% endif %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<section>
|
||||
<div class="report-meta">
|
||||
<p><strong>Branch:</strong> {{ report.branch_name }}</p>
|
||||
<p><strong>Date:</strong> <time datetime="{{ report.date.isoformat() }}">{{ report.locale_date }}</time></p>
|
||||
{% if report.job_id %}<p><strong>Job ID:</strong> {{ report.job_id }}</p>{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<div class="summary">
|
||||
<h3><a name="summary">Summary</a></h3>
|
||||
<h3>Summary</h3>
|
||||
<ul>
|
||||
<li><strong>Total units:</strong> {{ report.total_units }}</li>
|
||||
<li><strong>Failed:</strong> {{ report.total_failures }}</li>
|
||||
<li><strong>Passed:</strong> {{ report.total_successes }}</li>
|
||||
<li><strong>Failed:</strong> {{ report.total_failures }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
@@ -164,18 +161,58 @@ ul.images li {
|
||||
{% for suite_result in report.results_list %}
|
||||
<section>
|
||||
<div class="result">
|
||||
<h3><a name="results">Suite: {{ suite_result.suite_name }}</a></h3>
|
||||
<h3>Suite: {{ suite_result.suite_name }}</h3>
|
||||
<ul>
|
||||
<li><strong>Units:</strong> {{ suite_result.n_units }}</li>
|
||||
<li><strong>Failed:</strong> <a href="#{{ suite_result.suite_name }}-failed">{{ suite_result.n_failures }}</a></li>
|
||||
<li><strong>Passed:</strong> <a href="#{{ suite_result.suite_name }}-passed">{{ suite_result.n_successes }}</a></li>
|
||||
<li><strong>Passed:</strong> {{ suite_result.n_successes }}</li>
|
||||
<li><strong>Failed:</strong> {{ suite_result.n_failures }}</li>
|
||||
</ul>
|
||||
|
||||
<div class="successes">
|
||||
<h4>Passed</h4>
|
||||
<ul class="passed">
|
||||
{% for success in suite_result.successes if success.result == 'OK' %}
|
||||
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4>Skipped</h4>
|
||||
<ul>
|
||||
{% for success in suite_result.successes if success.result == 'SKIP' %}
|
||||
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4>Expected failures</h4>
|
||||
<ul>
|
||||
{% for success in suite_result.successes if success.result == 'EXPECTEDFAIL' %}
|
||||
<li>{{ success.name }} - result: <span class="result xfail">{{ success.result }}</span><br/>
|
||||
{% if success.stdout %}
|
||||
Output: <pre>{{ success.stdout }}</pre>
|
||||
{% endif %}
|
||||
{% if success.image_data is defined %}
|
||||
<ul class="images">
|
||||
<li><img alt="ref" src="{{ success.image_data.ref }}" /></li>
|
||||
<li><img alt="out" src="{{ success.image_data.out }}" /></li>
|
||||
<li><img alt="diff" src="{{ success.image_data.diff }}" /></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="failures">
|
||||
<h4><a name="{{ suite_result.suite_name }}-failed">Failures</a></h4>
|
||||
<h4>Failed</h4>
|
||||
<ul class="failed">
|
||||
{% for failure in suite_result.failures if failure.result in [ 'ERROR', 'FAIL', 'UNEXPECTEDPASS' ] %}
|
||||
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
|
||||
{% for failure in suite_result.failures if failure.result == 'FAIL' %}
|
||||
<li>{{ failure.name }} - result: <span class="result fail">{{ failure.result }}</span><br/>
|
||||
{% if failure.stdout %}
|
||||
Output: <pre>{{ failure.stdout }}</pre>
|
||||
{% endif %}
|
||||
@@ -192,10 +229,10 @@ ul.images li {
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4><a name="{{ suite_result.suite_name }}-timed-out">Timed out</a></h4>
|
||||
<h4>Timed out</h4>
|
||||
<ul class="failed">
|
||||
{% for failure in suite_result.failures if failure.result == 'TIMEOUT' %}
|
||||
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
|
||||
<li>{{ failure.name }} - result: <span class="result fail">{{ failure.result }}</span><br/>
|
||||
{% if failure.stdout %}
|
||||
Output: <pre>{{ failure.stdout }}</pre>
|
||||
{% endif %}
|
||||
@@ -206,46 +243,6 @@ ul.images li {
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="successes">
|
||||
<h4><a name="{{ suite_result.suite_name }}-expected-fail">Expected failures</a></h4>
|
||||
<ul>
|
||||
{% for success in suite_result.successes if success.result == 'EXPECTEDFAIL' %}
|
||||
<li><a name="{{ success.name }}">{{ success.name }}</a> - result: <span class="result xfail">{{ success.result }}</span><br/>
|
||||
{% if success.stdout %}
|
||||
Output: <pre>{{ success.stdout }}</pre>
|
||||
{% endif %}
|
||||
{% if success.image_data is defined %}
|
||||
<ul class="images">
|
||||
<li><img alt="ref" src="{{ success.image_data.ref }}" /></li>
|
||||
<li><img alt="out" src="{{ success.image_data.out }}" /></li>
|
||||
<li><img alt="diff" src="{{ success.image_data.diff }}" /></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4><a name="{{ suite_result.suite_name }}-skipped">Skipped</a></h4>
|
||||
<ul>
|
||||
{% for success in suite_result.successes if success.result == 'SKIP' %}
|
||||
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h4><a name="{{ suite_result.suite_name }}-passed">Passed</a></h4>
|
||||
<ul class="passed">
|
||||
{% for success in suite_result.successes if success.result == 'OK' %}
|
||||
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
|
||||
{% else %}
|
||||
<li>None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
@@ -331,7 +328,7 @@ for name, units in suites.items():
|
||||
print('Processing {} suite {}:'.format(project_name, suite_name))
|
||||
|
||||
def if_failed(unit):
|
||||
if unit['result'] in ['FAIL', 'UNEXPECTEDPASS', 'TIMEOUT', 'ERROR',]:
|
||||
if unit['result'] in ['FAIL', 'TIMEOUT']:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@@ -51,7 +51,6 @@ for line in args.infile:
|
||||
|
||||
duration = data['duration']
|
||||
return_code = data['returncode']
|
||||
result = data['result']
|
||||
log = data['stdout']
|
||||
|
||||
unit = {
|
||||
@@ -59,7 +58,6 @@ for line in args.infile:
|
||||
'name': unit_name,
|
||||
'duration': duration,
|
||||
'returncode': return_code,
|
||||
'result': result,
|
||||
'stdout': log,
|
||||
}
|
||||
|
||||
@@ -70,12 +68,12 @@ for name, units in suites.items():
|
||||
print('Processing suite {} (units: {})'.format(name, len(units)))
|
||||
|
||||
def if_failed(unit):
|
||||
if unit['result'] in ['ERROR', 'FAIL', 'UNEXPECTEDPASS', 'TIMEOUT']:
|
||||
if unit['returncode'] != 0:
|
||||
return True
|
||||
return False
|
||||
|
||||
def if_succeded(unit):
|
||||
if unit['result'] in ['OK', 'EXPECTEDFAIL', 'SKIP']:
|
||||
if unit['returncode'] == 0:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@@ -1,135 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
read_arg() {
|
||||
# $1 = arg name
|
||||
# $2 = arg value
|
||||
# $3 = arg parameter
|
||||
local rematch='^[^=]*=(.*)$'
|
||||
if [[ $2 =~ $rematch ]]; then
|
||||
read "$1" <<< "${BASH_REMATCH[1]}"
|
||||
else
|
||||
read "$1" <<< "$3"
|
||||
# There is no way to shift our callers args, so
|
||||
# return 1 to indicate they should do it instead.
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
build=0
|
||||
run=0
|
||||
push=0
|
||||
list=0
|
||||
print_help=0
|
||||
no_login=0
|
||||
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v6"
|
||||
|
||||
while (($# > 0)); do
|
||||
case "${1%%=*}" in
|
||||
build) build=1;;
|
||||
run) run=1;;
|
||||
push) push=1;;
|
||||
list) list=1;;
|
||||
help) print_help=1;;
|
||||
--base|-b) read_arg base "$@" || shift;;
|
||||
--base-version) read_arg base_version "$@" || shift;;
|
||||
--no-login) no_login=1;;
|
||||
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ $print_help == 1 ]; then
|
||||
echo "$0 - Build and run Docker images"
|
||||
echo ""
|
||||
echo "Usage: $0 <command> [options] [basename]"
|
||||
echo ""
|
||||
echo "Available commands"
|
||||
echo ""
|
||||
echo " build --base=<BASENAME> - Build Docker image <BASENAME>.Dockerfile"
|
||||
echo " run --base=<BASENAME> - Run Docker image <BASENAME>"
|
||||
echo " push --base=<BASENAME> - Push Docker image <BASENAME> to the registry"
|
||||
echo " list - List available images"
|
||||
echo " help - This help message"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
if [ $list == 1 ]; then
|
||||
echo "Available Docker images:"
|
||||
for f in *.Dockerfile; do
|
||||
filename=$( basename -- "$f" )
|
||||
basename="${filename%.*}"
|
||||
|
||||
echo -e " \e[1;39m$basename\e[0m"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# All commands after this require --base to be set
|
||||
if [ -z $base ]; then
|
||||
echo "Usage: $0 <command>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$base.Dockerfile" ]; then
|
||||
echo -e "\e[1;31mERROR\e[0m: Dockerfile for '$base' not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z $base_version ]; then
|
||||
base_version="latest"
|
||||
else
|
||||
base_version="v$base_version"
|
||||
fi
|
||||
|
||||
if [ ! -x "$(command -v docker)" ] || [ docker --help |& grep -q podman ]; then
|
||||
# Docker is actually implemented by podman, and its OCI output
|
||||
# is incompatible with some of the dockerd instances on GitLab
|
||||
# CI runners.
|
||||
echo "Using: Podman"
|
||||
format="--format docker"
|
||||
CMD="podman"
|
||||
else
|
||||
echo "Using: Docker"
|
||||
format=""
|
||||
CMD="sudo socker"
|
||||
fi
|
||||
|
||||
REGISTRY="registry.gitlab.gnome.org"
|
||||
TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}"
|
||||
|
||||
if [ $build == 1 ]; then
|
||||
echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
|
||||
${CMD} build \
|
||||
${format} \
|
||||
--build-arg HOST_USER_ID="$UID" \
|
||||
--tag "${TAG}" \
|
||||
--file "${base}.Dockerfile" .
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ $push == 1 ]; then
|
||||
echo -e "\e[1;32mPUSHING\e[0m: ${base} as ${TAG}"
|
||||
|
||||
if [ $no_login == 0 ]; then
|
||||
${CMD} login ${REGISTRY}
|
||||
fi
|
||||
|
||||
${CMD} push ${TAG}
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ $run == 1 ]; then
|
||||
echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
|
||||
${CMD} run \
|
||||
--rm \
|
||||
--volume "$(pwd)/..:/home/user/app" \
|
||||
--workdir "/home/user/app" \
|
||||
--tty \
|
||||
--interactive "${TAG}" \
|
||||
bash
|
||||
exit $?
|
||||
fi
|
||||
sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \
|
||||
--file "Dockerfile" .
|
||||
sudo docker run --rm --security-opt label=disable \
|
||||
--volume "$(pwd)/..:/home/user/app" --workdir "/home/user/app" \
|
||||
--tty --interactive "${TAG}" bash
|
||||
|
@@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# We need to add a new remote for the upstream master, since this script could
|
||||
# be running in a personal fork of the repository which has out of date branches.
|
||||
git remote add upstream https://gitlab.gnome.org/GNOME/gtk.git
|
||||
git fetch upstream
|
||||
|
||||
# Work out the newest common ancestor between the detached HEAD that this CI job
|
||||
# has checked out, and the upstream target branch (which will typically be
|
||||
# `upstream/master` or `upstream/gtk-3-24`).
|
||||
#
|
||||
# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if we’re running in
|
||||
# a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
|
||||
newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1)
|
||||
git diff -U0 --no-color "${newest_common_ancestor_sha}" | .gitlab-ci/clang-format-diff.py -binary "clang-format" -p1
|
||||
exit_status=$?
|
||||
|
||||
# The style check is not infallible. The clang-format configuration cannot
|
||||
# perfectly describe GTK’s coding style: in particular, it cannot align
|
||||
# function arguments. The documented coding style for GTK takes priority over
|
||||
# clang-format suggestions. Hopefully we can eventually improve clang-format to
|
||||
# be configurable enough for our coding style. That’s why this CI check is OK
|
||||
# to fail: the idea is that people can look through the output and ignore it if
|
||||
# it’s wrong. (That situation can also happen if someone touches pre-existing
|
||||
# badly formatted code and it doesn’t make sense to tidy up the wider coding
|
||||
# style with the changes they’re making.)
|
||||
echo ""
|
||||
echo "Note that clang-format output is advisory and cannot always match the"
|
||||
echo "GTK coding style, documented at:"
|
||||
echo " https://gitlab.gnome.org/GNOME/gtk/blob/master/docs/CODING-STYLE"
|
||||
echo "Warnings from this tool can be ignored in favour of the documented "
|
||||
echo "coding style, or in favour of matching the style of existing"
|
||||
echo "surrounding code."
|
||||
|
||||
exit ${exit_status}
|
@@ -1,34 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set +x
|
||||
set +e
|
||||
|
||||
srcdir=$( pwd )
|
||||
builddir=$1
|
||||
|
||||
export GDK_BACKEND=x11
|
||||
xvfb-run -a -s "-screen 0 1024x768x24" \
|
||||
meson test -C ${builddir} \
|
||||
--print-errorlogs \
|
||||
--suite=gtk \
|
||||
--no-suite=gtk:a11y
|
||||
|
||||
# Store the exit code for the CI run, but always
|
||||
# generate the reports
|
||||
exit_code=$?
|
||||
|
||||
cd ${builddir}
|
||||
|
||||
$srcdir/.gitlab-ci/meson-junit-report.py \
|
||||
--project-name=gtk \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--output=report.xml \
|
||||
meson-logs/testlog.json
|
||||
$srcdir/.gitlab-ci/meson-html-report.py \
|
||||
--project-name=gtk \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--reftest-output-dir="testsuite/reftests/output" \
|
||||
--output=report.html \
|
||||
meson-logs/testlog.json
|
||||
|
||||
exit $exit_code
|
@@ -16,9 +16,7 @@ meson \
|
||||
-Dwayland-backend=true \
|
||||
-Dbroadway-backend=true \
|
||||
-Dvulkan=yes \
|
||||
-Dprofiler=true \
|
||||
--werror \
|
||||
${EXTRA_MESON_FLAGS:-} \
|
||||
_build $srcdir
|
||||
unset CCACHE_DISABLE
|
||||
|
||||
|
@@ -33,10 +33,6 @@ pacman --noconfirm -S --needed \
|
||||
mingw-w64-$MSYS2_ARCH-gst-plugins-bad \
|
||||
mingw-w64-$MSYS2_ARCH-shared-mime-info
|
||||
|
||||
# https://gitlab.gnome.org/GNOME/gtk/issues/2243
|
||||
wget "https://gitlab.gnome.org/creiter/gitlab-ci-win32-runner/raw/master/pango/mingw-w64-$MSYS2_ARCH-pango-1.44.7-1-any.pkg.tar.xz"
|
||||
pacman --noconfirm -U "mingw-w64-$MSYS2_ARCH-pango-1.44.7-1-any.pkg.tar.xz"
|
||||
|
||||
mkdir -p _ccache
|
||||
export CCACHE_BASEDIR="$(pwd)"
|
||||
export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
|
||||
|
@@ -174,7 +174,7 @@ maintainers review your contribution.
|
||||
|
||||
Each contribution is reviewed by the core developers of the GTK project.
|
||||
|
||||
The [CODEOWNERS](./docs/CODEOWNERS) document contains the list of core
|
||||
The [CODE-OWNERS](./docs/CODE-OWNERS) document contains the list of core
|
||||
contributors to GTK and the areas for which they are responsible; you
|
||||
should ensure to receive their review and signoff on your changes.
|
||||
|
||||
|
223
NEWS
223
NEWS
@@ -1,224 +1,3 @@
|
||||
Overview of Changes in GTK 3.98.3
|
||||
=================================
|
||||
|
||||
* GtkEntry:
|
||||
- Support setting attributes in ui files
|
||||
|
||||
* GtkScaleButton:
|
||||
- Don't derive from GtkButton
|
||||
|
||||
* GtkAboutDialog:
|
||||
- Support more common licenses
|
||||
|
||||
* GtkEmojiChooser:
|
||||
- Improve keyboard navigation
|
||||
|
||||
* Chooser buttons:
|
||||
- Make dialogs modal by default
|
||||
|
||||
* Focus handling
|
||||
- Fix crossing event generation
|
||||
- Fix focus handling in various widgets
|
||||
- Change :can-focus to be recursive
|
||||
- Fix GtkWindow:is-active setting
|
||||
|
||||
* Accessibility:
|
||||
- Add a cursor-aspect-ratio setting
|
||||
- Set focus-related states properly
|
||||
|
||||
* Themes:
|
||||
- Use blue focus outlines more
|
||||
- Numerous minor improvements
|
||||
|
||||
* Wayland:
|
||||
- Fix .Compose file loading
|
||||
- Support popup repositioning
|
||||
|
||||
* GDK:
|
||||
- Remove GdkKeymap from public API, replaced by
|
||||
GdkDevice properties
|
||||
- Add full keyboard translation state to key events
|
||||
- Simplify modifier support, drop GdkModifierIntent
|
||||
- Move key event matching to GDK
|
||||
- Add GdkSurface::enter/leave-monitor signals
|
||||
|
||||
* GSK:
|
||||
- Turn GskRenderNode into a derivable type, and make
|
||||
it introspectable
|
||||
|
||||
* Translation updates:
|
||||
- Japanese
|
||||
- Lithuanian
|
||||
- Turkish
|
||||
|
||||
|
||||
Overview of Changes in GTK 3.98.2
|
||||
=================================
|
||||
|
||||
* Introduce GtkShortcutController, and replace key bindings,
|
||||
mnemonics and accelerators by GtkShortcut
|
||||
|
||||
* Derive the HighContrast theme from Adwaita
|
||||
|
||||
* GtkMenuButton: Add a use-underline property
|
||||
|
||||
* GtkTreeView: Fix cell editing
|
||||
|
||||
* Add gdk_toplevel_inhibit_system_shortcuts
|
||||
|
||||
* gtk-demo: Fix issues in multiple demos
|
||||
|
||||
* Translation updates:
|
||||
Polish
|
||||
|
||||
|
||||
Overview of Changes in GTK 3.98.1
|
||||
=================================
|
||||
|
||||
* GtkFileChooser:
|
||||
- Remove filename/uri api
|
||||
- Drop extra-widget
|
||||
- Remove overwrite confirmation
|
||||
- Remove show-hidden property
|
||||
- Remove local-only property
|
||||
- Remove GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
|
||||
- The portal file chooser supports selecting folders
|
||||
|
||||
* GtkSpinner:
|
||||
- Rename active property to spinning
|
||||
|
||||
* GtkRevealer:
|
||||
- Fix size allocation at small scales
|
||||
|
||||
* GtkPopover:
|
||||
- Drop :relative-to, it is always the :parent now
|
||||
|
||||
* GtkWindow:
|
||||
- Drop window-type, it is always a regular toplevel
|
||||
|
||||
* GtkWidget:
|
||||
- Drop expand property
|
||||
- Drop margin property
|
||||
- Drop gtk_grab_add, gtk_device_grab_add
|
||||
|
||||
* GtkTextView:
|
||||
- Support overlines in GtkTextTag
|
||||
- Support visible spaces in GtkTextTag
|
||||
- Support hyphenation control in GtkTextTag
|
||||
|
||||
* Split GtkEventControllerFocus from GtkEventControllerKey
|
||||
|
||||
* DND:
|
||||
- Fix local DND to avoid serialization
|
||||
- Add new content provider constructors
|
||||
- Split GtkDropTargetAsync and GtkDropTarget
|
||||
- Group DND events into event sequences
|
||||
- Propagate DND events like motion events
|
||||
- Introduce GtkDropControllerMotion
|
||||
- Remove GtkSelectionData
|
||||
|
||||
* Performance:
|
||||
- Clean up profiler marks
|
||||
- Share GL programs between renderers
|
||||
|
||||
* GDK:
|
||||
- Drop gdk_surface_new_temp
|
||||
- Make GdkEvent an immutable boxed type, not an object
|
||||
- Remove GdkAtom and property- and selection-related apis
|
||||
- Introduce GdkPopup and GdkToplevel interfaces
|
||||
- Implement them in backend-specific surface subtypes
|
||||
- Rename gdk_surface_input_shape_combine_region to
|
||||
gdk_surface_set_input_region
|
||||
- Drop X11-only concepts such as sticky or keep-below
|
||||
|
||||
* OS X: Fix OpenGL extension detection
|
||||
|
||||
* Broadway: implement scaling
|
||||
|
||||
* Translation updates:
|
||||
Dutch
|
||||
Japanese
|
||||
Persian
|
||||
|
||||
|
||||
Overview of Changes in GTK 3.98.0
|
||||
=================================
|
||||
|
||||
While this release gets significantly closer to what we aim for in GTK 4,
|
||||
there are still a few big items outstanding that we are currently working
|
||||
on:
|
||||
|
||||
- Event controllers for keyboard shortcuts
|
||||
- Movable popovers
|
||||
- Row-recycling list and grid views
|
||||
- Revamped accessibility infrastructure
|
||||
- Animation API
|
||||
|
||||
We will do further 3.98.x snapshots as these land.
|
||||
|
||||
*****************
|
||||
|
||||
* The DND refactoring has been completed. The GTK API for DND has been turned
|
||||
into event controllers: GtkDragSource and GtkDropTarget. Support for file
|
||||
transfers via file transfer portal has been added for both DND and the clipboard.
|
||||
|
||||
* Child surfaces have been removed. GDK only supports toplevel and popup surfaces
|
||||
now. The client-side window implementation has been removed too. On the GTK side,
|
||||
the GtkNative interface has been introduced for widgets that have their own
|
||||
surface. This cleanup is not 100% complete yet.
|
||||
|
||||
* Global positions and related apis such as gdk_surface_move are no longer available.
|
||||
|
||||
* A constraint-based layout manager has been added.
|
||||
|
||||
* Many classes have been made explicitly non-subclassable, and the widget hierarchy
|
||||
has been simplified, by making widgets derive directly from GtkWidget instead of
|
||||
a container.
|
||||
|
||||
* Menu-related changes:
|
||||
- GtkMenu, GtkMenuBar and related classes have been removed. They are being replaced
|
||||
by GMenu and popover-based variants. Popover menus can now do traditional, nested
|
||||
menus, and model buttons show accelerators.
|
||||
- Context menus are no longer created with ::populate-popup signals, but use menu
|
||||
models and actions.
|
||||
- Widget actions can be created in class_init, with gtk_widget_class_install_action.
|
||||
- GtkToolbar has been removed as well.
|
||||
|
||||
* Text-related changed:
|
||||
- Text cursor blinking has been made smooth.
|
||||
- GtkTextView is caching rendernodes for the visible text range now, improving the
|
||||
scrolling performance of text.
|
||||
- Add a simple undo stack for text edits has been added.
|
||||
|
||||
* The native Win32 filechooser backend supports choices.
|
||||
|
||||
* GtkTreeView renders tree and grid lines with textures.
|
||||
|
||||
* GtkEmojiChooser has been made public.
|
||||
|
||||
* GtkGestureMultiPress has been renamed to GtkGestureClick.
|
||||
|
||||
* GtkWidget has api to handle style classes: gtk_widget_add_style_class.
|
||||
This is the first step towards moving away from GtkStyleContext.
|
||||
|
||||
* X11-specific changes:
|
||||
- XI2 is now mandatory
|
||||
- The xim input method has been removed
|
||||
|
||||
* Wayland-specific changes:
|
||||
- The loading of cursor themes has been improved to load cursors on demand,
|
||||
and no longer relies on libwayland-cursor.
|
||||
|
||||
* The GL renderer is now sharing icon and glyph caches for all surfaces,
|
||||
and has better support for blurring and shadow rendering.
|
||||
|
||||
* Performance-related changes:
|
||||
- GTK provides profiling information for Sysprof when launched with GTK_TRACE=1.
|
||||
- Css computation has been optimized
|
||||
- Css lookups are using a Bloom filter
|
||||
- Icon loading IO has been moved to a thread
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 3.96.0
|
||||
==================================
|
||||
|
||||
@@ -581,7 +360,7 @@ Overview of Changes in GTK+ 3.92.1, 重庆市
|
||||
The bulk of the preparation for this release was done during
|
||||
and after the fantastic GNOME.Asia Summit 2017 in Chongqing, China.
|
||||
|
||||
* Drop autotools support. Meson 0.42.1 is now required
|
||||
* Drop autotools support. Meson 0.42.1 is now required
|
||||
|
||||
* Implement most of CSS3 font-variant
|
||||
|
||||
|
@@ -54,36 +54,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "libsass",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts": [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/libsass.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "sassc",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts": [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/sassc.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "gtk",
|
||||
"buildsystem": "meson",
|
||||
|
@@ -54,36 +54,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "libsass",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts": [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/libsass.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "sassc",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts": [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/sassc.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "gtk",
|
||||
"buildsystem": "meson",
|
||||
|
@@ -54,36 +54,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "libsass",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts": [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/libsass.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "sassc",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts": [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/sassc.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "gtk",
|
||||
"buildsystem": "meson",
|
||||
|
@@ -185,6 +185,9 @@
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#mesondefine LT_OBJDIR
|
||||
|
||||
/* Define if <X11/extensions/XIproto.h> needed for xReply */
|
||||
#mesondefine NEED_XIPROTO_H_FOR_XREPLY
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
#mesondefine NO_MINUS_C_MINUS_O
|
||||
|
||||
|
@@ -221,12 +221,9 @@ open_cb (GtkWidget *button,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Load",
|
||||
"_Cancel");
|
||||
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
|
||||
g_object_unref (cwd);
|
||||
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
}
|
||||
@@ -293,37 +290,29 @@ save_response_cb (GtkNativeDialog *dialog,
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GListModel *model;
|
||||
GFile *file;
|
||||
char *text;
|
||||
char *text, *filename;
|
||||
GError *error = NULL;
|
||||
|
||||
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
|
||||
text = serialize_model (model);
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
g_file_replace_contents (file, text, -1,
|
||||
NULL, FALSE,
|
||||
G_FILE_CREATE_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
&error);
|
||||
if (error != NULL)
|
||||
{
|
||||
GtkWidget *message_dialog;
|
||||
|
||||
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"Saving failed");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
|
||||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||
if (!g_file_set_contents (filename, text, -1, &error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"Saving failed");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", error->message);
|
||||
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_widget_show (message_dialog);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_widget_show (dialog);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_free (text);
|
||||
g_object_unref (file);
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
@@ -340,12 +329,9 @@ save_cb (GtkWidget *button,
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"_Save",
|
||||
"_Cancel");
|
||||
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
|
||||
g_object_unref (cwd);
|
||||
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
}
|
||||
@@ -414,7 +400,7 @@ edit_constraint (ConstraintEditorWindow *win,
|
||||
ConstraintEditor *editor;
|
||||
GListModel *model;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (win));
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
if (constraint)
|
||||
@@ -454,7 +440,7 @@ edit_guide (ConstraintEditorWindow *win,
|
||||
GtkWidget *window;
|
||||
GuideEditor *editor;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (win));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Edit Guide");
|
||||
@@ -601,10 +587,7 @@ create_widget_func (gpointer item,
|
||||
g_object_bind_property (item, "name",
|
||||
label, "label",
|
||||
G_BINDING_DEFAULT);
|
||||
gtk_widget_set_margin_start (label, 10);
|
||||
gtk_widget_set_margin_end (label, 10);
|
||||
gtk_widget_set_margin_top (label, 10);
|
||||
gtk_widget_set_margin_bottom (label, 10);
|
||||
g_object_set (label, "margin", 10, NULL);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (row), box);
|
||||
@@ -613,19 +596,19 @@ create_widget_func (gpointer item,
|
||||
if (GTK_IS_CONSTRAINT (item) || GTK_IS_CONSTRAINT_GUIDE (item))
|
||||
{
|
||||
button = gtk_button_new_from_icon_name ("document-edit-symbolic");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
|
||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (row_edit), win);
|
||||
g_object_set_data (G_OBJECT (row), "edit", button);
|
||||
gtk_container_add (GTK_CONTAINER (box), button);
|
||||
button = gtk_button_new_from_icon_name ("edit-delete-symbolic");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
|
||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (row_delete), win);
|
||||
gtk_container_add (GTK_CONTAINER (box), button);
|
||||
}
|
||||
else if (GTK_IS_WIDGET (item))
|
||||
{
|
||||
button = gtk_button_new_from_icon_name ("edit-delete-symbolic");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
|
||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (row_delete), win);
|
||||
gtk_container_add (GTK_CONTAINER (box), button);
|
||||
}
|
||||
|
@@ -3,10 +3,7 @@
|
||||
<template class="ConstraintEditor" parent="GtkWidget">
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid">
|
||||
<property name="margin-start">20</property>
|
||||
<property name="margin-end">20</property>
|
||||
<property name="margin-top">20</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<property name="margin">20</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<child>
|
||||
|
@@ -77,7 +77,7 @@ update_weak_position (ConstraintView *self,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
x,
|
||||
GTK_CONSTRAINT_STRENGTH_WEAK);
|
||||
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
|
||||
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
|
||||
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
|
||||
constraint);
|
||||
g_object_set_data (G_OBJECT (child), "x-constraint", constraint);
|
||||
@@ -97,7 +97,7 @@ update_weak_position (ConstraintView *self,
|
||||
GTK_CONSTRAINT_RELATION_EQ,
|
||||
y,
|
||||
GTK_CONSTRAINT_STRENGTH_WEAK);
|
||||
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
|
||||
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
|
||||
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
|
||||
constraint);
|
||||
g_object_set_data (G_OBJECT (child), "y-constraint", constraint);
|
||||
@@ -214,7 +214,7 @@ constraint_view_add_child (ConstraintView *view,
|
||||
|
||||
label = gtk_label_new (name);
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_widget_add_css_class (frame, "child");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "child");
|
||||
gtk_widget_set_name (frame, name);
|
||||
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||
gtk_widget_set_parent (frame, GTK_WIDGET (view));
|
||||
@@ -257,8 +257,8 @@ constraint_view_add_guide (ConstraintView *view,
|
||||
G_BINDING_DEFAULT);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_widget_add_css_class (frame, "guide");
|
||||
g_object_set_data (G_OBJECT (frame), "internal", (char *)"yes");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "guide");
|
||||
g_object_set_data (G_OBJECT (frame), "internal", "yes");
|
||||
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||
gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL);
|
||||
|
||||
@@ -276,7 +276,7 @@ constraint_view_add_guide (ConstraintView *view,
|
||||
names[i].attr,
|
||||
1.0, 0.0,
|
||||
GTK_CONSTRAINT_STRENGTH_REQUIRED);
|
||||
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
|
||||
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
|
||||
gtk_constraint_layout_add_constraint (layout, constraint);
|
||||
g_object_set_data (G_OBJECT (guide), names[i].name, constraint);
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ get_strength (const char *id)
|
||||
return strength;
|
||||
}
|
||||
|
||||
static const char *
|
||||
const char *
|
||||
get_strength_nick (GtkConstraintStrength strength)
|
||||
{
|
||||
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
|
||||
|
@@ -45,10 +45,7 @@
|
||||
<template class="GuideEditor" parent="GtkWidget">
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid">
|
||||
<property name="margin-start">20</property>
|
||||
<property name="margin-end">20</property>
|
||||
<property name="margin-top">20</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<property name="margin">20</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<child>
|
||||
|
@@ -13,7 +13,6 @@ constraint_editor_resources = gnome.compile_resources('constraint_editor_resourc
|
||||
|
||||
executable('gtk4-constraint-editor',
|
||||
constraint_editor_sources, constraint_editor_resources,
|
||||
c_args: common_cflags,
|
||||
dependencies: libgtk_dep,
|
||||
include_directories: confinc,
|
||||
gui_app: true,
|
||||
|
@@ -6,7 +6,6 @@
|
||||
typedef GtkApplication DemoApplication;
|
||||
typedef GtkApplicationClass DemoApplicationClass;
|
||||
|
||||
static GType demo_application_get_type (void);
|
||||
G_DEFINE_TYPE (DemoApplication, demo_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
typedef struct {
|
||||
@@ -15,7 +14,7 @@ typedef struct {
|
||||
GtkWidget *message;
|
||||
GtkWidget *infobar;
|
||||
GtkWidget *status;
|
||||
GtkWidget *menubutton;
|
||||
GtkWidget *menutool;
|
||||
GMenuModel *toolmenu;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
@@ -26,7 +25,6 @@ typedef struct {
|
||||
} DemoApplicationWindow;
|
||||
typedef GtkApplicationWindowClass DemoApplicationWindowClass;
|
||||
|
||||
static GType demo_application_window_get_type (void);
|
||||
G_DEFINE_TYPE (DemoApplicationWindow, demo_application_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
|
||||
static void create_window (GApplication *app, const char *contents);
|
||||
@@ -421,7 +419,7 @@ demo_application_window_load_state (DemoApplicationWindow *win)
|
||||
static void
|
||||
demo_application_window_init (DemoApplicationWindow *window)
|
||||
{
|
||||
GtkWidget *popover;
|
||||
GtkWidget *menu;
|
||||
|
||||
window->width = -1;
|
||||
window->height = -1;
|
||||
@@ -430,8 +428,8 @@ demo_application_window_init (DemoApplicationWindow *window)
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (window));
|
||||
|
||||
popover = gtk_popover_menu_new_from_model (window->toolmenu);
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->menubutton), popover);
|
||||
menu = gtk_menu_new_from_model (window->toolmenu);
|
||||
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (window->menutool), menu);
|
||||
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (window),
|
||||
win_entries, G_N_ELEMENTS (win_entries),
|
||||
@@ -479,7 +477,7 @@ surface_state_changed (GtkWidget *widget)
|
||||
DemoApplicationWindow *window = (DemoApplicationWindow *)widget;
|
||||
GdkSurfaceState new_state;
|
||||
|
||||
new_state = gdk_toplevel_get_state (GDK_TOPLEVEL (gtk_native_get_surface (GTK_NATIVE (widget))));
|
||||
new_state = gdk_surface_get_state (gtk_native_get_surface (GTK_NATIVE (widget)));
|
||||
window->maximized = (new_state & GDK_SURFACE_STATE_MAXIMIZED) != 0;
|
||||
window->fullscreen = (new_state & GDK_SURFACE_STATE_FULLSCREEN) != 0;
|
||||
}
|
||||
@@ -530,7 +528,7 @@ demo_application_window_class_init (DemoApplicationWindowClass *class)
|
||||
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, infobar);
|
||||
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, status);
|
||||
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, buffer);
|
||||
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, menubutton);
|
||||
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, menutool);
|
||||
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, toolmenu);
|
||||
gtk_widget_class_bind_template_callback (widget_class, clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, update_statusbar);
|
||||
|
@@ -8,24 +8,27 @@
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<object class="GtkToolbar">
|
||||
<property name="hexpand">1</property>
|
||||
<style>
|
||||
<class name="primary-toolbar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="menubutton">
|
||||
<object class="GtkMenuToolButton" id="menutool">
|
||||
<property name="icon-name">document-open</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkToolButton">
|
||||
<property name="icon-name">application-exit</property>
|
||||
<property name="action-name">app.quit</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
<object class="GtkSeparatorToolItem"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkToolButton">
|
||||
<property name="icon-name">applications-other</property>
|
||||
<property name="action-name">win.logo</property>
|
||||
</object>
|
||||
@@ -40,17 +43,25 @@
|
||||
<object class="GtkInfoBar" id="infobar">
|
||||
<property name="visible">0</property>
|
||||
<property name="hexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="message">
|
||||
<property name="hexpand">1</property>
|
||||
<child internal-child="content_area">
|
||||
<object class="GtkBox" id="content_area">
|
||||
<child>
|
||||
<object class="GtkLabel" id="message">
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="action">
|
||||
<object class="GtkButton">
|
||||
<property name="valign">center</property>
|
||||
<property name="label" translatable="yes">_OK</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="clicked_cb"/>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="valign">center</property>
|
||||
<property name="label" translatable="yes">_OK</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="clicked_cb"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<layout>
|
||||
@@ -61,7 +72,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="has-frame">1</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkTextView">
|
||||
<property name="hexpand">1</property>
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Quit</attribute>
|
||||
<attribute name="action">app.quit</attribute>
|
||||
<attribute name="accel"><Control>q</attribute>
|
||||
<attribute name="accel"><Primary>q</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GtkWidget *assistant = NULL;
|
||||
static GtkWidget *progress_bar = NULL;
|
||||
|
||||
static gboolean
|
||||
@@ -26,7 +27,8 @@ apply_changes_gradually (gpointer data)
|
||||
else
|
||||
{
|
||||
/* Close automatically once changes are fully applied. */
|
||||
gtk_widget_destroy (data);
|
||||
gtk_widget_destroy (assistant);
|
||||
assistant = NULL;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
}
|
||||
@@ -35,13 +37,16 @@ static void
|
||||
on_assistant_apply (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
/* Start a timer to simulate changes taking a few seconds to apply. */
|
||||
g_timeout_add (100, apply_changes_gradually, widget);
|
||||
g_timeout_add (100, apply_changes_gradually, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
on_assistant_close_cancel (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gtk_widget_destroy (widget);
|
||||
GtkWidget **assistant = (GtkWidget **) data;
|
||||
|
||||
gtk_widget_destroy (*assistant);
|
||||
*assistant = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -89,10 +94,6 @@ create_page1 (GtkWidget *assistant)
|
||||
GtkWidget *box, *label, *entry;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_widget_set_margin_start (box, 12);
|
||||
gtk_widget_set_margin_end (box, 12);
|
||||
gtk_widget_set_margin_top (box, 12);
|
||||
gtk_widget_set_margin_bottom (box, 12);
|
||||
|
||||
label = gtk_label_new ("You must fill out this entry to continue:");
|
||||
gtk_container_add (GTK_CONTAINER (box), label);
|
||||
@@ -114,15 +115,10 @@ create_page2 (GtkWidget *assistant)
|
||||
{
|
||||
GtkWidget *box, *checkbutton;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_widget_set_margin_start (box, 12);
|
||||
gtk_widget_set_margin_end (box, 12);
|
||||
gtk_widget_set_margin_top (box, 12);
|
||||
gtk_widget_set_margin_bottom (box, 12);
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
|
||||
checkbutton = gtk_check_button_new_with_label ("This is optional data, you may continue "
|
||||
"even if you do not check this");
|
||||
gtk_widget_set_valign (checkbutton, GTK_ALIGN_CENTER);
|
||||
gtk_container_add (GTK_CONTAINER (box), checkbutton);
|
||||
|
||||
gtk_assistant_append_page (GTK_ASSISTANT (assistant), box);
|
||||
@@ -168,8 +164,6 @@ create_page4 (GtkWidget *assistant)
|
||||
GtkWidget*
|
||||
do_assistant (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *assistant;
|
||||
|
||||
if (!assistant)
|
||||
{
|
||||
assistant = gtk_assistant_new ();
|
||||
@@ -178,8 +172,6 @@ do_assistant (GtkWidget *do_widget)
|
||||
|
||||
gtk_window_set_display (GTK_WINDOW (assistant),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_signal_connect (assistant, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &assistant);
|
||||
|
||||
create_page1 (assistant);
|
||||
create_page2 (assistant);
|
||||
@@ -187,9 +179,9 @@ do_assistant (GtkWidget *do_widget)
|
||||
create_page4 (assistant);
|
||||
|
||||
g_signal_connect (G_OBJECT (assistant), "cancel",
|
||||
G_CALLBACK (on_assistant_close_cancel), NULL);
|
||||
G_CALLBACK (on_assistant_close_cancel), &assistant);
|
||||
g_signal_connect (G_OBJECT (assistant), "close",
|
||||
G_CALLBACK (on_assistant_close_cancel), NULL);
|
||||
G_CALLBACK (on_assistant_close_cancel), &assistant);
|
||||
g_signal_connect (G_OBJECT (assistant), "apply",
|
||||
G_CALLBACK (on_assistant_apply), NULL);
|
||||
g_signal_connect (G_OBJECT (assistant), "prepare",
|
||||
@@ -199,7 +191,10 @@ do_assistant (GtkWidget *do_widget)
|
||||
if (!gtk_widget_get_visible (assistant))
|
||||
gtk_widget_show (assistant);
|
||||
else
|
||||
gtk_widget_destroy (assistant);
|
||||
{
|
||||
gtk_widget_destroy (assistant);
|
||||
assistant = NULL;
|
||||
}
|
||||
|
||||
return assistant;
|
||||
}
|
||||
|
@@ -25,8 +25,9 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="has-frame">1</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<property name="min-content-width">150</property>
|
||||
<layout>
|
||||
<property name="left-attach">0</property>
|
||||
|
@@ -131,11 +131,13 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
|
||||
GtkAlign valign, halign;
|
||||
gboolean is_left, is_right, is_top, is_bottom;
|
||||
gboolean has_left, has_right, has_top, has_bottom;
|
||||
GtkStyleContext *context;
|
||||
|
||||
has_left = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_LEFT);
|
||||
has_right = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_RIGHT);
|
||||
has_top = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_TOP);
|
||||
has_bottom = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_BOTTOM);
|
||||
context = gtk_widget_get_style_context (child);
|
||||
has_left = gtk_style_context_has_class (context, GTK_STYLE_CLASS_LEFT);
|
||||
has_right = gtk_style_context_has_class (context, GTK_STYLE_CLASS_RIGHT);
|
||||
has_top = gtk_style_context_has_class (context, GTK_STYLE_CLASS_TOP);
|
||||
has_bottom = gtk_style_context_has_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
|
||||
is_left = is_right = is_top = is_bottom = FALSE;
|
||||
|
||||
@@ -158,24 +160,24 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
|
||||
is_bottom = (child_allocation->y + child_allocation->height == height);
|
||||
|
||||
if (has_left && !is_left)
|
||||
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_LEFT);
|
||||
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
|
||||
else if (!has_left && is_left)
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_LEFT);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
|
||||
|
||||
if (has_right && !is_right)
|
||||
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_RIGHT);
|
||||
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
|
||||
else if (!has_right && is_right)
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_RIGHT);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
|
||||
|
||||
if (has_top && !is_top)
|
||||
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_TOP);
|
||||
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
|
||||
else if (!has_top && is_top)
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_TOP);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
|
||||
|
||||
if (has_bottom && !is_bottom)
|
||||
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
else if (!has_bottom && is_bottom)
|
||||
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -38,22 +38,7 @@ help_activate (GSimpleAction *action,
|
||||
g_print ("Help not available\n");
|
||||
}
|
||||
|
||||
static void
|
||||
not_implemented (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_print ("Action “%s” not implemented\n", g_action_get_name (G_ACTION (action)));
|
||||
}
|
||||
|
||||
static GActionEntry win_entries[] = {
|
||||
{ "new", not_implemented, NULL, NULL, NULL },
|
||||
{ "open", not_implemented, NULL, NULL, NULL },
|
||||
{ "save", not_implemented, NULL, NULL, NULL },
|
||||
{ "save-as", not_implemented, NULL, NULL, NULL },
|
||||
{ "copy", not_implemented, NULL, NULL, NULL },
|
||||
{ "cut", not_implemented, NULL, NULL, NULL },
|
||||
{ "paste", not_implemented, NULL, NULL, NULL },
|
||||
{ "quit", quit_activate, NULL, NULL, NULL },
|
||||
{ "about", about_activate, NULL, NULL, NULL },
|
||||
{ "help", help_activate, NULL, NULL, NULL }
|
||||
@@ -63,7 +48,10 @@ GtkWidget *
|
||||
do_builder (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *toolbar;
|
||||
GActionGroup *actions;
|
||||
GtkAccelGroup *accel_group;
|
||||
GtkWidget *item;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -71,16 +59,58 @@ do_builder (GtkWidget *do_widget)
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/builder/demo.ui");
|
||||
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "toolbar1"));
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (toolbar),
|
||||
"primary-toolbar");
|
||||
actions = (GActionGroup*)g_simple_action_group_new ();
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (actions),
|
||||
win_entries, G_N_ELEMENTS (win_entries),
|
||||
window);
|
||||
gtk_widget_insert_action_group (window, "win", actions);
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "new_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_n, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "open_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_o, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "save_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "quit_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "copy_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_c, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "cut_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_x, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "paste_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_v, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "help_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_F1, 0, GTK_ACCEL_VISIBLE);
|
||||
|
||||
item = (GtkWidget*)gtk_builder_get_object (builder, "about_item");
|
||||
gtk_widget_add_accelerator (item, "activate", accel_group,
|
||||
GDK_KEY_F7, 0, GTK_ACCEL_VISIBLE);
|
||||
|
||||
g_object_set_data_full (G_OBJECT(window), "builder", builder, g_object_unref);
|
||||
}
|
||||
|
551
demos/gtk-demo/changedisplay.c
Normal file
551
demos/gtk-demo/changedisplay.c
Normal file
@@ -0,0 +1,551 @@
|
||||
/* Change Display
|
||||
*
|
||||
* Demonstrates migrating a window between different displays.
|
||||
* A display is a mouse and keyboard with some number of
|
||||
* associated monitors. The neat thing about having multiple
|
||||
* displays is that they can be on a completely separate
|
||||
* computers, as long as there is a network connection to the
|
||||
* computer where the application is running.
|
||||
*
|
||||
* Only some of the windowing systems where GTK runs have the
|
||||
* concept of multiple displays. (The X Window System is the
|
||||
* main example.) Other windowing systems can only handle one
|
||||
* keyboard and mouse, and combine all monitors into
|
||||
* a single display.
|
||||
*
|
||||
* This is a moderately complex example, and demonstrates:
|
||||
*
|
||||
* - Tracking the currently open displays
|
||||
*
|
||||
* - Changing the display for a window
|
||||
*
|
||||
* - Letting the user choose a window by clicking on it
|
||||
*
|
||||
* - Using GtkListStore and GtkTreeView
|
||||
*
|
||||
* - Using GtkDialog
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* The ChangeDisplayInfo structure corresponds to a toplevel window and
|
||||
* holds pointers to widgets inside the toplevel window along with other
|
||||
* information about the contents of the window.
|
||||
* This is a common organizational structure in real applications.
|
||||
*/
|
||||
typedef struct _ChangeDisplayInfo ChangeDisplayInfo;
|
||||
|
||||
struct _ChangeDisplayInfo
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkSizeGroup *size_group;
|
||||
|
||||
GtkTreeModel *display_model;
|
||||
|
||||
GdkDisplay *current_display;
|
||||
};
|
||||
|
||||
/* These enumerations provide symbolic names for the columns
|
||||
* in the two GtkListStore models.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
DISPLAY_COLUMN_NAME,
|
||||
DISPLAY_COLUMN_DISPLAY,
|
||||
DISPLAY_NUM_COLUMNS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SCREEN_COLUMN_NUMBER,
|
||||
SCREEN_COLUMN_SCREEN,
|
||||
SCREEN_NUM_COLUMNS
|
||||
};
|
||||
|
||||
/* Finds the toplevel window under the mouse pointer, if any.
|
||||
*/
|
||||
static GtkWidget *
|
||||
find_toplevel_at_pointer (GdkDisplay *display)
|
||||
{
|
||||
GdkSurface *pointer_window;
|
||||
GtkWidget *widget = NULL;
|
||||
|
||||
pointer_window = gdk_device_get_surface_at_position (gtk_get_current_event_device (), NULL, NULL);
|
||||
|
||||
if (pointer_window)
|
||||
widget = GTK_WIDGET (gtk_native_get_for_surface (pointer_window));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
released_cb (GtkGestureClick *gesture,
|
||||
guint n_press,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gboolean *clicked)
|
||||
{
|
||||
*clicked = TRUE;
|
||||
}
|
||||
|
||||
/* Asks the user to click on a window, then waits for them click
|
||||
* the mouse. When the mouse is released, returns the toplevel
|
||||
* window under the pointer, or NULL, if there is none.
|
||||
*/
|
||||
static GtkWidget *
|
||||
query_for_toplevel (GdkDisplay *display,
|
||||
const char *prompt)
|
||||
{
|
||||
GtkWidget *popup, *label, *frame;
|
||||
GdkCursor *cursor;
|
||||
GtkWidget *toplevel = NULL;
|
||||
GdkDevice *device;
|
||||
|
||||
popup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_display (GTK_WINDOW (popup), display);
|
||||
gtk_window_set_modal (GTK_WINDOW (popup), TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (popup), frame);
|
||||
|
||||
label = gtk_label_new (prompt);
|
||||
g_object_set (label, "margin", 10, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||
|
||||
gtk_widget_show (popup);
|
||||
cursor = gdk_cursor_new_from_name ("crosshair", NULL);
|
||||
device = gtk_get_current_event_device ();
|
||||
|
||||
if (gdk_seat_grab (gdk_device_get_seat (device),
|
||||
gtk_native_get_surface (GTK_NATIVE (popup)),
|
||||
GDK_SEAT_CAPABILITY_ALL_POINTING,
|
||||
FALSE, cursor, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
|
||||
{
|
||||
GtkGesture *gesture = gtk_gesture_click_new ();
|
||||
gboolean clicked = FALSE;
|
||||
|
||||
g_signal_connect (gesture, "released",
|
||||
G_CALLBACK (released_cb), &clicked);
|
||||
gtk_widget_add_controller (popup, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
/* Process events until clicked is set by our button release event handler.
|
||||
* We pass in may_block=TRUE since we want to wait if there
|
||||
* are no events currently.
|
||||
*/
|
||||
while (!clicked)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
gdk_seat_ungrab (gdk_device_get_seat (device));
|
||||
|
||||
toplevel = find_toplevel_at_pointer (display);
|
||||
if (toplevel == popup)
|
||||
toplevel = NULL;
|
||||
}
|
||||
|
||||
g_object_unref (cursor);
|
||||
gtk_widget_destroy (popup);
|
||||
|
||||
return toplevel;
|
||||
}
|
||||
|
||||
/* Prompts the user for a toplevel window to move, and then moves
|
||||
* that window to the currently selected display
|
||||
*/
|
||||
static void
|
||||
query_change_display (ChangeDisplayInfo *info)
|
||||
{
|
||||
GdkDisplay *display = gtk_widget_get_display (info->window);
|
||||
GtkWidget *toplevel;
|
||||
|
||||
toplevel = query_for_toplevel (display,
|
||||
"Please select the toplevel\n"
|
||||
"to move to the new display");
|
||||
|
||||
if (toplevel)
|
||||
gtk_window_set_display (GTK_WINDOW (toplevel), info->current_display);
|
||||
else
|
||||
gdk_display_beep (display);
|
||||
}
|
||||
|
||||
/* Called when the user clicks on a button in our dialog or
|
||||
* closes the dialog through the window manager. Unless the
|
||||
* "Change" button was clicked, we destroy the dialog.
|
||||
*/
|
||||
static void
|
||||
response_cb (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
ChangeDisplayInfo *info)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
query_change_display (info);
|
||||
else
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
/* Called when the user clicks on "Open..." in the display
|
||||
* frame. Prompts for a new display, and then opens a connection
|
||||
* to that display.
|
||||
*/
|
||||
static void
|
||||
open_display_cb (GtkWidget *button,
|
||||
ChangeDisplayInfo *info)
|
||||
{
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *display_entry;
|
||||
GtkWidget *dialog_label;
|
||||
gchar *new_screen_name = NULL;
|
||||
GdkDisplay *result = NULL;
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ("Open Display",
|
||||
GTK_WINDOW (info->window),
|
||||
GTK_DIALOG_MODAL,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_("_OK"), GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
display_entry = gtk_entry_new ();
|
||||
gtk_entry_set_activates_default (GTK_ENTRY (display_entry), TRUE);
|
||||
dialog_label =
|
||||
gtk_label_new ("Please enter the name of\nthe new display\n");
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (content_area), dialog_label);
|
||||
gtk_container_add (GTK_CONTAINER (content_area), display_entry);
|
||||
|
||||
gtk_widget_grab_focus (display_entry);
|
||||
|
||||
while (!result)
|
||||
{
|
||||
gint response_id = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
break;
|
||||
|
||||
new_screen_name = gtk_editable_get_chars (GTK_EDITABLE (display_entry),
|
||||
0, -1);
|
||||
|
||||
if (strcmp (new_screen_name, "") != 0)
|
||||
{
|
||||
result = gdk_display_open (new_screen_name);
|
||||
if (!result)
|
||||
{
|
||||
gchar *error_msg =
|
||||
g_strdup_printf ("Can't open display:\n\t%s\nplease try another one\n",
|
||||
new_screen_name);
|
||||
gtk_label_set_text (GTK_LABEL (dialog_label), error_msg);
|
||||
g_free (error_msg);
|
||||
}
|
||||
|
||||
g_free (new_screen_name);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
/* Called when the user clicks on the "Close" button in the
|
||||
* "Display" frame. Closes the selected display.
|
||||
*/
|
||||
static void
|
||||
close_display_cb (GtkWidget *button,
|
||||
ChangeDisplayInfo *info)
|
||||
{
|
||||
if (info->current_display)
|
||||
gdk_display_close (info->current_display);
|
||||
}
|
||||
|
||||
/* Called when the selected row in the display list changes.
|
||||
* Updates info->current_display, then refills the list of
|
||||
* screens.
|
||||
*/
|
||||
static void
|
||||
display_changed_cb (GtkTreeSelection *selection,
|
||||
ChangeDisplayInfo *info)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (info->current_display)
|
||||
g_object_unref (info->current_display);
|
||||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
gtk_tree_model_get (model, &iter,
|
||||
DISPLAY_COLUMN_DISPLAY, &info->current_display,
|
||||
-1);
|
||||
else
|
||||
info->current_display = NULL;
|
||||
}
|
||||
|
||||
/* This function is used both for creating the "Display" and
|
||||
* "Screen" frames, since they have a similar structure. The
|
||||
* caller hooks up the right context for the value returned
|
||||
* in tree_view, and packs any relevant buttons into button_vbox.
|
||||
*/
|
||||
static void
|
||||
create_frame (ChangeDisplayInfo *info,
|
||||
const char *title,
|
||||
GtkWidget **frame,
|
||||
GtkWidget **tree_view,
|
||||
GtkWidget **button_vbox)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkWidget *scrollwin;
|
||||
GtkWidget *hbox;
|
||||
|
||||
*frame = gtk_frame_new (title);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
||||
g_object_set (hbox, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (*frame), hbox);
|
||||
|
||||
scrollwin = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
|
||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin),
|
||||
GTK_SHADOW_IN);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), scrollwin);
|
||||
|
||||
*tree_view = gtk_tree_view_new ();
|
||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (*tree_view), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (scrollwin), *tree_view);
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (*tree_view));
|
||||
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
|
||||
|
||||
*button_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), *button_vbox);
|
||||
|
||||
if (!info->size_group)
|
||||
info->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
gtk_size_group_add_widget (GTK_SIZE_GROUP (info->size_group), *button_vbox);
|
||||
}
|
||||
|
||||
/* If we have a stack of buttons, it often looks better if their contents
|
||||
* are left-aligned, rather than centered. This function creates a button
|
||||
* and left-aligns it contents.
|
||||
*/
|
||||
GtkWidget *
|
||||
left_align_button_new (const char *label)
|
||||
{
|
||||
GtkWidget *button = gtk_button_new_with_mnemonic (label);
|
||||
GtkWidget *child = gtk_bin_get_child (GTK_BIN (button));
|
||||
|
||||
gtk_widget_set_halign (child, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
/* Creates the "Display" frame in the main window.
|
||||
*/
|
||||
GtkWidget *
|
||||
create_display_frame (ChangeDisplayInfo *info)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *tree_view;
|
||||
GtkWidget *button_vbox;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *selection;
|
||||
GtkWidget *button;
|
||||
|
||||
create_frame (info, "Display", &frame, &tree_view, &button_vbox);
|
||||
|
||||
button = left_align_button_new ("_Open...");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (open_display_cb), info);
|
||||
gtk_container_add (GTK_CONTAINER (button_vbox), button);
|
||||
|
||||
button = left_align_button_new ("_Close");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (close_display_cb), info);
|
||||
gtk_container_add (GTK_CONTAINER (button_vbox), button);
|
||||
|
||||
info->display_model = (GtkTreeModel *)gtk_list_store_new (DISPLAY_NUM_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
GDK_TYPE_DISPLAY);
|
||||
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), info->display_model);
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes ("Name",
|
||||
gtk_cell_renderer_text_new (),
|
||||
"text", DISPLAY_COLUMN_NAME,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
||||
g_signal_connect (selection, "changed",
|
||||
G_CALLBACK (display_changed_cb), info);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
/* Called when one of the currently open displays is closed.
|
||||
* Remove it from our list of displays.
|
||||
*/
|
||||
static void
|
||||
display_closed_cb (GdkDisplay *display,
|
||||
gboolean is_error,
|
||||
ChangeDisplayInfo *info)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gboolean valid;
|
||||
|
||||
for (valid = gtk_tree_model_get_iter_first (info->display_model, &iter);
|
||||
valid;
|
||||
valid = gtk_tree_model_iter_next (info->display_model, &iter))
|
||||
{
|
||||
GdkDisplay *tmp_display;
|
||||
|
||||
gtk_tree_model_get (info->display_model, &iter,
|
||||
DISPLAY_COLUMN_DISPLAY, &tmp_display,
|
||||
-1);
|
||||
if (tmp_display == display)
|
||||
{
|
||||
gtk_list_store_remove (GTK_LIST_STORE (info->display_model), &iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Adds a new display to our list of displays, and connects
|
||||
* to the "closed" signal so that we can remove it from the
|
||||
* list of displays again.
|
||||
*/
|
||||
static void
|
||||
add_display (ChangeDisplayInfo *info,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
const gchar *name = gdk_display_get_name (display);
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_list_store_append (GTK_LIST_STORE (info->display_model), &iter);
|
||||
gtk_list_store_set (GTK_LIST_STORE (info->display_model), &iter,
|
||||
DISPLAY_COLUMN_NAME, name,
|
||||
DISPLAY_COLUMN_DISPLAY, display,
|
||||
-1);
|
||||
|
||||
g_signal_connect (display, "closed",
|
||||
G_CALLBACK (display_closed_cb), info);
|
||||
}
|
||||
|
||||
/* Called when a new display is opened
|
||||
*/
|
||||
static void
|
||||
display_opened_cb (GdkDisplayManager *manager,
|
||||
GdkDisplay *display,
|
||||
ChangeDisplayInfo *info)
|
||||
{
|
||||
add_display (info, display);
|
||||
}
|
||||
|
||||
/* Adds all currently open displays to our list of displays,
|
||||
* and set up a signal connection so that we'll be notified
|
||||
* when displays are opened in the future as well.
|
||||
*/
|
||||
static void
|
||||
initialize_displays (ChangeDisplayInfo *info)
|
||||
{
|
||||
GdkDisplayManager *manager = gdk_display_manager_get ();
|
||||
GSList *displays = gdk_display_manager_list_displays (manager);
|
||||
GSList *tmp_list;
|
||||
|
||||
for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next)
|
||||
add_display (info, tmp_list->data);
|
||||
|
||||
g_slist_free (tmp_list);
|
||||
|
||||
g_signal_connect (manager, "display-opened",
|
||||
G_CALLBACK (display_opened_cb), info);
|
||||
}
|
||||
|
||||
/* Cleans up when the toplevel is destroyed; we remove the
|
||||
* connections we use to track currently open displays, then
|
||||
* free the ChangeDisplayInfo structure.
|
||||
*/
|
||||
static void
|
||||
destroy_info (ChangeDisplayInfo *info)
|
||||
{
|
||||
GdkDisplayManager *manager = gdk_display_manager_get ();
|
||||
GSList *displays = gdk_display_manager_list_displays (manager);
|
||||
GSList *tmp_list;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (manager,
|
||||
display_opened_cb,
|
||||
info);
|
||||
|
||||
for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next)
|
||||
g_signal_handlers_disconnect_by_func (tmp_list->data,
|
||||
display_closed_cb,
|
||||
info);
|
||||
|
||||
g_slist_free (tmp_list);
|
||||
|
||||
g_object_unref (info->size_group);
|
||||
g_object_unref (info->display_model);
|
||||
|
||||
if (info->current_display)
|
||||
g_object_unref (info->current_display);
|
||||
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_cb (GObject *object,
|
||||
ChangeDisplayInfo **info)
|
||||
{
|
||||
destroy_info (*info);
|
||||
*info = NULL;
|
||||
}
|
||||
|
||||
/* Main entry point. If the dialog for this demo doesn't yet exist, creates
|
||||
* it. Otherwise, destroys it.
|
||||
*/
|
||||
GtkWidget *
|
||||
do_changedisplay (GtkWidget *do_widget)
|
||||
{
|
||||
static ChangeDisplayInfo *info = NULL;
|
||||
|
||||
if (!info)
|
||||
{
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *frame;
|
||||
|
||||
info = g_new0 (ChangeDisplayInfo, 1);
|
||||
|
||||
info->window = gtk_dialog_new_with_buttons ("Change Display",
|
||||
GTK_WINDOW (do_widget),
|
||||
0,
|
||||
"Close", GTK_RESPONSE_CLOSE,
|
||||
"Change", GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (info->window), 300, 400);
|
||||
|
||||
g_signal_connect (info->window, "response",
|
||||
G_CALLBACK (response_cb), info);
|
||||
g_signal_connect (info->window, "destroy",
|
||||
G_CALLBACK (destroy_cb), &info);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (info->window));
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
g_object_set (vbox, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (content_area), vbox);
|
||||
|
||||
frame = create_display_frame (info);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
initialize_displays (info);
|
||||
|
||||
gtk_widget_show (info->window);
|
||||
return info->window;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (info->window);
|
||||
return NULL;
|
||||
}
|
||||
}
|
@@ -15,7 +15,7 @@
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
static void
|
||||
void
|
||||
copy_button_clicked (GtkWidget *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -31,7 +31,7 @@ copy_button_clicked (GtkWidget *button,
|
||||
gdk_clipboard_set_text (clipboard, gtk_editable_get_text (GTK_EDITABLE (entry)));
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
paste_received (GObject *source_object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
@@ -75,7 +75,7 @@ paste_received (GObject *source_object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
paste_button_clicked (GtkWidget *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ get_image_paintable (GtkImage *image)
|
||||
{
|
||||
const gchar *icon_name;
|
||||
GtkIconTheme *icon_theme;
|
||||
GtkIconPaintable *icon;
|
||||
GtkIconInfo *icon_info;
|
||||
|
||||
switch (gtk_image_get_storage_type (image))
|
||||
{
|
||||
@@ -107,18 +107,10 @@ get_image_paintable (GtkImage *image)
|
||||
case GTK_IMAGE_ICON_NAME:
|
||||
icon_name = gtk_image_get_icon_name (image);
|
||||
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
|
||||
icon = gtk_icon_theme_lookup_icon (icon_theme,
|
||||
icon_name,
|
||||
NULL,
|
||||
48, 1,
|
||||
gtk_widget_get_direction (GTK_WIDGET (image)),
|
||||
0);
|
||||
if (icon == NULL)
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 48, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
|
||||
if (icon_info == NULL)
|
||||
return NULL;
|
||||
return GDK_PAINTABLE (icon);
|
||||
|
||||
case GTK_IMAGE_EMPTY:
|
||||
case GTK_IMAGE_GICON:
|
||||
return GDK_PAINTABLE (gtk_icon_info_load_texture (icon_info));
|
||||
default:
|
||||
g_warning ("Image storage type %d not handled",
|
||||
gtk_image_get_storage_type (image));
|
||||
@@ -127,54 +119,59 @@ get_image_paintable (GtkImage *image)
|
||||
}
|
||||
|
||||
static void
|
||||
drag_begin (GtkDragSource *source,
|
||||
GdkDrag *drag,
|
||||
GtkWidget *widget)
|
||||
drag_begin (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
|
||||
paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
if (paintable)
|
||||
{
|
||||
gtk_drag_source_set_icon (source, paintable, -2, -2);
|
||||
gtk_drag_set_icon_paintable (drag, paintable, -2, -2);
|
||||
g_object_unref (paintable);
|
||||
}
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
prepare_drag (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *image)
|
||||
void
|
||||
drag_data_get (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (image));
|
||||
GdkPaintable *paintable;
|
||||
|
||||
if (!GDK_IS_TEXTURE (paintable))
|
||||
return NULL;
|
||||
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, paintable);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
drag_drop (GtkDropTarget *dest,
|
||||
const GValue *value,
|
||||
double x,
|
||||
double y,
|
||||
GtkImage *image)
|
||||
{
|
||||
GdkTexture *texture = g_value_get_object (value);
|
||||
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (texture));
|
||||
|
||||
return TRUE;
|
||||
paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
if (GDK_IS_TEXTURE (paintable))
|
||||
gtk_selection_data_set_texture (selection_data, GDK_TEXTURE (paintable));
|
||||
}
|
||||
|
||||
static void
|
||||
copy_image (GSimpleAction *action,
|
||||
GVariant *value,
|
||||
gpointer data)
|
||||
drag_data_received (GtkWidget *widget,
|
||||
GdkDrop *drop,
|
||||
GtkSelectionData *selection_data,
|
||||
gpointer data)
|
||||
{
|
||||
GdkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
|
||||
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
|
||||
if (gtk_selection_data_get_length (selection_data) > 0)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
|
||||
texture = gtk_selection_data_get_texture (selection_data);
|
||||
gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
copy_image (GtkMenuItem *item,
|
||||
gpointer data)
|
||||
{
|
||||
GdkClipboard *clipboard;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
|
||||
paintable = get_image_paintable (GTK_IMAGE (data));
|
||||
|
||||
if (GDK_IS_TEXTURE (paintable))
|
||||
gdk_clipboard_set_texture (clipboard, GDK_TEXTURE (paintable));
|
||||
@@ -199,12 +196,16 @@ paste_image_received (GObject *source,
|
||||
}
|
||||
|
||||
static void
|
||||
paste_image (GSimpleAction *action,
|
||||
GVariant *value,
|
||||
gpointer data)
|
||||
paste_image (GtkMenuItem *item,
|
||||
gpointer data)
|
||||
{
|
||||
GdkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
|
||||
gdk_clipboard_read_texture_async (clipboard, NULL, paste_image_received, data);
|
||||
GdkClipboard *clipboard;
|
||||
|
||||
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
|
||||
gdk_clipboard_read_texture_async (clipboard,
|
||||
NULL,
|
||||
paste_image_received,
|
||||
data);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -214,24 +215,22 @@ pressed_cb (GtkGesture *gesture,
|
||||
double y,
|
||||
GtkWidget *image)
|
||||
{
|
||||
GtkWidget *popover;
|
||||
GMenu *menu;
|
||||
GMenuItem *item;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *item;
|
||||
|
||||
menu = g_menu_new ();
|
||||
item = g_menu_item_new (_("_Copy"), "clipboard.copy");
|
||||
g_menu_append_item (menu, item);
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
item = g_menu_item_new (_("_Paste"), "clipboard.paste");
|
||||
g_menu_append_item (menu, item);
|
||||
item = gtk_menu_item_new_with_mnemonic (_("_Copy"));
|
||||
g_signal_connect (item, "activate", G_CALLBACK (copy_image), image);
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
|
||||
popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu));
|
||||
gtk_widget_set_parent (popover, image);
|
||||
item = gtk_menu_item_new_with_mnemonic (_("_Paste"));
|
||||
g_signal_connect (item, "activate", G_CALLBACK (paste_image), image);
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &(GdkRectangle) { x, y, 1, 1});
|
||||
gtk_popover_popup (GTK_POPOVER (popover));
|
||||
|
||||
g_object_unref (menu);
|
||||
gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@@ -244,15 +243,8 @@ do_clipboard (GtkWidget *do_widget)
|
||||
GtkWidget *entry, *button;
|
||||
GtkWidget *image;
|
||||
GtkGesture *gesture;
|
||||
GActionEntry entries[] = {
|
||||
{ "copy", copy_image, NULL, NULL, NULL },
|
||||
{ "paste", paste_image, NULL, NULL, NULL },
|
||||
};
|
||||
GActionGroup *actions;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Clipboard");
|
||||
@@ -261,10 +253,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
gtk_widget_set_margin_top (vbox, 8);
|
||||
gtk_widget_set_margin_bottom (vbox, 8);
|
||||
g_object_set (vbox, "margin", 8, NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
@@ -273,10 +262,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
gtk_widget_set_margin_start (hbox, 8);
|
||||
gtk_widget_set_margin_end (hbox, 8);
|
||||
gtk_widget_set_margin_top (hbox, 8);
|
||||
gtk_widget_set_margin_bottom (hbox, 8);
|
||||
g_object_set (hbox, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
||||
|
||||
/* Create the first entry */
|
||||
@@ -293,10 +279,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
gtk_widget_set_margin_start (hbox, 8);
|
||||
gtk_widget_set_margin_end (hbox, 8);
|
||||
gtk_widget_set_margin_top (hbox, 8);
|
||||
gtk_widget_set_margin_bottom (hbox, 8);
|
||||
g_object_set (hbox, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
||||
|
||||
/* Create the second entry */
|
||||
@@ -313,27 +296,27 @@ do_clipboard (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
gtk_widget_set_margin_start (hbox, 8);
|
||||
gtk_widget_set_margin_end (hbox, 8);
|
||||
gtk_widget_set_margin_top (hbox, 8);
|
||||
gtk_widget_set_margin_bottom (hbox, 8);
|
||||
g_object_set (hbox, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
||||
|
||||
/* Create the first image */
|
||||
image = gtk_image_new_from_icon_name ("dialog-warning");
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), 48);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), image);
|
||||
|
||||
/* make image a drag source */
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
|
||||
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-begin",
|
||||
G_CALLBACK (drag_begin), image);
|
||||
g_signal_connect (image, "drag-data-get",
|
||||
G_CALLBACK (drag_data_get), image);
|
||||
|
||||
/* accept drops on image */
|
||||
dest = gtk_drop_target_new (GDK_TYPE_TEXTURE, GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (drag_drop), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
|
||||
NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-data-received",
|
||||
G_CALLBACK (drag_data_received), image);
|
||||
|
||||
/* context menu on image */
|
||||
gesture = gtk_gesture_click_new ();
|
||||
@@ -341,41 +324,30 @@ do_clipboard (GtkWidget *do_widget)
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (pressed_cb), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
actions = G_ACTION_GROUP (g_simple_action_group_new ());
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), image);
|
||||
|
||||
gtk_widget_insert_action_group (image, "clipboard", actions);
|
||||
|
||||
g_object_unref (actions);
|
||||
|
||||
/* Create the second image */
|
||||
image = gtk_image_new_from_icon_name ("process-stop");
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), 48);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), image);
|
||||
|
||||
/* make image a drag source */
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
|
||||
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-begin",
|
||||
G_CALLBACK (drag_begin), image);
|
||||
g_signal_connect (image, "drag-data-get",
|
||||
G_CALLBACK (drag_data_get), image);
|
||||
|
||||
/* accept drops on image */
|
||||
dest = gtk_drop_target_new (GDK_TYPE_TEXTURE, GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (drag_drop), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
|
||||
NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-data-received",
|
||||
G_CALLBACK (drag_data_received), image);
|
||||
|
||||
/* context menu on image */
|
||||
gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (pressed_cb), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
actions = G_ACTION_GROUP (g_simple_action_group_new ());
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), image);
|
||||
|
||||
gtk_widget_insert_action_group (image, "clipboard", actions);
|
||||
|
||||
g_object_unref (actions);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
@@ -16,7 +16,7 @@ static GtkWidget *frame;
|
||||
/* draw callback for the drawing area
|
||||
*/
|
||||
static void
|
||||
draw_function (GtkDrawingArea *drawing_area,
|
||||
draw_function (GtkDrawingArea *da,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
@@ -69,7 +69,7 @@ do_colorsel (GtkWidget *do_widget)
|
||||
color.green = 0;
|
||||
color.alpha = 1;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Color Chooser");
|
||||
@@ -79,10 +79,7 @@ do_colorsel (GtkWidget *do_widget)
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 12);
|
||||
gtk_widget_set_margin_end (vbox, 12);
|
||||
gtk_widget_set_margin_top (vbox, 12);
|
||||
gtk_widget_set_margin_bottom (vbox, 12);
|
||||
g_object_set (vbox, "margin", 12, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
/*
|
||||
@@ -90,6 +87,7 @@ do_colorsel (GtkWidget *do_widget)
|
||||
*/
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
|
@@ -19,7 +19,7 @@ enum
|
||||
static GtkTreeModel *
|
||||
create_icon_store (void)
|
||||
{
|
||||
const char *icon_names[6] = {
|
||||
const gchar *icon_names[6] = {
|
||||
"dialog-warning",
|
||||
"process-stop",
|
||||
"document-new",
|
||||
@@ -27,7 +27,7 @@ create_icon_store (void)
|
||||
NULL,
|
||||
"document-open"
|
||||
};
|
||||
const char *labels[6] = {
|
||||
const gchar *labels[6] = {
|
||||
N_("Warning"),
|
||||
N_("Stop"),
|
||||
N_("New"),
|
||||
@@ -111,8 +111,8 @@ static GtkTreeModel *
|
||||
create_capital_store (void)
|
||||
{
|
||||
struct {
|
||||
const char *group;
|
||||
const char *capital;
|
||||
gchar *group;
|
||||
gchar *capital;
|
||||
} capitals[] = {
|
||||
{ "A - B", NULL },
|
||||
{ NULL, "Albany" },
|
||||
@@ -234,7 +234,7 @@ typedef struct _MaskEntry MaskEntry;
|
||||
struct _MaskEntry
|
||||
{
|
||||
GtkEntry entry;
|
||||
const char *mask;
|
||||
gchar *mask;
|
||||
};
|
||||
|
||||
typedef struct _MaskEntryClass MaskEntryClass;
|
||||
@@ -246,7 +246,6 @@ struct _MaskEntryClass
|
||||
|
||||
static void mask_entry_editable_init (GtkEditableInterface *iface);
|
||||
|
||||
static GType mask_entry_get_type (void);
|
||||
G_DEFINE_TYPE_WITH_CODE (MaskEntry, mask_entry, GTK_TYPE_ENTRY,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
|
||||
mask_entry_editable_init));
|
||||
@@ -311,7 +310,7 @@ do_combobox (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Combo Boxes");
|
||||
@@ -320,10 +319,7 @@ do_combobox (GtkWidget *do_widget)
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
gtk_widget_set_margin_start (vbox, 10);
|
||||
gtk_widget_set_margin_end (vbox, 10);
|
||||
gtk_widget_set_margin_top (vbox, 10);
|
||||
gtk_widget_set_margin_bottom (vbox, 10);
|
||||
g_object_set (vbox, "margin", 10, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
/* A combobox demonstrating cell renderers, separators and
|
||||
@@ -333,10 +329,7 @@ do_combobox (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_margin_start (box, 5);
|
||||
gtk_widget_set_margin_end (box, 5);
|
||||
gtk_widget_set_margin_top (box, 5);
|
||||
gtk_widget_set_margin_bottom (box, 5);
|
||||
g_object_set (box, "margin", 5, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), box);
|
||||
|
||||
model = create_icon_store ();
|
||||
@@ -377,10 +370,7 @@ do_combobox (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_margin_start (box, 5);
|
||||
gtk_widget_set_margin_end (box, 5);
|
||||
gtk_widget_set_margin_top (box, 5);
|
||||
gtk_widget_set_margin_bottom (box, 5);
|
||||
g_object_set (box, "margin", 5, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), box);
|
||||
|
||||
model = create_capital_store ();
|
||||
@@ -408,10 +398,7 @@ do_combobox (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_margin_start (box, 5);
|
||||
gtk_widget_set_margin_end (box, 5);
|
||||
gtk_widget_set_margin_top (box, 5);
|
||||
gtk_widget_set_margin_bottom (box, 5);
|
||||
g_object_set (box, "margin", 5, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), box);
|
||||
|
||||
combo = gtk_combo_box_text_new_with_entry ();
|
||||
@@ -429,10 +416,7 @@ do_combobox (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_margin_start (box, 5);
|
||||
gtk_widget_set_margin_end (box, 5);
|
||||
gtk_widget_set_margin_top (box, 5);
|
||||
gtk_widget_set_margin_bottom (box, 5);
|
||||
g_object_set (box, "margin", 5, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), box);
|
||||
|
||||
combo = gtk_combo_box_text_new ();
|
||||
|
@@ -255,7 +255,7 @@ do_constraints (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *header, *box, *grid, *button;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
|
@@ -211,7 +211,7 @@ do_constraints2 (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *header, *box, *grid, *button;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
|
@@ -131,7 +131,7 @@ do_constraints3 (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *header, *box, *grid, *button;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
|
@@ -24,7 +24,7 @@ do_css_accordion (GtkWidget *do_widget)
|
||||
GtkWidget *container, *child;
|
||||
GtkStyleProvider *provider;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "CSS Accordion");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 300);
|
||||
|
@@ -72,7 +72,7 @@ do_css_basics (GtkWidget *do_widget)
|
||||
GtkTextBuffer *text;
|
||||
GBytes *bytes;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
|
@@ -11,8 +11,8 @@
|
||||
* These are the available blend modes.
|
||||
*/
|
||||
struct {
|
||||
const char *name;
|
||||
const char *id;
|
||||
gchar *name;
|
||||
gchar *id;
|
||||
} blend_modes[] =
|
||||
{
|
||||
{ "Color", "color" },
|
||||
|
@@ -86,7 +86,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
|
||||
GtkTextBuffer *text;
|
||||
GBytes *bytes;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
|
@@ -72,7 +72,7 @@ do_css_pixbufs (GtkWidget *do_widget)
|
||||
GtkTextBuffer *text;
|
||||
GBytes *bytes;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
|
@@ -58,23 +58,26 @@ apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
GtkWidget *
|
||||
create_toolbar (void)
|
||||
{
|
||||
GtkWidget *toolbar;
|
||||
GtkWidget *item;
|
||||
GtkToolItem *item;
|
||||
|
||||
toolbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
toolbar = gtk_toolbar_new ();
|
||||
gtk_widget_set_valign (toolbar, GTK_ALIGN_CENTER);
|
||||
|
||||
item = gtk_button_new_from_icon_name ("go-next");
|
||||
gtk_container_add (GTK_CONTAINER (toolbar), item);
|
||||
item = gtk_tool_button_new (NULL, NULL);
|
||||
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-next");
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
|
||||
|
||||
item = gtk_button_new_from_icon_name ("go-previous");
|
||||
gtk_container_add (GTK_CONTAINER (toolbar), item);
|
||||
item = gtk_tool_button_new (NULL, NULL);
|
||||
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-previous");
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
|
||||
|
||||
item = gtk_button_new_with_label ("Hello World");
|
||||
gtk_container_add (GTK_CONTAINER (toolbar), item);
|
||||
item = gtk_tool_button_new (NULL, "Hello World");
|
||||
gtk_tool_item_set_is_important (item, TRUE);
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
|
||||
|
||||
return toolbar;
|
||||
}
|
||||
@@ -91,7 +94,7 @@ do_css_shadows (GtkWidget *do_widget)
|
||||
GtkTextBuffer *text;
|
||||
GBytes *bytes;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
|
@@ -24,6 +24,7 @@ do_cursors (GtkWidget *do_widget)
|
||||
GtkBuilder *builder;
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
|
@@ -656,10 +656,7 @@
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="margin-start">60</property>
|
||||
<property name="margin-end">60</property>
|
||||
<property name="margin-top">60</property>
|
||||
<property name="margin-bottom">60</property>
|
||||
<property name="margin">60</property>
|
||||
<property name="spacing">10</property>
|
||||
<property name="halign">center</property>
|
||||
<child>
|
||||
@@ -675,10 +672,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -735,10 +729,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -795,10 +786,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -868,10 +856,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -928,10 +913,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -988,10 +970,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1048,10 +1027,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1108,10 +1084,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1181,10 +1154,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1241,10 +1211,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1301,10 +1268,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1361,10 +1325,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1434,10 +1395,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1494,10 +1452,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1554,10 +1509,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1614,10 +1566,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1674,10 +1623,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1734,10 +1680,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1794,10 +1737,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1867,10 +1807,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1927,10 +1864,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -1987,10 +1921,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2047,10 +1978,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2107,10 +2035,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2167,10 +2092,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2227,10 +2149,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2287,10 +2206,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2347,10 +2263,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2407,10 +2320,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2467,10 +2377,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2527,10 +2434,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2587,10 +2491,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2647,10 +2548,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2707,10 +2605,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2780,10 +2675,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
@@ -2840,10 +2732,7 @@
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
|
@@ -104,13 +104,6 @@
|
||||
<file>gtkfishbowl.c</file>
|
||||
<file>gtkfishbowl.h</file>
|
||||
</gresource>
|
||||
<gresource prefix="/gears">
|
||||
<file>gtkgears.c</file>
|
||||
<file>gtkgears.h</file>
|
||||
</gresource>
|
||||
<gresource prefix="/iconscroll">
|
||||
<file>iconscroll.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/iconview">
|
||||
<file>gnome-fs-directory.png</file>
|
||||
<file>gnome-fs-regular.png</file>
|
||||
@@ -153,6 +146,7 @@
|
||||
<file>application_demo.c</file>
|
||||
<file>assistant.c</file>
|
||||
<file>builder.c</file>
|
||||
<file>changedisplay.c</file>
|
||||
<file>clipboard.c</file>
|
||||
<file>colorsel.c</file>
|
||||
<file>combobox.c</file>
|
||||
@@ -170,22 +164,21 @@
|
||||
<file>drawingarea.c</file>
|
||||
<file>dnd.c</file>
|
||||
<file>editable_cells.c</file>
|
||||
<file>entry_buffer.c</file>
|
||||
<file>entry_completion.c</file>
|
||||
<file>entry_undo.c</file>
|
||||
<file>expander.c</file>
|
||||
<file>filtermodel.c</file>
|
||||
<file>fishbowl.c</file>
|
||||
<file>fixed.c</file>
|
||||
<file>flowbox.c</file>
|
||||
<file>foreigndrawing.c</file>
|
||||
<file>font_features.c</file>
|
||||
<file>fontplane.c</file>
|
||||
<file>fontrendering.c</file>
|
||||
<file>gears.c</file>
|
||||
<file>gestures.c</file>
|
||||
<file>glarea.c</file>
|
||||
<file>headerbar.c</file>
|
||||
<file>hypertext.c</file>
|
||||
<file>iconscroll.c</file>
|
||||
<file>iconview.c</file>
|
||||
<file>iconview_edit.c</file>
|
||||
<file>images.c</file>
|
||||
@@ -194,6 +187,7 @@
|
||||
<file>listbox.c</file>
|
||||
<file>list_store.c</file>
|
||||
<file>markup.c</file>
|
||||
<file>menus.c</file>
|
||||
<file>modelbutton.c</file>
|
||||
<file>overlay.c</file>
|
||||
<file>overlay2.c</file>
|
||||
@@ -204,9 +198,9 @@
|
||||
<file>paintable_mediastream.c</file>
|
||||
<file>panes.c</file>
|
||||
<file>password_entry.c</file>
|
||||
<file>peg_solitaire.c</file>
|
||||
<file>pickers.c</file>
|
||||
<file>pixbufs.c</file>
|
||||
<file>popover.c</file>
|
||||
<file>printing.c</file>
|
||||
<file>revealer.c</file>
|
||||
<file>rotated_text.c</file>
|
||||
@@ -214,7 +208,6 @@
|
||||
<file>search_entry.c</file>
|
||||
<file>search_entry2.c</file>
|
||||
<file>shortcuts.c</file>
|
||||
<file>shortcut_triggers.c</file>
|
||||
<file>sizegroup.c</file>
|
||||
<file>sidebar.c</file>
|
||||
<file>sliding_puzzle.c</file>
|
||||
@@ -223,7 +216,6 @@
|
||||
<file>spinner.c</file>
|
||||
<file>tabs.c</file>
|
||||
<file>tagged_entry.c</file>
|
||||
<file>textundo.c</file>
|
||||
<file>textview.c</file>
|
||||
<file>textscroll.c</file>
|
||||
<file>theming_style_classes.c</file>
|
||||
@@ -244,6 +236,9 @@
|
||||
<file>messages.txt</file>
|
||||
<file>apple-red.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/popover">
|
||||
<file>popover.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/glarea">
|
||||
<file>glarea-gl.fs.glsl</file>
|
||||
<file>glarea-gl.vs.glsl</file>
|
||||
|
@@ -22,75 +22,6 @@
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<menu id="menubar">
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes">_File</attribute>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_New</attribute>
|
||||
<attribute name="action">win.new</attribute>
|
||||
<attribute name="accel"><Control>n</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Open</attribute>
|
||||
<attribute name="action">win.open</attribute>
|
||||
<attribute name="accel"><Control>o</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Save</attribute>
|
||||
<attribute name="action">win.save</attribute>
|
||||
<attribute name="accel"><Control>s</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Save _As</attribute>
|
||||
<attribute name="action">win.save-as</attribute>
|
||||
<attribute name="accel"><Control>q</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Quit</attribute>
|
||||
<attribute name="action">win.quit</attribute>
|
||||
<attribute name="accel"><Control><Shift>s</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</submenu>
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes">_Edit</attribute>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Copy</attribute>
|
||||
<attribute name="action">win.copy</attribute>
|
||||
<attribute name="accel"><Control>c</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Cut</attribute>
|
||||
<attribute name="action">win.cut</attribute>
|
||||
<attribute name="accel"><Control>x</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Paste</attribute>
|
||||
<attribute name="action">win.paste</attribute>
|
||||
<attribute name="accel"><Control>v</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</submenu>
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes">_Help</attribute>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Help</attribute>
|
||||
<attribute name="action">win.help</attribute>
|
||||
<attribute name="accel">F1</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_About</attribute>
|
||||
<attribute name="action">win.about</attribute>
|
||||
<attribute name="accel">F7</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</submenu>
|
||||
</menu>
|
||||
<object class="GtkAboutDialog" id="aboutdialog1">
|
||||
<property name="program-name" translatable="yes">Builder demo</property>
|
||||
<property name="logo-icon-name" translatable="yes">gtk3-demo</property>
|
||||
@@ -106,57 +37,159 @@
|
||||
<object class="GtkBox" id="vbox1">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkPopoverMenuBar" id="menubar1">
|
||||
<property name="menu-model">menubar</property>
|
||||
<object class="GtkMenuBar" id="menubar1">
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="a11y-menubar">
|
||||
<property name="AtkObject::accessible-name">The menubar</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem">
|
||||
<property name="label" translatable="yes">_File</property>
|
||||
<property name="use-underline">1</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu">
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="new_item">
|
||||
<property name="label" translatable="yes">_New</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="open_item">
|
||||
<property name="label" translatable="yes">_Open</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="save_item">
|
||||
<property name="label" translatable="yes">_Save</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="save_as_item">
|
||||
<property name="label" translatable="yes">Save _As</property>
|
||||
<property name="use-underline">1</property>
|
||||
<accelerator key="s" modifiers="primary | shift-mask" signal="activate"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="quit_item">
|
||||
<property name="label" translatable="yes">_Quit</property>
|
||||
<property name="use-underline">1</property>
|
||||
<property name="action-name">win.quit</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem">
|
||||
<property name="label" translatable="yes">_Edit</property>
|
||||
<property name="use-underline">1</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu">
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="copy_item">
|
||||
<property name="label" translatable="yes">_Copy</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="cut_item">
|
||||
<property name="label" translatable="yes">_Cut</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="paste_item">
|
||||
<property name="label" translatable="yes">_Paste</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem">
|
||||
<property name="label" translatable="yes">_Help</property>
|
||||
<property name="use-underline">1</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu">
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="help_item">
|
||||
<property name="label" translatable="yes">_Help</property>
|
||||
<property name="use-underline">1</property>
|
||||
<property name="action-name">win.help</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="about_item">
|
||||
<property name="label" translatable="yes">_About</property>
|
||||
<property name="use-underline">1</property>
|
||||
<property name="action-name">win.about</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="toolbar1">
|
||||
<object class="GtkToolbar" id="toolbar1">
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="a11y-toolbar">
|
||||
<property name="AtkObject::accessible-name">The toolbar</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkToolButton">
|
||||
<property name="label" translatable="yes">New</property>
|
||||
<property name="tooltip-text" translatable="yes">Create a new file</property>
|
||||
<property name="icon-name">document-new</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkToolButton">
|
||||
<property name="label" translatable="yes">Open</property>
|
||||
<property name="tooltip-text" translatable="yes">Open a file</property>
|
||||
<property name="icon-name">document-open</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkToolButton">
|
||||
<property name="label" translatable="yes">Save</property>
|
||||
<property name="tooltip-text" translatable="yes">Save a file</property>
|
||||
<property name="icon-name">document-save</property>
|
||||
<property name="is-important">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
<object class="GtkSeparatorToolItem"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkToolButton">
|
||||
<property name="label" translatable="yes">Copy</property>
|
||||
<property name="tooltip-text" translatable="yes">Copy selected object into the clipboard</property>
|
||||
<property name="icon-name">edit-copy</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkToolButton">
|
||||
<property name="label" translatable="yes">Cut</property>
|
||||
<property name="tooltip-text" translatable="yes">Cut selected object into the clipboard</property>
|
||||
<property name="icon-name">edit-cut</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkToolButton">
|
||||
<property name="label" translatable="yes">Paste</property>
|
||||
<property name="tooltip-text" translatable="yes">Paste object from the clipboard</property>
|
||||
<property name="icon-name">edit-paste</property>
|
||||
@@ -166,9 +199,8 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="has-frame">1</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<property name="expand">1</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview1">
|
||||
<property name="model">liststore1</property>
|
||||
|
@@ -129,13 +129,13 @@ demo_tagged_entry_size_allocate (GtkWidget *widget,
|
||||
baseline);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
demo_tagged_entry_grab_focus (GtkWidget *widget)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
return gtk_widget_grab_focus (priv->entry);
|
||||
gtk_widget_grab_focus (priv->entry);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -472,7 +472,7 @@ demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *tag,
|
||||
gtk_container_add (GTK_CONTAINER (tag->button), image);
|
||||
gtk_widget_set_halign (tag->button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (tag->button, GTK_ALIGN_CENTER);
|
||||
gtk_button_set_has_frame (GTK_BUTTON (tag->button), FALSE);
|
||||
gtk_button_set_relief (GTK_BUTTON (tag->button), GTK_RELIEF_NONE);
|
||||
gtk_container_add (GTK_CONTAINER (tag->box), tag->button);
|
||||
g_signal_connect (tag->button, "clicked", G_CALLBACK (on_button_clicked), tag);
|
||||
}
|
||||
|
@@ -105,7 +105,7 @@ do_dialog (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Dialogs and Message Boxes");
|
||||
@@ -114,17 +114,11 @@ do_dialog (GtkWidget *do_widget)
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
frame = gtk_frame_new ("Dialogs");
|
||||
gtk_widget_set_margin_start (frame, 8);
|
||||
gtk_widget_set_margin_end (frame, 8);
|
||||
gtk_widget_set_margin_top (frame, 8);
|
||||
gtk_widget_set_margin_bottom (frame, 8);
|
||||
g_object_set (frame, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
gtk_widget_set_margin_top (vbox, 8);
|
||||
gtk_widget_set_margin_bottom (vbox, 8);
|
||||
g_object_set (vbox, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
/* Standard message dialog */
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/* Drag-and-Drop
|
||||
*
|
||||
* I can't believe its not glade!
|
||||
*
|
||||
* Try right-clicking in the window.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
@@ -42,7 +40,7 @@ free_demo_widget (gpointer data)
|
||||
}
|
||||
|
||||
#define GTK_TYPE_DEMO_WIDGET (gtk_demo_widget_get_type ())
|
||||
static GType gtk_demo_widget_get_type (void);
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GtkDemoWidget, gtk_demo_widget, copy_demo_widget, free_demo_widget)
|
||||
|
||||
static GtkDemoWidget *
|
||||
@@ -59,7 +57,7 @@ serialize_widget (GtkWidget *widget)
|
||||
}
|
||||
else if (GTK_IS_SPINNER (widget))
|
||||
{
|
||||
g_object_get (widget, "spinning", &demo->active, NULL);
|
||||
g_object_get (widget, "active", &demo->active, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -80,8 +78,8 @@ deserialize_widget (GtkDemoWidget *demo)
|
||||
}
|
||||
else if (demo->type == GTK_TYPE_SPINNER)
|
||||
{
|
||||
widget = g_object_new (demo->type, "spinning", demo->active, NULL);
|
||||
gtk_widget_add_css_class (widget, "demo");
|
||||
widget = g_object_new (demo->type, "active", demo->active, NULL);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -94,7 +92,7 @@ deserialize_widget (GtkDemoWidget *demo)
|
||||
static double pos_x, pos_y;
|
||||
|
||||
static void
|
||||
new_label_cb (GtkWidget *button,
|
||||
new_label_cb (GtkMenuItem *item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFixed *fixed = data;
|
||||
@@ -102,54 +100,46 @@ new_label_cb (GtkWidget *button,
|
||||
|
||||
widget = gtk_label_new ("Label");
|
||||
gtk_fixed_put (fixed, widget, pos_x, pos_y);
|
||||
|
||||
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
|
||||
}
|
||||
|
||||
static void
|
||||
new_spinner_cb (GtkWidget *button,
|
||||
new_spinner_cb (GtkMenuItem *item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFixed *fixed = data;
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_spinner_new ();
|
||||
gtk_widget_add_css_class (widget, "demo");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
|
||||
gtk_spinner_start (GTK_SPINNER (widget));
|
||||
gtk_fixed_put (fixed, widget, pos_x, pos_y);
|
||||
|
||||
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
|
||||
}
|
||||
|
||||
static void
|
||||
copy_cb (GtkWidget *button, GtkWidget *child)
|
||||
copy_cb (GtkWidget *child)
|
||||
{
|
||||
GdkClipboard *clipboard;
|
||||
GtkDemoWidget *demo;
|
||||
|
||||
g_print ("Copy %s\n", G_OBJECT_TYPE_NAME (child));
|
||||
|
||||
demo = serialize_widget (child);
|
||||
|
||||
clipboard = gdk_display_get_clipboard (gdk_display_get_default ());
|
||||
gdk_clipboard_set (clipboard, GTK_TYPE_DEMO_WIDGET, demo);
|
||||
|
||||
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
|
||||
}
|
||||
|
||||
static void
|
||||
delete_cb (GtkWidget *button, GtkWidget *child)
|
||||
delete_cb (GtkWidget *child)
|
||||
{
|
||||
gtk_widget_destroy (child);
|
||||
|
||||
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
|
||||
}
|
||||
|
||||
static void
|
||||
cut_cb (GtkWidget *button, GtkWidget *child)
|
||||
cut_cb (GtkWidget *child)
|
||||
{
|
||||
copy_cb (button, child);
|
||||
delete_cb (button, child);
|
||||
|
||||
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
|
||||
copy_cb (child);
|
||||
delete_cb (child);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -185,7 +175,7 @@ value_read (GObject *source,
|
||||
}
|
||||
|
||||
static void
|
||||
paste_cb (GtkWidget *button, GtkWidget *fixed)
|
||||
paste_cb (GtkWidget *fixed)
|
||||
{
|
||||
GdkClipboard *clipboard;
|
||||
|
||||
@@ -197,8 +187,6 @@ paste_cb (GtkWidget *button, GtkWidget *fixed)
|
||||
}
|
||||
else
|
||||
g_print ("Don't know how to handle clipboard contents\n");
|
||||
|
||||
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -217,7 +205,7 @@ edit_label_done (GtkWidget *entry, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
edit_cb (GtkWidget *button, GtkWidget *child)
|
||||
edit_cb (GtkWidget *child)
|
||||
{
|
||||
GtkWidget *fixed = gtk_widget_get_parent (child);
|
||||
int x, y;
|
||||
@@ -231,7 +219,6 @@ edit_cb (GtkWidget *button, GtkWidget *child)
|
||||
g_object_set_data (G_OBJECT (entry), "label", child);
|
||||
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), gtk_label_get_text (GTK_LABEL (child)));
|
||||
gtk_editable_set_width_chars (GTK_EDITABLE (entry), 12);
|
||||
g_signal_connect (entry, "activate", G_CALLBACK (edit_label_done), NULL);
|
||||
gtk_fixed_put (GTK_FIXED (fixed), entry, x, y);
|
||||
gtk_widget_grab_focus (entry);
|
||||
@@ -240,12 +227,9 @@ edit_cb (GtkWidget *button, GtkWidget *child)
|
||||
{
|
||||
gboolean active;
|
||||
|
||||
g_object_get (child, "spinning", &active, NULL);
|
||||
g_object_set (child, "spinning", !active, NULL);
|
||||
g_object_get (child, "active", &active, NULL);
|
||||
g_object_set (child, "active", !active, NULL);
|
||||
}
|
||||
|
||||
if (button)
|
||||
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -263,66 +247,65 @@ pressed_cb (GtkGesture *gesture,
|
||||
|
||||
if (gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)) == GDK_BUTTON_SECONDARY)
|
||||
{
|
||||
GdkRectangle rect;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *box;
|
||||
GtkWidget *item;
|
||||
GdkClipboard *clipboard;
|
||||
|
||||
pos_x = x;
|
||||
pos_y = y;
|
||||
|
||||
menu = gtk_popover_new ();
|
||||
gtk_widget_set_parent (menu, widget);
|
||||
gtk_popover_set_has_arrow (GTK_POPOVER (menu), FALSE);
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (menu), &(GdkRectangle){ x, y, 1, 1});
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (menu), box);
|
||||
menu = gtk_menu_new ();
|
||||
item = gtk_menu_item_new_with_label ("New Label");
|
||||
g_signal_connect (item, "activate", G_CALLBACK (new_label_cb), widget);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
item = gtk_menu_item_new_with_label ("New Spinner");
|
||||
g_signal_connect (item, "activate", G_CALLBACK (new_spinner_cb), widget);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
|
||||
item = gtk_button_new_with_label ("New Label");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
|
||||
g_signal_connect (item, "clicked", G_CALLBACK (new_label_cb), widget);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
item = gtk_button_new_with_label ("New Spinner");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
|
||||
g_signal_connect (item, "clicked", G_CALLBACK (new_spinner_cb), widget);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
item = gtk_separator_menu_item_new ();
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
|
||||
item = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
|
||||
item = gtk_button_new_with_label ("Edit");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
|
||||
item = gtk_menu_item_new_with_label ("Edit");
|
||||
gtk_widget_set_sensitive (item, child != NULL && child != widget);
|
||||
g_signal_connect (item, "clicked", G_CALLBACK (edit_cb), child);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
g_signal_connect_swapped (item, "activate", G_CALLBACK (edit_cb), child);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
|
||||
item = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
item = gtk_separator_menu_item_new ();
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
|
||||
item = gtk_button_new_with_label ("Cut");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
|
||||
item = gtk_menu_item_new_with_label ("Cut");
|
||||
gtk_widget_set_sensitive (item, child != NULL && child != widget);
|
||||
g_signal_connect (item, "clicked", G_CALLBACK (cut_cb), child);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
item = gtk_button_new_with_label ("Copy");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
|
||||
g_signal_connect_swapped (item, "activate", G_CALLBACK (cut_cb), child);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
item = gtk_menu_item_new_with_label ("Copy");
|
||||
gtk_widget_set_sensitive (item, child != NULL && child != widget);
|
||||
g_signal_connect (item, "clicked", G_CALLBACK (copy_cb), child);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
item = gtk_button_new_with_label ("Paste");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
|
||||
g_signal_connect_swapped (item, "activate", G_CALLBACK (copy_cb), child);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
item = gtk_menu_item_new_with_label ("Paste");
|
||||
clipboard = gdk_display_get_clipboard (gdk_display_get_default ());
|
||||
gtk_widget_set_sensitive (item,
|
||||
gdk_content_formats_contain_gtype (gdk_clipboard_get_formats (clipboard), GTK_TYPE_DEMO_WIDGET));
|
||||
g_signal_connect (item, "clicked", G_CALLBACK (paste_cb), widget);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
item = gtk_button_new_with_label ("Delete");
|
||||
gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
|
||||
g_signal_connect_swapped (item, "activate", G_CALLBACK (paste_cb), widget);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
item = gtk_menu_item_new_with_label ("Delete");
|
||||
gtk_widget_set_sensitive (item, child != NULL && child != widget);
|
||||
g_signal_connect (item, "clicked", G_CALLBACK (delete_cb), child);
|
||||
gtk_container_add (GTK_CONTAINER (box), item);
|
||||
g_signal_connect_swapped (item, "activate", G_CALLBACK (delete_cb), child);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
|
||||
gtk_popover_popup (GTK_POPOVER (menu));
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
rect.width = 0;
|
||||
rect.height = 0;
|
||||
|
||||
gtk_menu_popup_at_rect (GTK_MENU (menu),
|
||||
gtk_native_get_surface (gtk_widget_get_native (widget)),
|
||||
&rect,
|
||||
GDK_GRAVITY_NORTH_WEST,
|
||||
GDK_GRAVITY_NORTH_WEST,
|
||||
NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +325,7 @@ released_cb (GtkGesture *gesture,
|
||||
if (gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)) == GDK_BUTTON_PRIMARY)
|
||||
{
|
||||
if (child != NULL && child != widget)
|
||||
edit_cb (NULL, child);
|
||||
edit_cb (child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +340,7 @@ do_dnd (GtkWidget *do_widget)
|
||||
GtkGesture *multipress;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Drag-and-drop");
|
||||
|
@@ -189,7 +189,7 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
|
||||
@@ -198,10 +198,7 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
G_CALLBACK (close_window), NULL);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 16);
|
||||
gtk_widget_set_margin_end (vbox, 16);
|
||||
gtk_widget_set_margin_top (vbox, 16);
|
||||
gtk_widget_set_margin_bottom (vbox, 16);
|
||||
g_object_set (vbox, "margin", 16, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
/*
|
||||
@@ -214,6 +211,7 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_vexpand (frame, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
@@ -234,6 +232,7 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_widget_set_vexpand (frame, TRUE);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
|
@@ -275,9 +275,6 @@ cell_edited (GtkCellRendererText *cell,
|
||||
g_array_index (articles, Item, i).product, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
@@ -348,7 +345,7 @@ do_editable_cells (GtkWidget *do_widget)
|
||||
GtkTreeModel *items_model;
|
||||
GtkTreeModel *numbers_model;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Editable Cells");
|
||||
@@ -356,17 +353,15 @@ do_editable_cells (GtkWidget *do_widget)
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
g_object_set (vbox, "margin", 5, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (vbox),
|
||||
gtk_label_new ("Shopping list (you can edit the cells!)"));
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_ETCHED_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
60
demos/gtk-demo/entry_buffer.c
Normal file
60
demos/gtk-demo/entry_buffer.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Entry/Entry Buffer
|
||||
*
|
||||
* GtkEntryBuffer provides the text content in a GtkEntry.
|
||||
* Applications can provide their own buffer implementation,
|
||||
* e.g. to provide secure handling for passwords in memory.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
GtkWidget *
|
||||
do_entry_buffer (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkEntryBuffer *buffer;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Entry Buffer");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
g_object_set (vbox, "margin", 5, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"Entries share a buffer. Typing in one is reflected in the other.");
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
/* Create a buffer */
|
||||
buffer = gtk_entry_buffer_new (NULL, 0);
|
||||
|
||||
/* Create our first entry */
|
||||
entry = gtk_entry_new_with_buffer (buffer);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), entry);
|
||||
|
||||
/* Create the second entry */
|
||||
entry = gtk_entry_new_with_buffer (buffer);
|
||||
gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), entry);
|
||||
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
@@ -9,7 +9,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* Creates a tree model containing the completions */
|
||||
static GtkTreeModel *
|
||||
GtkTreeModel *
|
||||
create_completion_model (void)
|
||||
{
|
||||
GtkListStore *store;
|
||||
@@ -45,7 +45,7 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Entry Completion");
|
||||
@@ -55,10 +55,7 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
g_object_set (vbox, "margin", 5, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
|
@@ -1,55 +0,0 @@
|
||||
/* Entry/Entry Undo
|
||||
*
|
||||
* GtkEntry can provide basic Undo/Redo support using standard keyboard
|
||||
* accelerators such as Primary+z to undo and Primary+Shift+z to redo.
|
||||
* Additionally, Primary+y can be used to redo.
|
||||
*
|
||||
* Use gtk_entry_set_enable_undo() to enable undo/redo support.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
GtkWidget *
|
||||
do_entry_undo (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Entry Undo");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"Use Primary+z or Primary+Shift+z to undo or redo changes");
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
/* Create our entry */
|
||||
entry = gtk_entry_new ();
|
||||
gtk_editable_set_enable_undo (GTK_EDITABLE (entry), TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), entry);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
@@ -52,14 +52,14 @@ do_expander (GtkWidget *do_widget)
|
||||
area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (window));
|
||||
|
||||
label = gtk_widget_get_last_child (area);
|
||||
gtk_label_set_wrap (GTK_LABEL (label), FALSE);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), FALSE);
|
||||
gtk_widget_set_vexpand (label, FALSE);
|
||||
|
||||
expander = gtk_expander_new ("Details:");
|
||||
gtk_widget_set_vexpand (expander, TRUE);
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 100);
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
@@ -122,6 +122,7 @@ do_filtermodel (GtkWidget *do_widget)
|
||||
GtkBuilder *builder;
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/filtermodel/filtermodel.ui");
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
|
@@ -31,10 +31,7 @@
|
||||
<property name="title" translatable="yes">Filter Model</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="column-homogeneous">1</property>
|
||||
@@ -56,6 +53,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview1">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="model">liststore1</property>
|
||||
<property name="headers-clickable">0</property>
|
||||
<child internal-child="selection">
|
||||
@@ -94,6 +92,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview2">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="headers-clickable">0</property>
|
||||
<property name="search-column">0</property>
|
||||
<child internal-child="selection">
|
||||
@@ -176,6 +175,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview3">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="headers-clickable">0</property>
|
||||
<property name="search-column">0</property>
|
||||
<child internal-child="selection">
|
||||
|
@@ -22,11 +22,29 @@ gsize n_icon_names = 0;
|
||||
static void
|
||||
init_icon_names (GtkIconTheme *theme)
|
||||
{
|
||||
GPtrArray *icons;
|
||||
GList *l, *icon_list;
|
||||
|
||||
if (icon_names)
|
||||
return;
|
||||
|
||||
icon_names = gtk_icon_theme_get_icon_names (theme);
|
||||
n_icon_names = g_strv_length (icon_names);
|
||||
icon_list = gtk_icon_theme_list_icons (theme, NULL);
|
||||
icons = g_ptr_array_new ();
|
||||
|
||||
for (l = icon_list; l; l = l->next)
|
||||
{
|
||||
if (g_str_has_suffix (l->data, "symbolic"))
|
||||
continue;
|
||||
|
||||
g_ptr_array_add (icons, g_strdup (l->data));
|
||||
}
|
||||
|
||||
n_icon_names = icons->len;
|
||||
g_ptr_array_add (icons, NULL); /* NULL-terminate the array */
|
||||
icon_names = (char **) g_ptr_array_free (icons, FALSE);
|
||||
|
||||
/* don't free strings, we assigned them to the array */
|
||||
g_list_free_full (icon_list, g_free);
|
||||
}
|
||||
|
||||
static const char *
|
||||
@@ -37,16 +55,13 @@ get_random_icon_name (GtkIconTheme *theme)
|
||||
return icon_names[g_random_int_range(0, n_icon_names)];
|
||||
}
|
||||
|
||||
/* Can't be static because it's also used in iconscroll.c */
|
||||
GtkWidget *
|
||||
create_icon (void)
|
||||
{
|
||||
GtkWidget *image;
|
||||
|
||||
image = gtk_image_new ();
|
||||
image = gtk_image_new_from_icon_name (get_random_icon_name (gtk_icon_theme_get_default ()));
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (image),
|
||||
get_random_icon_name (gtk_icon_theme_get_for_display (gtk_widget_get_display (image))));
|
||||
|
||||
return image;
|
||||
}
|
||||
@@ -62,7 +77,7 @@ create_blurred_button (void)
|
||||
{
|
||||
GtkWidget *w = gtk_button_new ();
|
||||
|
||||
gtk_widget_add_css_class (w, "blurred-button");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (w), "blurred-button");
|
||||
|
||||
return w;
|
||||
}
|
||||
@@ -109,7 +124,7 @@ create_label (void)
|
||||
{
|
||||
GtkWidget *w = gtk_label_new ("pLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.");
|
||||
|
||||
gtk_label_set_wrap (GTK_LABEL (w), TRUE);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
|
||||
gtk_label_set_max_width_chars (GTK_LABEL (w), 100);
|
||||
|
||||
return w;
|
||||
@@ -159,7 +174,7 @@ static GtkWidget *
|
||||
create_menu_button (void)
|
||||
{
|
||||
GtkWidget *w = gtk_menu_button_new ();
|
||||
GtkWidget *popover = gtk_popover_new ();
|
||||
GtkWidget *popover = gtk_popover_new (NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (popover), gtk_button_new_with_label ("Hey!"));
|
||||
gtk_popover_set_autohide (GTK_POPOVER (popover), FALSE);
|
||||
@@ -211,8 +226,8 @@ set_widget_type (GtkFishbowl *fishbowl,
|
||||
}
|
||||
|
||||
void
|
||||
fishbowl_next_button_clicked_cb (GtkButton *source,
|
||||
gpointer user_data)
|
||||
next_button_clicked_cb (GtkButton *source,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFishbowl *fishbowl = user_data;
|
||||
int new_index;
|
||||
@@ -226,8 +241,8 @@ fishbowl_next_button_clicked_cb (GtkButton *source,
|
||||
}
|
||||
|
||||
void
|
||||
fishbowl_prev_button_clicked_cb (GtkButton *source,
|
||||
gpointer user_data)
|
||||
prev_button_clicked_cb (GtkButton *source,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFishbowl *fishbowl = user_data;
|
||||
int new_index;
|
||||
@@ -241,8 +256,8 @@ fishbowl_prev_button_clicked_cb (GtkButton *source,
|
||||
}
|
||||
|
||||
void
|
||||
fishbowl_changes_toggled_cb (GtkToggleButton *button,
|
||||
gpointer user_data)
|
||||
changes_toggled_cb (GtkToggleButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (gtk_toggle_button_get_active (button))
|
||||
gtk_button_set_icon_name (GTK_BUTTON (button), "changes-prevent");
|
||||
@@ -273,6 +288,12 @@ do_fishbowl (GtkWidget *do_widget)
|
||||
g_type_ensure (GTK_TYPE_FISHBOWL);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/fishbowl/fishbowl.ui");
|
||||
gtk_builder_add_callback_symbols (builder,
|
||||
"next_button_clicked_cb", G_CALLBACK (next_button_clicked_cb),
|
||||
"prev_button_clicked_cb", G_CALLBACK (prev_button_clicked_cb),
|
||||
"changes_toggled_cb", G_CALLBACK (changes_toggled_cb),
|
||||
NULL);
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
@@ -15,13 +15,13 @@
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">pan-start-symbolic</property>
|
||||
<signal name="clicked" handler="fishbowl_prev_button_clicked_cb" object="bowl" swapped="no"/>
|
||||
<signal name="clicked" handler="prev_button_clicked_cb" object="bowl" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">pan-end-symbolic</property>
|
||||
<signal name="clicked" handler="fishbowl_next_button_clicked_cb" object="bowl" swapped="no"/>
|
||||
<signal name="clicked" handler="next_button_clicked_cb" object="bowl" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -49,8 +49,8 @@
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="changes_allow">
|
||||
<property name="icon-name">changes-allow</property>
|
||||
<property name="has-frame">0</property>
|
||||
<signal name="notify::active" handler="fishbowl_changes_toggled_cb"/>
|
||||
<property name="relief">none</property>
|
||||
<signal name="notify::active" handler="changes_toggled_cb"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@@ -52,7 +52,7 @@ create_faces (void)
|
||||
/* Add a face */
|
||||
faces[i].face = gtk_frame_new (NULL);
|
||||
gtk_widget_set_size_request (faces[i].face, face_size, face_size);
|
||||
gtk_widget_add_css_class (faces[i].face, faces[i].css_class);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (faces[i].face), faces[i].css_class);
|
||||
gtk_container_add (GTK_CONTAINER (fixed), faces[i].face);
|
||||
|
||||
/* Set up the transformation for each face */
|
||||
@@ -124,7 +124,7 @@ create_demo_window (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window, *sw, *fixed, *cube;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Fixed layout");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
|
@@ -719,7 +719,7 @@ do_flowbox (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Flow Box");
|
||||
|
@@ -10,9 +10,10 @@
|
||||
<property name="title">Font Explorer</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="tooltip-text">Reset</property>
|
||||
<signal name="clicked" handler="font_features_reset_features" swapped="no"/>
|
||||
<signal name="clicked" handler="reset" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="icon-name">view-refresh-symbolic</property>
|
||||
@@ -26,23 +27,22 @@
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkFontButton" id="font">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="font">Sans 12</property>
|
||||
<property name="level">family|style|size|variations|features</property>
|
||||
<signal name="font-set" handler="font_features_font_changed" swapped="no"/>
|
||||
<signal name="font-set" handler="font_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -61,8 +61,9 @@
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="script_lang">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="margin-top">10</property>
|
||||
<signal name="changed" handler="font_features_script_changed" swapped="no"/>
|
||||
<signal name="changed" handler="script_changed" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
@@ -108,10 +109,7 @@
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="margin-start">20</property>
|
||||
<property name="margin-end">20</property>
|
||||
<property name="margin-top">20</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<property name="margin">20</property>
|
||||
<property name="spacing">20</property>
|
||||
<child>
|
||||
<object class="GtkStack" id="stack">
|
||||
@@ -139,7 +137,7 @@
|
||||
Разъяренный чтец эгоистично бьёт пятью жердями шустрого фехтовальщика. Наш банк вчера же выплатил Ф.Я. Эйхгольду комиссию за ценные вещи. Эх, чужак, общий съём цен шляп (юфть) – вдрызг! В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!
|
||||
|
||||
Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός</property>
|
||||
<signal name="activate" handler="font_features_stop_edit"/>
|
||||
<signal name="activate" handler="stop_edit"/>
|
||||
<property name="valign">start</property>
|
||||
<property name="width-chars">50</property>
|
||||
</object>
|
||||
@@ -183,7 +181,7 @@
|
||||
<property name="icon-name">document-edit-symbolic</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">end</property>
|
||||
<signal name="toggled" handler="font_features_toggle_edit"/>
|
||||
<signal name="toggled" handler="toggle_edit"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "fontplane.h"
|
||||
|
||||
#include "gtk.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_WEIGHT_ADJUSTMENT,
|
||||
@@ -140,6 +142,17 @@ update_value (GtkFontPlane *plane,
|
||||
gtk_widget_queue_draw (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
hold_action (GtkGestureLongPress *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkFontPlane *plane)
|
||||
{
|
||||
gboolean handled;
|
||||
|
||||
g_signal_emit_by_name (plane, "popup-menu", &handled);
|
||||
}
|
||||
|
||||
static void
|
||||
plane_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
gdouble start_x,
|
||||
@@ -150,6 +163,13 @@ plane_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
|
||||
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
|
||||
|
||||
if (button == GDK_BUTTON_SECONDARY)
|
||||
{
|
||||
gboolean handled;
|
||||
|
||||
g_signal_emit_by_name (plane, "popup-menu", &handled);
|
||||
}
|
||||
|
||||
if (button != GDK_BUTTON_PRIMARY)
|
||||
{
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
||||
@@ -189,6 +209,8 @@ gtk_font_plane_init (GtkFontPlane *plane)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE);
|
||||
|
||||
gesture = gtk_gesture_drag_new ();
|
||||
g_signal_connect (gesture, "drag-begin",
|
||||
G_CALLBACK (plane_drag_gesture_begin), plane);
|
||||
@@ -198,6 +220,13 @@ gtk_font_plane_init (GtkFontPlane *plane)
|
||||
G_CALLBACK (plane_drag_gesture_end), plane);
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
|
||||
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
gesture = gtk_gesture_long_press_new ();
|
||||
g_signal_connect (gesture, "pressed",
|
||||
G_CALLBACK (hold_action), plane);
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture),
|
||||
TRUE);
|
||||
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -43,6 +43,7 @@ update_image (void)
|
||||
cairo_font_options_t *fopt;
|
||||
cairo_hint_style_t hintstyle;
|
||||
cairo_hint_metrics_t hintmetrics;
|
||||
int i;
|
||||
|
||||
if (!context)
|
||||
context = gtk_widget_create_pango_context (image);
|
||||
@@ -115,7 +116,6 @@ update_image (void)
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_grid)))
|
||||
{
|
||||
int i;
|
||||
cairo_set_source_rgba (cr, 0.2, 0, 0, 0.2);
|
||||
for (i = 1; i < ink.height + 20; i++)
|
||||
{
|
||||
@@ -248,6 +248,7 @@ do_fontrendering (GtkWidget *do_widget)
|
||||
GtkBuilder *builder;
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/fontrendering/fontrendering.ui");
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
|
@@ -165,11 +165,10 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
<style><class name="linked"/></style>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="text_radio">
|
||||
<property name="draw-indicator">0</property>
|
||||
@@ -184,7 +183,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<layout>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
<property name="column-span">7</property>
|
||||
</layout>
|
||||
@@ -193,7 +192,7 @@
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="propagate-natural-height">1</property>
|
||||
<property name="has-frame">1</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
|
989
demos/gtk-demo/foreigndrawing.c
Normal file
989
demos/gtk-demo/foreigndrawing.c
Normal file
@@ -0,0 +1,989 @@
|
||||
/* Foreign drawing
|
||||
*
|
||||
* Many applications can't use GTK widgets, for a variety of reasons,
|
||||
* but still want their user interface to appear integrated with the
|
||||
* rest of the desktop, and follow GTK themes. This demo shows how to
|
||||
* use GtkStyleContext and the gtk_render_ APIs to achieve this.
|
||||
*
|
||||
* Note that this is a very simple, non-interactive example.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
|
||||
static void
|
||||
append_element (GtkWidgetPath *path,
|
||||
const char *selector)
|
||||
{
|
||||
static const struct {
|
||||
const char *name;
|
||||
GtkStateFlags state_flag;
|
||||
} pseudo_classes[] = {
|
||||
{ "active", GTK_STATE_FLAG_ACTIVE },
|
||||
{ "hover", GTK_STATE_FLAG_PRELIGHT },
|
||||
{ "selected", GTK_STATE_FLAG_SELECTED },
|
||||
{ "disabled", GTK_STATE_FLAG_INSENSITIVE },
|
||||
{ "indeterminate", GTK_STATE_FLAG_INCONSISTENT },
|
||||
{ "focus", GTK_STATE_FLAG_FOCUSED },
|
||||
{ "backdrop", GTK_STATE_FLAG_BACKDROP },
|
||||
{ "dir(ltr)", GTK_STATE_FLAG_DIR_LTR },
|
||||
{ "dir(rtl)", GTK_STATE_FLAG_DIR_RTL },
|
||||
{ "link", GTK_STATE_FLAG_LINK },
|
||||
{ "visited", GTK_STATE_FLAG_VISITED },
|
||||
{ "checked", GTK_STATE_FLAG_CHECKED },
|
||||
{ "drop(active)", GTK_STATE_FLAG_DROP_ACTIVE }
|
||||
};
|
||||
const char *next;
|
||||
char *name;
|
||||
char type;
|
||||
guint i;
|
||||
|
||||
next = strpbrk (selector, "#.:");
|
||||
if (next == NULL)
|
||||
next = selector + strlen (selector);
|
||||
|
||||
name = g_strndup (selector, next - selector);
|
||||
if (g_ascii_isupper (selector[0]))
|
||||
{
|
||||
GType gtype;
|
||||
gtype = g_type_from_name (name);
|
||||
if (gtype == G_TYPE_INVALID)
|
||||
{
|
||||
g_critical ("Unknown type name `%s'", name);
|
||||
g_free (name);
|
||||
return;
|
||||
}
|
||||
gtk_widget_path_append_type (path, gtype);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Omit type, we're using name */
|
||||
gtk_widget_path_append_type (path, G_TYPE_NONE);
|
||||
gtk_widget_path_iter_set_object_name (path, -1, name);
|
||||
}
|
||||
g_free (name);
|
||||
|
||||
while (*next != '\0')
|
||||
{
|
||||
type = *next;
|
||||
selector = next + 1;
|
||||
next = strpbrk (selector, "#.:");
|
||||
if (next == NULL)
|
||||
next = selector + strlen (selector);
|
||||
name = g_strndup (selector, next - selector);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case '#':
|
||||
gtk_widget_path_iter_set_name (path, -1, name);
|
||||
break;
|
||||
|
||||
case '.':
|
||||
gtk_widget_path_iter_add_class (path, -1, name);
|
||||
break;
|
||||
|
||||
case ':':
|
||||
for (i = 0; i < G_N_ELEMENTS (pseudo_classes); i++)
|
||||
{
|
||||
if (g_str_equal (pseudo_classes[i].name, name))
|
||||
{
|
||||
gtk_widget_path_iter_set_state (path,
|
||||
-1,
|
||||
gtk_widget_path_iter_get_state (path, -1)
|
||||
| pseudo_classes[i].state_flag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == G_N_ELEMENTS (pseudo_classes))
|
||||
g_critical ("Unknown pseudo-class :%s", name);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
static GtkStyleContext *
|
||||
create_context_for_path (GtkWidgetPath *path,
|
||||
GtkStyleContext *parent)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
context = gtk_style_context_new ();
|
||||
gtk_style_context_set_path (context, path);
|
||||
gtk_style_context_set_parent (context, parent);
|
||||
/* Unfortunately, we have to explicitly set the state again here
|
||||
* for it to take effect
|
||||
*/
|
||||
gtk_style_context_set_state (context, gtk_widget_path_iter_get_state (path, -1));
|
||||
gtk_widget_path_unref (path);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static GtkStyleContext *
|
||||
get_style (GtkStyleContext *parent,
|
||||
const char *selector)
|
||||
{
|
||||
GtkWidgetPath *path;
|
||||
|
||||
if (parent)
|
||||
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
|
||||
else
|
||||
path = gtk_widget_path_new ();
|
||||
|
||||
append_element (path, selector);
|
||||
|
||||
return create_context_for_path (path, parent);
|
||||
}
|
||||
|
||||
static GtkStyleContext *
|
||||
get_style_with_siblings (GtkStyleContext *parent,
|
||||
const char *selector,
|
||||
const char **siblings,
|
||||
gint position)
|
||||
{
|
||||
GtkWidgetPath *path, *siblings_path;
|
||||
guint i;
|
||||
|
||||
if (parent)
|
||||
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
|
||||
else
|
||||
path = gtk_widget_path_new ();
|
||||
|
||||
siblings_path = gtk_widget_path_new ();
|
||||
for (i = 0; siblings[i]; i++)
|
||||
append_element (siblings_path, siblings[i]);
|
||||
|
||||
gtk_widget_path_append_with_siblings (path, siblings_path, position);
|
||||
gtk_widget_path_unref (siblings_path);
|
||||
|
||||
return create_context_for_path (path, parent);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_style_common (GtkStyleContext *context,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *contents_x,
|
||||
gint *contents_y,
|
||||
gint *contents_width,
|
||||
gint *contents_height)
|
||||
{
|
||||
GtkBorder margin, border, padding;
|
||||
int min_width, min_height;
|
||||
|
||||
gtk_style_context_get_margin (context, &margin);
|
||||
gtk_style_context_get_border (context, &border);
|
||||
gtk_style_context_get_padding (context, &padding);
|
||||
|
||||
gtk_style_context_get (context,
|
||||
"min-width", &min_width,
|
||||
"min-height", &min_height,
|
||||
NULL);
|
||||
x += margin.left;
|
||||
y += margin.top;
|
||||
width -= margin.left + margin.right;
|
||||
height -= margin.top + margin.bottom;
|
||||
|
||||
width = MAX (width, min_width);
|
||||
height = MAX (height, min_height);
|
||||
|
||||
gtk_render_background (context, cr, x, y, width, height);
|
||||
gtk_render_frame (context, cr, x, y, width, height);
|
||||
|
||||
if (contents_x)
|
||||
*contents_x = x + border.left + padding.left;
|
||||
if (contents_y)
|
||||
*contents_y = y + border.top + padding.top;
|
||||
if (contents_width)
|
||||
*contents_width = width - border.left - border.right - padding.left - padding.right;
|
||||
if (contents_height)
|
||||
*contents_height = height - border.top - border.bottom - padding.top - padding.bottom;
|
||||
}
|
||||
|
||||
static void
|
||||
query_size (GtkStyleContext *context,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkBorder margin, border, padding;
|
||||
int min_width, min_height;
|
||||
|
||||
gtk_style_context_get_margin (context, &margin);
|
||||
gtk_style_context_get_border (context, &border);
|
||||
gtk_style_context_get_padding (context, &padding);
|
||||
|
||||
gtk_style_context_get (context,
|
||||
"min-width", &min_width,
|
||||
"min-height", &min_height,
|
||||
NULL);
|
||||
|
||||
min_width += margin.left + margin.right + border.left + border.right + padding.left + padding.right;
|
||||
min_height += margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
|
||||
|
||||
if (width)
|
||||
*width = MAX (*width, min_width);
|
||||
if (height)
|
||||
*height = MAX (*height, min_height);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_menu (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *menu_context;
|
||||
GtkStyleContext *menuitem_context;
|
||||
GtkStyleContext *hovermenuitem_context;
|
||||
GtkStyleContext *hoveredarrowmenuitem_context;
|
||||
GtkStyleContext *arrowmenuitem_context;
|
||||
GtkStyleContext *checkmenuitem_context;
|
||||
GtkStyleContext *disabledarrowmenuitem_context;
|
||||
GtkStyleContext *disabledcheckmenuitem_context;
|
||||
GtkStyleContext *radiomenuitem_context;
|
||||
GtkStyleContext *disablemenuitem_context;
|
||||
GtkStyleContext *disabledradiomenuitem_context;
|
||||
GtkStyleContext *separatormenuitem_context;
|
||||
gint menuitem1_height, menuitem2_height, menuitem3_height, menuitem4_height, menuitem5_height;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
gint menu_x, menu_y, menu_width, menu_height;
|
||||
gint arrow_width, arrow_height, arrow_size;
|
||||
gint toggle_x, toggle_y, toggle_width, toggle_height;
|
||||
|
||||
/* This information is taken from the GtkMenu docs, see "CSS nodes" */
|
||||
menu_context = get_style (gtk_widget_get_style_context(widget), "menu");
|
||||
hovermenuitem_context = get_style (menu_context, "menuitem:hover");
|
||||
hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
|
||||
menuitem_context = get_style (menu_context, "menuitem");
|
||||
arrowmenuitem_context = get_style (menuitem_context, "arrow:dir(rtl)");
|
||||
disablemenuitem_context = get_style (menu_context, "menuitem:disabled");
|
||||
disabledarrowmenuitem_context = get_style (disablemenuitem_context, "arrow:dir(rtl)");
|
||||
checkmenuitem_context = get_style (menuitem_context, "check:checked");
|
||||
disabledcheckmenuitem_context = get_style (disablemenuitem_context, "check");
|
||||
separatormenuitem_context = get_style (menu_context, "separator:disabled");
|
||||
radiomenuitem_context = get_style (menuitem_context, "radio:checked");
|
||||
disabledradiomenuitem_context = get_style (disablemenuitem_context, "radio");
|
||||
|
||||
*height = 0;
|
||||
query_size (menu_context, NULL, height);
|
||||
menuitem1_height = 0;
|
||||
query_size (hovermenuitem_context, NULL, &menuitem1_height);
|
||||
query_size (hoveredarrowmenuitem_context, NULL, &menuitem1_height);
|
||||
*height += menuitem1_height;
|
||||
menuitem2_height = 0;
|
||||
query_size (menu_context, NULL, &menuitem5_height);
|
||||
query_size (menuitem_context, NULL, &menuitem2_height);
|
||||
query_size (arrowmenuitem_context, NULL, &menuitem2_height);
|
||||
query_size (disabledarrowmenuitem_context, NULL, &menuitem2_height);
|
||||
*height += menuitem2_height;
|
||||
menuitem3_height = 0;
|
||||
query_size (menu_context, NULL, &menuitem5_height);
|
||||
query_size (menuitem_context, NULL, &menuitem3_height);
|
||||
query_size (checkmenuitem_context, NULL, &menuitem3_height);
|
||||
query_size (disabledcheckmenuitem_context, NULL, &menuitem3_height);
|
||||
*height += menuitem3_height;
|
||||
menuitem4_height = 0;
|
||||
query_size (menu_context, NULL, &menuitem5_height);
|
||||
query_size (separatormenuitem_context, NULL, &menuitem4_height);
|
||||
*height += menuitem4_height;
|
||||
menuitem5_height = 0;
|
||||
query_size (menu_context, NULL, &menuitem5_height);
|
||||
query_size (menuitem_context, NULL, &menuitem5_height);
|
||||
query_size (radiomenuitem_context, NULL, &menuitem5_height);
|
||||
query_size (disabledradiomenuitem_context, NULL, &menuitem5_height);
|
||||
*height += menuitem5_height;
|
||||
|
||||
draw_style_common (menu_context, cr, x, y, width, *height,
|
||||
&menu_x, &menu_y, &menu_width, &menu_height);
|
||||
|
||||
/* Hovered with right arrow */
|
||||
gtk_style_context_get (hoveredarrowmenuitem_context,
|
||||
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
|
||||
arrow_size = MIN (arrow_width, arrow_height);
|
||||
draw_style_common (hovermenuitem_context, cr, menu_x, menu_y, menu_width, menuitem1_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_arrow (hoveredarrowmenuitem_context, cr, G_PI / 2,
|
||||
contents_x + contents_width - arrow_size,
|
||||
contents_y + (contents_height - arrow_size) / 2, arrow_size);
|
||||
|
||||
/* Left arrow sensitive, and right arrow insensitive */
|
||||
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height, menu_width, menuitem2_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_style_context_get (arrowmenuitem_context,
|
||||
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
|
||||
arrow_size = MIN (arrow_width, arrow_height);
|
||||
gtk_render_arrow (arrowmenuitem_context, cr, G_PI / 2,
|
||||
contents_x,
|
||||
contents_y + (contents_height - arrow_size) / 2, arrow_size);
|
||||
gtk_style_context_get (disabledarrowmenuitem_context,
|
||||
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
|
||||
arrow_size = MIN (arrow_width, arrow_height);
|
||||
gtk_render_arrow (disabledarrowmenuitem_context, cr, G_PI / 2,
|
||||
contents_x + contents_width - arrow_size,
|
||||
contents_y + (contents_height - arrow_size) / 2, arrow_size);
|
||||
|
||||
|
||||
/* Left check enabled, sensitive, and right check unchecked, insensitive */
|
||||
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height, menu_width, menuitem3_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_style_context_get (checkmenuitem_context,
|
||||
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
|
||||
draw_style_common (checkmenuitem_context, cr,
|
||||
contents_x,
|
||||
contents_y,
|
||||
toggle_width, toggle_height,
|
||||
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
|
||||
gtk_render_check (checkmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
|
||||
gtk_style_context_get (disabledcheckmenuitem_context,
|
||||
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
|
||||
draw_style_common (disabledcheckmenuitem_context, cr,
|
||||
contents_x + contents_width - toggle_width,
|
||||
contents_y,
|
||||
toggle_width, toggle_height,
|
||||
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
|
||||
gtk_render_check (disabledcheckmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
|
||||
|
||||
/* Separator */
|
||||
draw_style_common (separatormenuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height,
|
||||
menu_width, menuitem4_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
/* Left check enabled, sensitive, and right check unchecked, insensitive */
|
||||
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height + menuitem4_height,
|
||||
menu_width, menuitem5_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_style_context_get (radiomenuitem_context,
|
||||
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
|
||||
draw_style_common (radiomenuitem_context, cr,
|
||||
contents_x,
|
||||
contents_y,
|
||||
toggle_width, toggle_height,
|
||||
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
|
||||
gtk_render_check (radiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
|
||||
gtk_style_context_get (disabledradiomenuitem_context,
|
||||
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
|
||||
draw_style_common (disabledradiomenuitem_context, cr,
|
||||
contents_x + contents_width - toggle_width,
|
||||
contents_y,
|
||||
toggle_width, toggle_height,
|
||||
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
|
||||
gtk_render_check (disabledradiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
|
||||
|
||||
g_object_unref (menu_context);
|
||||
g_object_unref (menuitem_context);
|
||||
g_object_unref (hovermenuitem_context);
|
||||
g_object_unref (hoveredarrowmenuitem_context);
|
||||
g_object_unref (arrowmenuitem_context);
|
||||
g_object_unref (checkmenuitem_context);
|
||||
g_object_unref (disabledarrowmenuitem_context);
|
||||
g_object_unref (disabledcheckmenuitem_context);
|
||||
g_object_unref (radiomenuitem_context);
|
||||
g_object_unref (disablemenuitem_context);
|
||||
g_object_unref (disabledradiomenuitem_context);
|
||||
g_object_unref (separatormenuitem_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_menubar (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *frame_context;
|
||||
GtkStyleContext *border_context;
|
||||
GtkStyleContext *menubar_context;
|
||||
GtkStyleContext *hovered_menuitem_context;
|
||||
GtkStyleContext *menuitem_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
gint item_width;
|
||||
|
||||
/* Menubar background is the same color as our base background, so use a frame */
|
||||
frame_context = get_style (NULL, "frame");
|
||||
border_context = get_style (frame_context, "border");
|
||||
|
||||
/* This information is taken from the GtkMenuBar docs, see "CSS nodes" */
|
||||
menubar_context = get_style (NULL, "menubar");
|
||||
hovered_menuitem_context = get_style (menubar_context, "menuitem:hover");
|
||||
menuitem_context = get_style (menubar_context, "menuitem");
|
||||
|
||||
*height = 0;
|
||||
query_size (frame_context, NULL, height);
|
||||
query_size (border_context, NULL, height);
|
||||
query_size (menubar_context, NULL, height);
|
||||
query_size (hovered_menuitem_context, NULL, height);
|
||||
query_size (menuitem_context, NULL, height);
|
||||
|
||||
draw_style_common (frame_context, cr, x, y, width, *height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (border_context, cr, x, y, width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
draw_style_common (menubar_context, cr, contents_x, contents_y, contents_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
item_width = contents_width / 3;
|
||||
draw_style_common (hovered_menuitem_context, cr, contents_x, contents_y, item_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (menuitem_context, cr, contents_x + item_width * 2, contents_y, item_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (menuitem_context);
|
||||
g_object_unref (hovered_menuitem_context);
|
||||
g_object_unref (menubar_context);
|
||||
g_object_unref (border_context);
|
||||
g_object_unref (frame_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_notebook (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GtkStyleContext *notebook_context;
|
||||
GtkStyleContext *header_context;
|
||||
GtkStyleContext *tabs_context;
|
||||
GtkStyleContext *tab1_context, *tab2_context;
|
||||
GtkStyleContext *stack_context;
|
||||
gint header_height;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
|
||||
/* This information is taken from the GtkNotebook docs, see "CSS nodes" */
|
||||
notebook_context = get_style (NULL, "notebook.frame");
|
||||
header_context = get_style (notebook_context, "header.top");
|
||||
tabs_context = get_style (header_context, "tabs");
|
||||
tab1_context = get_style (tabs_context, "tab:checked");
|
||||
tab2_context = get_style (tabs_context, "tab:hover");
|
||||
stack_context = get_style (notebook_context, "stack");
|
||||
|
||||
header_height = 0;
|
||||
query_size (notebook_context, NULL, &header_height);
|
||||
query_size (header_context, NULL, &header_height);
|
||||
query_size (tabs_context, NULL, &header_height);
|
||||
query_size (tab1_context, NULL, &header_height);
|
||||
query_size (tab2_context, NULL, &header_height);
|
||||
|
||||
draw_style_common (notebook_context, cr, x, y, width, height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (header_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (tabs_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (tab1_context, cr, x, y, width / 2, header_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
draw_style_common (tab2_context, cr, x + width / 2, y, width / 2, header_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (stack_context, cr, x, y + header_height, width,height - header_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (stack_context);
|
||||
g_object_unref (tabs_context);
|
||||
g_object_unref (tab1_context);
|
||||
g_object_unref (tab2_context);
|
||||
g_object_unref (header_context);
|
||||
g_object_unref (notebook_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_horizontal_scrollbar (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint position,
|
||||
GtkStateFlags state,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *scrollbar_context;
|
||||
GtkStyleContext *contents_context;
|
||||
GtkStyleContext *trough_context;
|
||||
GtkStyleContext *slider_context;
|
||||
gint slider_width;
|
||||
|
||||
/* This information is taken from the GtkScrollbar docs, see "CSS nodes" */
|
||||
scrollbar_context = get_style (NULL, "scrollbar.horizontal.bottom");
|
||||
contents_context = get_style (scrollbar_context, "contents");
|
||||
trough_context = get_style (contents_context, "trough");
|
||||
slider_context = get_style (trough_context, "slider");
|
||||
|
||||
gtk_style_context_set_state (scrollbar_context, state);
|
||||
gtk_style_context_set_state (contents_context, state);
|
||||
gtk_style_context_set_state (trough_context, state);
|
||||
gtk_style_context_set_state (slider_context, state);
|
||||
|
||||
*height = 0;
|
||||
query_size (scrollbar_context, NULL, height);
|
||||
query_size (contents_context, NULL, height);
|
||||
query_size (trough_context, NULL, height);
|
||||
query_size (slider_context, NULL, height);
|
||||
|
||||
gtk_style_context_get (slider_context,
|
||||
"min-width", &slider_width, NULL);
|
||||
|
||||
draw_style_common (scrollbar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (contents_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (slider_context, cr, x + position, y, slider_width, *height, NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (slider_context);
|
||||
g_object_unref (trough_context);
|
||||
g_object_unref (contents_context);
|
||||
g_object_unref (scrollbar_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_text (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
const gchar *text,
|
||||
GtkStateFlags state)
|
||||
{
|
||||
GtkStyleContext *label_context;
|
||||
GtkStyleContext *selection_context;
|
||||
GtkStyleContext *context;
|
||||
PangoLayout *layout;
|
||||
|
||||
/* This information is taken from the GtkLabel docs, see "CSS nodes" */
|
||||
label_context = get_style (NULL, "label.view");
|
||||
selection_context = get_style (label_context, "selection");
|
||||
|
||||
gtk_style_context_set_state (label_context, state);
|
||||
|
||||
if (state & GTK_STATE_FLAG_SELECTED)
|
||||
context = selection_context;
|
||||
else
|
||||
context = label_context;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, text);
|
||||
|
||||
gtk_render_background (context, cr, x, y, width, height);
|
||||
gtk_render_frame (context, cr, x, y, width, height);
|
||||
gtk_render_layout (context, cr, x, y, layout);
|
||||
|
||||
g_object_unref (layout);
|
||||
|
||||
g_object_unref (selection_context);
|
||||
g_object_unref (label_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_check (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkStateFlags state,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *button_context;
|
||||
GtkStyleContext *check_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
|
||||
/* This information is taken from the GtkCheckButton docs, see "CSS nodes" */
|
||||
button_context = get_style (NULL, "checkbutton");
|
||||
check_context = get_style (button_context, "check");
|
||||
|
||||
gtk_style_context_set_state (check_context, state);
|
||||
|
||||
*width = *height = 0;
|
||||
query_size (button_context, width, height);
|
||||
query_size (check_context, width, height);
|
||||
|
||||
draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (check_context, cr, x, y, *width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
|
||||
|
||||
g_object_unref (check_context);
|
||||
g_object_unref (button_context);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
draw_radio (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkStateFlags state,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *button_context;
|
||||
GtkStyleContext *check_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
|
||||
/* This information is taken from the GtkRadioButton docs, see "CSS nodes" */
|
||||
button_context = get_style (NULL, "radiobutton");
|
||||
check_context = get_style (button_context, "radio");
|
||||
|
||||
gtk_style_context_set_state (check_context, state);
|
||||
|
||||
*width = *height = 0;
|
||||
query_size (button_context, width, height);
|
||||
query_size (check_context, width, height);
|
||||
|
||||
draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (check_context, cr, x, y, *width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
|
||||
|
||||
g_object_unref (check_context);
|
||||
g_object_unref (button_context);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
draw_progress (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint position,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *bar_context;
|
||||
GtkStyleContext *trough_context;
|
||||
GtkStyleContext *progress_context;
|
||||
|
||||
/* This information is taken from the GtkProgressBar docs, see "CSS nodes" */
|
||||
bar_context = get_style (NULL, "progressbar.horizontal");
|
||||
trough_context = get_style (bar_context, "trough");
|
||||
progress_context = get_style (trough_context, "progress.left");
|
||||
|
||||
*height = 0;
|
||||
query_size (bar_context, NULL, height);
|
||||
query_size (trough_context, NULL, height);
|
||||
query_size (progress_context, NULL, height);
|
||||
|
||||
draw_style_common (bar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (progress_context, cr, x, y, position, *height, NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (progress_context);
|
||||
g_object_unref (trough_context);
|
||||
g_object_unref (bar_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_scale (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint position,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *scale_context;
|
||||
GtkStyleContext *contents_context;
|
||||
GtkStyleContext *trough_context;
|
||||
GtkStyleContext *slider_context;
|
||||
GtkStyleContext *highlight_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
gint trough_height, slider_height;
|
||||
|
||||
scale_context = get_style (NULL, "scale.horizontal");
|
||||
contents_context = get_style (scale_context, "contents");
|
||||
trough_context = get_style (contents_context, "trough");
|
||||
slider_context = get_style (trough_context, "slider");
|
||||
highlight_context = get_style (trough_context, "highlight.top");
|
||||
|
||||
*height = 0;
|
||||
query_size (scale_context, NULL, height);
|
||||
query_size (contents_context, NULL, height);
|
||||
query_size (trough_context, NULL, height);
|
||||
query_size (slider_context, NULL, height);
|
||||
query_size (highlight_context, NULL, height);
|
||||
|
||||
draw_style_common (scale_context, cr, x, y, width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
draw_style_common (contents_context, cr, contents_x, contents_y, contents_width, contents_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
/* Scale trough defines its size querying slider and highlight */
|
||||
trough_height = 0;
|
||||
query_size (trough_context, NULL, &trough_height);
|
||||
slider_height = 0;
|
||||
query_size (slider_context, NULL, &slider_height);
|
||||
query_size (highlight_context, NULL, &slider_height);
|
||||
trough_height += slider_height;
|
||||
draw_style_common (trough_context, cr, contents_x, contents_y, contents_width, trough_height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
draw_style_common (highlight_context, cr, contents_x, contents_y,
|
||||
contents_width / 2, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (slider_context, cr, contents_x + position, contents_y, contents_height, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
g_object_unref (scale_context);
|
||||
g_object_unref (contents_context);
|
||||
g_object_unref (trough_context);
|
||||
g_object_unref (slider_context);
|
||||
g_object_unref (highlight_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_combobox (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gboolean has_entry,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *combo_context;
|
||||
GtkStyleContext *box_context;
|
||||
GtkStyleContext *button_context;
|
||||
GtkStyleContext *button_box_context;
|
||||
GtkStyleContext *entry_context;
|
||||
GtkStyleContext *arrow_context;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
gint button_width;
|
||||
gint arrow_width, arrow_height, arrow_size;
|
||||
|
||||
/* This information is taken from the GtkComboBox docs, see "CSS nodes" */
|
||||
combo_context = get_style (NULL, "combobox:focus");
|
||||
box_context = get_style (combo_context, "box.horizontal.linked");
|
||||
if (has_entry)
|
||||
{
|
||||
const char *siblings[3] = { "entry.combo:focus", "button.combo" , NULL };
|
||||
|
||||
entry_context = get_style_with_siblings (box_context, "entry.combo:focus", siblings, 0);
|
||||
button_context = get_style_with_siblings (box_context, "button.combo", siblings, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *siblings[2] = { "button.combo" , NULL };
|
||||
|
||||
button_context = get_style_with_siblings (box_context, "button.combo", siblings, 0);
|
||||
}
|
||||
button_box_context = get_style (button_context, "box.horizontal");
|
||||
arrow_context = get_style (button_box_context, "arrow");
|
||||
|
||||
*height = 0;
|
||||
query_size (combo_context, NULL, height);
|
||||
query_size (box_context, NULL, height);
|
||||
if (has_entry)
|
||||
query_size (entry_context, NULL, height);
|
||||
query_size (button_context, NULL, height);
|
||||
query_size (button_box_context, NULL, height);
|
||||
query_size (arrow_context, NULL, height);
|
||||
|
||||
gtk_style_context_get (arrow_context,
|
||||
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
|
||||
arrow_size = MIN (arrow_width, arrow_height);
|
||||
|
||||
draw_style_common (combo_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (box_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
if (has_entry)
|
||||
{
|
||||
button_width = *height;
|
||||
draw_style_common (entry_context, cr, x, y, width - button_width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (button_context, cr, x + width - button_width, y, button_width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
button_width = width;
|
||||
draw_style_common (button_context, cr, x, y, width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
}
|
||||
|
||||
draw_style_common (button_box_context, cr, contents_x, contents_y, contents_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
draw_style_common (arrow_context, cr, contents_x, contents_y, contents_width, contents_height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
gtk_render_arrow (arrow_context, cr, G_PI / 2,
|
||||
contents_x + contents_width - arrow_size,
|
||||
contents_y + (contents_height - arrow_size) / 2, arrow_size);
|
||||
|
||||
g_object_unref (arrow_context);
|
||||
if (has_entry)
|
||||
g_object_unref (entry_context);
|
||||
g_object_unref (button_context);
|
||||
g_object_unref (combo_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_spinbutton (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint *height)
|
||||
{
|
||||
GtkStyleContext *spin_context;
|
||||
GtkStyleContext *entry_context;
|
||||
GtkStyleContext *up_context;
|
||||
GtkStyleContext *down_context;
|
||||
GtkIconTheme *icon_theme;
|
||||
GtkIconInfo *icon_info;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
gint icon_width, icon_height, icon_size;
|
||||
gint button_width;
|
||||
gint contents_x, contents_y, contents_width, contents_height;
|
||||
|
||||
/* This information is taken from the GtkSpinButton docs, see "CSS nodes" */
|
||||
spin_context = get_style (NULL, "spinbutton.horizontal:focus");
|
||||
entry_context = get_style (spin_context, "entry:focus");
|
||||
up_context = get_style (spin_context, "button.up:focus:active");
|
||||
down_context = get_style (spin_context, "button.down:focus");
|
||||
|
||||
*height = 0;
|
||||
query_size (spin_context, NULL, height);
|
||||
query_size (entry_context, NULL, height);
|
||||
query_size (up_context, NULL, height);
|
||||
query_size (down_context, NULL, height);
|
||||
button_width = *height;
|
||||
|
||||
draw_style_common (spin_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
draw_style_common (entry_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
|
||||
|
||||
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
|
||||
|
||||
gtk_style_context_get (up_context,
|
||||
"min-width", &icon_width, "min-height", &icon_height, NULL);
|
||||
icon_size = MIN (icon_width, icon_height);
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-add-symbolic", icon_size, 0);
|
||||
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, up_context, NULL, NULL);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (icon_info);
|
||||
draw_style_common (up_context, cr, x + width - button_width, y, button_width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_icon (up_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2);
|
||||
g_object_unref (pixbuf);
|
||||
g_object_unref (texture);
|
||||
|
||||
gtk_style_context_get (down_context,
|
||||
"min-width", &icon_width, "min-height", &icon_height, NULL);
|
||||
icon_size = MIN (icon_width, icon_height);
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-remove-symbolic", icon_size, 0);
|
||||
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, down_context, NULL, NULL);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (icon_info);
|
||||
draw_style_common (down_context, cr, x + width - 2 * button_width, y, button_width, *height,
|
||||
&contents_x, &contents_y, &contents_width, &contents_height);
|
||||
gtk_render_icon (down_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2);
|
||||
g_object_unref (pixbuf);
|
||||
g_object_unref (texture);
|
||||
|
||||
g_object_unref (down_context);
|
||||
g_object_unref (up_context);
|
||||
g_object_unref (entry_context);
|
||||
g_object_unref (spin_context);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_func (GtkDrawingArea *da,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (da);
|
||||
gint panewidth;
|
||||
gint x, y;
|
||||
|
||||
panewidth = width / 2;
|
||||
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
cairo_set_source_rgb (cr, 0.9, 0.9, 0.9);
|
||||
cairo_fill (cr);
|
||||
|
||||
x = y = 10;
|
||||
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 30, GTK_STATE_FLAG_NORMAL, &height);
|
||||
y += height + 8;
|
||||
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 40, GTK_STATE_FLAG_PRELIGHT, &height);
|
||||
y += height + 8;
|
||||
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 50, GTK_STATE_FLAG_ACTIVE|GTK_STATE_FLAG_PRELIGHT, &height);
|
||||
|
||||
y += height + 8;
|
||||
draw_text (widget, cr, x, y, panewidth - 20, 20, "Not selected", GTK_STATE_FLAG_NORMAL);
|
||||
y += 20 + 10;
|
||||
draw_text (widget, cr, x, y, panewidth - 20, 20, "Selected", GTK_STATE_FLAG_SELECTED);
|
||||
|
||||
x = 10;
|
||||
y += 20 + 10;
|
||||
draw_check (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height);
|
||||
x += width + 10;
|
||||
draw_check (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height);
|
||||
x += width + 10;
|
||||
draw_radio (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height);
|
||||
x += width + 10;
|
||||
draw_radio (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height);
|
||||
x = 10;
|
||||
|
||||
y += height + 10;
|
||||
draw_progress (widget, cr, x, y, panewidth - 20, 50, &height);
|
||||
|
||||
y += height + 10;
|
||||
draw_scale (widget, cr, x, y, panewidth - 20, 75, &height);
|
||||
|
||||
y += height + 20;
|
||||
draw_notebook (widget, cr, x, y, panewidth - 20, 160);
|
||||
|
||||
/* Second column */
|
||||
x += panewidth;
|
||||
y = 10;
|
||||
draw_menu (widget, cr, x, y, panewidth - 20, &height);
|
||||
|
||||
y += height + 10;
|
||||
draw_menubar (widget, cr, x, y, panewidth - 20, &height);
|
||||
|
||||
y += height + 20;
|
||||
draw_spinbutton (widget, cr, x, y, panewidth - 20, &height);
|
||||
|
||||
y += height + 30;
|
||||
draw_combobox (widget, cr, x, y, panewidth - 20, FALSE, &height);
|
||||
|
||||
y += height + 10;
|
||||
draw_combobox (widget, cr, 10 + panewidth, y, panewidth - 20, TRUE, &height);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_foreigndrawing (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *box;
|
||||
GtkWidget *da;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Foreign drawing");
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 400);
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 400);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_func, NULL, NULL);
|
||||
gtk_widget_set_hexpand (da, TRUE);
|
||||
gtk_widget_set_vexpand (da, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (box), da);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
@@ -1,137 +0,0 @@
|
||||
/* OpenGL/Gears
|
||||
*
|
||||
* This is a classic OpenGL demo, running in a GtkGLArea.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtkgears.h"
|
||||
|
||||
/************************************************************************
|
||||
* DEMO CODE *
|
||||
************************************************************************/
|
||||
|
||||
static void
|
||||
on_axis_value_change (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GtkGears *gears = GTK_GEARS (data);
|
||||
int axis = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (adjustment), "axis"));
|
||||
|
||||
gtk_gears_set_axis (gears, axis, gtk_adjustment_get_value (adjustment));
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
create_axis_slider (GtkGears *gears,
|
||||
int axis)
|
||||
{
|
||||
GtkWidget *box, *label, *slider;
|
||||
GtkAdjustment *adj;
|
||||
const char *text;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case GTK_GEARS_X_AXIS:
|
||||
text = "X";
|
||||
break;
|
||||
|
||||
case GTK_GEARS_Y_AXIS:
|
||||
text = "Y";
|
||||
break;
|
||||
|
||||
case GTK_GEARS_Z_AXIS:
|
||||
text = "Z";
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
label = gtk_label_new (text);
|
||||
gtk_container_add (GTK_CONTAINER (box), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
adj = gtk_adjustment_new (gtk_gears_get_axis (gears, axis), 0.0, 360.0, 1.0, 12.0, 0.0);
|
||||
g_object_set_data (G_OBJECT (adj), "axis", GINT_TO_POINTER (axis));
|
||||
g_signal_connect (adj, "value-changed",
|
||||
G_CALLBACK (on_axis_value_change),
|
||||
gears);
|
||||
slider = gtk_scale_new (GTK_ORIENTATION_VERTICAL, adj);
|
||||
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (box), slider);
|
||||
gtk_widget_set_vexpand (slider, TRUE);
|
||||
gtk_widget_show (slider);
|
||||
|
||||
gtk_widget_show (box);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_gears (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *box, *hbox, *fps_label, *gears, *overlay, *frame;
|
||||
int i;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Gears");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
gtk_widget_set_margin_start (overlay, 12);
|
||||
gtk_widget_set_margin_end (overlay, 12);
|
||||
gtk_widget_set_margin_top (overlay, 12);
|
||||
gtk_widget_set_margin_bottom (overlay, 12);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), overlay);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_widget_set_halign (frame, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_START);
|
||||
gtk_widget_add_css_class (frame, "app-notification");
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), frame);
|
||||
|
||||
fps_label = gtk_label_new ("");
|
||||
gtk_widget_set_halign (fps_label, GTK_ALIGN_START);
|
||||
gtk_container_add (GTK_CONTAINER (frame), fps_label);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
|
||||
gtk_box_set_spacing (GTK_BOX (box), 6);
|
||||
gtk_container_add (GTK_CONTAINER (overlay), box);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
|
||||
gtk_box_set_spacing (GTK_BOX (box), 6);
|
||||
gtk_container_add (GTK_CONTAINER (box), hbox);
|
||||
|
||||
gears = gtk_gears_new ();
|
||||
gtk_widget_set_hexpand (gears, TRUE);
|
||||
gtk_widget_set_vexpand (gears, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), gears);
|
||||
|
||||
for (i = 0; i < GTK_GEARS_N_AXIS; i++)
|
||||
gtk_container_add (GTK_CONTAINER (hbox), create_axis_slider (GTK_GEARS (gears), i));
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
|
||||
gtk_box_set_spacing (GTK_BOX (hbox), 6);
|
||||
gtk_container_add (GTK_CONTAINER (box), hbox);
|
||||
|
||||
gtk_gears_set_fps_label (GTK_GEARS (gears), GTK_LABEL (fps_label));
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
@@ -17,9 +17,9 @@ typedef struct _Demo Demo;
|
||||
|
||||
struct _Demo
|
||||
{
|
||||
const char *name;
|
||||
const char *title;
|
||||
const char *filename;
|
||||
gchar *name;
|
||||
gchar *title;
|
||||
gchar *filename;
|
||||
GDoDemoFunc func;
|
||||
Demo *children;
|
||||
};
|
||||
|
@@ -94,12 +94,9 @@ drawing_area_draw (GtkDrawingArea *area,
|
||||
cairo_pattern_t *pat;
|
||||
cairo_matrix_t matrix;
|
||||
gdouble angle, scale;
|
||||
gdouble x_center, y_center;
|
||||
|
||||
gtk_gesture_get_bounding_box_center (GTK_GESTURE (zoom), &x_center, &y_center);
|
||||
|
||||
cairo_get_matrix (cr, &matrix);
|
||||
cairo_matrix_translate (&matrix, x_center, y_center);
|
||||
cairo_matrix_translate (&matrix, width / 2, height / 2);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
@@ -146,7 +143,7 @@ do_gestures (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Gestures");
|
||||
g_signal_connect (window, "destroy",
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* OpenGL/OpenGL Area
|
||||
/* OpenGL Area
|
||||
*
|
||||
* GtkGLArea is a widget that allows custom drawing using OpenGL calls.
|
||||
*/
|
||||
@@ -241,7 +241,7 @@ realize (GtkWidget *widget)
|
||||
fragment_path = "/glarea/glarea-gl.fs.glsl";
|
||||
}
|
||||
|
||||
init_buffers (NULL, &position_buffer);
|
||||
init_buffers (&position_buffer, NULL);
|
||||
init_shaders (vertex_path, fragment_path, &program, &mvp_location);
|
||||
}
|
||||
|
||||
@@ -383,23 +383,20 @@ close_window (GtkWidget *widget)
|
||||
rotation_angles[Z_AXIS] = 0.0;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
GtkWidget *
|
||||
create_glarea_window (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window, *box, *button, *controls;
|
||||
int i;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "OpenGL Area");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
|
||||
gtk_widget_set_margin_start (box, 12);
|
||||
gtk_widget_set_margin_end (box, 12);
|
||||
gtk_widget_set_margin_top (box, 12);
|
||||
gtk_widget_set_margin_bottom (box, 12);
|
||||
g_object_set (box, "margin", 12, NULL);
|
||||
gtk_box_set_spacing (GTK_BOX (box), 6);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
|
||||
|
@@ -23,7 +23,7 @@ do_headerbar (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
@@ -42,7 +42,7 @@ do_headerbar (GtkWidget *do_widget)
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_add_css_class (box, "linked");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (box), "linked");
|
||||
button = gtk_button_new ();
|
||||
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
|
||||
gtk_container_add (GTK_CONTAINER (box), button);
|
||||
|
@@ -17,7 +17,7 @@
|
||||
static void
|
||||
insert_link (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
const char *text,
|
||||
gchar *text,
|
||||
gint page)
|
||||
{
|
||||
GtkTextTag *tag;
|
||||
@@ -41,7 +41,6 @@ show_page (GtkTextBuffer *buffer,
|
||||
|
||||
gtk_text_buffer_set_text (buffer, "", 0);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
|
||||
gtk_text_buffer_begin_irreversible_action (buffer);
|
||||
if (page == 1)
|
||||
{
|
||||
gtk_text_buffer_insert (buffer, &iter, "Some text to show that simple ", -1);
|
||||
@@ -74,7 +73,6 @@ show_page (GtkTextBuffer *buffer,
|
||||
"so that related items of information are connected.\n", -1);
|
||||
insert_link (buffer, &iter, "Go back", 1);
|
||||
}
|
||||
gtk_text_buffer_end_irreversible_action (buffer);
|
||||
}
|
||||
|
||||
/* Looks at all tags covering the position of iter in the text view,
|
||||
@@ -232,7 +230,7 @@ do_hypertext (GtkWidget *do_widget)
|
||||
GtkTextBuffer *buffer;
|
||||
GtkEventController *controller;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Hypertext");
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
@@ -260,7 +258,6 @@ do_hypertext (GtkWidget *do_widget)
|
||||
gtk_widget_add_controller (view, controller);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_set_enable_undo (buffer, TRUE);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
|
@@ -1,232 +0,0 @@
|
||||
/* Benchmark/Scrolling
|
||||
*
|
||||
* This demo scrolls a view with various content.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static guint tick_cb;
|
||||
static GtkAdjustment *hadjustment;
|
||||
static GtkAdjustment *vadjustment;
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *scrolledwindow;
|
||||
static int selected;
|
||||
|
||||
#define N_WIDGET_TYPES 4
|
||||
|
||||
|
||||
static int hincrement = 5;
|
||||
static int vincrement = 5;
|
||||
|
||||
static gboolean
|
||||
scroll_cb (GtkWidget *widget,
|
||||
GdkFrameClock *frame_clock,
|
||||
gpointer data)
|
||||
{
|
||||
double value;
|
||||
|
||||
value = gtk_adjustment_get_value (vadjustment);
|
||||
if (value + vincrement <= gtk_adjustment_get_lower (vadjustment) ||
|
||||
(value + vincrement >= gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment)))
|
||||
vincrement = - vincrement;
|
||||
|
||||
gtk_adjustment_set_value (vadjustment, value + vincrement);
|
||||
|
||||
value = gtk_adjustment_get_value (hadjustment);
|
||||
if (value + hincrement <= gtk_adjustment_get_lower (hadjustment) ||
|
||||
(value + hincrement >= gtk_adjustment_get_upper (hadjustment) - gtk_adjustment_get_page_size (hadjustment)))
|
||||
hincrement = - hincrement;
|
||||
|
||||
gtk_adjustment_set_value (hadjustment, value + hincrement);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
extern GtkWidget *create_icon (void);
|
||||
|
||||
static void
|
||||
populate_icons (void)
|
||||
{
|
||||
GtkWidget *grid;
|
||||
int top, left;
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_margin_start (grid, 10);
|
||||
gtk_widget_set_margin_end (grid, 10);
|
||||
gtk_widget_set_margin_top (grid, 10);
|
||||
gtk_widget_set_margin_bottom (grid, 10);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
|
||||
|
||||
for (top = 0; top < 100; top++)
|
||||
for (left = 0; left < 15; left++)
|
||||
gtk_grid_attach (GTK_GRID (grid), create_icon (), left, top, 1, 1);
|
||||
|
||||
hincrement = 0;
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add (GTK_CONTAINER (scrolledwindow), grid);
|
||||
}
|
||||
|
||||
static char *content;
|
||||
static gsize content_len;
|
||||
|
||||
extern void fontify (GtkTextBuffer *buffer);
|
||||
|
||||
static void
|
||||
populate_text (gboolean hilight)
|
||||
{
|
||||
GtkWidget *textview;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
if (!content)
|
||||
{
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = g_resources_lookup_data ("/sources/font_features.c", 0, NULL);
|
||||
content = g_bytes_unref_to_data (bytes, &content_len);
|
||||
}
|
||||
|
||||
buffer = gtk_text_buffer_new (NULL);
|
||||
gtk_text_buffer_set_text (buffer, content, (int)content_len);
|
||||
|
||||
if (hilight)
|
||||
fontify (buffer);
|
||||
|
||||
textview = gtk_text_view_new ();
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
|
||||
|
||||
hincrement = 0;
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add (GTK_CONTAINER (scrolledwindow), textview);
|
||||
}
|
||||
|
||||
static void
|
||||
populate_image (void)
|
||||
{
|
||||
GtkWidget *image;
|
||||
|
||||
if (!content)
|
||||
{
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = g_resources_lookup_data ("/sources/font_features.c", 0, NULL);
|
||||
content = g_bytes_unref_to_data (bytes, &content_len);
|
||||
}
|
||||
|
||||
image = gtk_picture_new_for_resource ("/sliding_puzzle/portland-rose.jpg");
|
||||
gtk_picture_set_can_shrink (GTK_PICTURE (image), FALSE);
|
||||
|
||||
hincrement = 5;
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add (GTK_CONTAINER (scrolledwindow), image);
|
||||
}
|
||||
|
||||
static void
|
||||
set_widget_type (int type)
|
||||
{
|
||||
if (tick_cb)
|
||||
gtk_widget_remove_tick_callback (window, tick_cb);
|
||||
|
||||
if (gtk_bin_get_child (GTK_BIN (scrolledwindow)))
|
||||
gtk_container_remove (GTK_CONTAINER (scrolledwindow),
|
||||
gtk_bin_get_child (GTK_BIN (scrolledwindow)));
|
||||
|
||||
selected = type;
|
||||
|
||||
switch (selected)
|
||||
{
|
||||
case 0:
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scrolling icons");
|
||||
populate_icons ();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scrolling plain text");
|
||||
populate_text (FALSE);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scrolling complex text");
|
||||
populate_text (TRUE);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a big image");
|
||||
populate_image ();
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
tick_cb = gtk_widget_add_tick_callback (window, scroll_cb, NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
iconscroll_next_clicked_cb (GtkButton *source,
|
||||
gpointer user_data)
|
||||
{
|
||||
int new_index;
|
||||
|
||||
if (selected + 1 >= N_WIDGET_TYPES)
|
||||
new_index = 0;
|
||||
else
|
||||
new_index = selected + 1;
|
||||
|
||||
|
||||
set_widget_type (new_index);
|
||||
}
|
||||
|
||||
void
|
||||
iconscroll_prev_clicked_cb (GtkButton *source,
|
||||
gpointer user_data)
|
||||
{
|
||||
int new_index;
|
||||
|
||||
if (selected - 1 < 0)
|
||||
new_index = N_WIDGET_TYPES - 1;
|
||||
else
|
||||
new_index = selected - 1;
|
||||
|
||||
set_widget_type (new_index);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_iconscroll (GtkWidget *do_widget)
|
||||
{
|
||||
if (!window)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/iconscroll/iconscroll.ui");
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
scrolledwindow = GTK_WIDGET (gtk_builder_get_object (builder, "scrolledwindow"));
|
||||
gtk_widget_realize (window);
|
||||
hadjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "hadjustment"));
|
||||
vadjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "vadjustment"));
|
||||
set_widget_type (0);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="resizable">0</property>
|
||||
<property name="default-width">500</property>
|
||||
<property name="default-height">500</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">pan-start-symbolic</property>
|
||||
<signal name="clicked" handler="iconscroll_prev_clicked_cb"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">pan-end-symbolic</property>
|
||||
<signal name="clicked" handler="iconscroll_next_clicked_cb"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow">
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="hadjustment">
|
||||
<object class="GtkAdjustment" id="hadjustment"/>
|
||||
</property>
|
||||
<property name="vadjustment">
|
||||
<object class="GtkAdjustment" id="vadjustment"/>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -26,7 +26,7 @@ enum
|
||||
|
||||
static GdkPixbuf *file_pixbuf, *folder_pixbuf;
|
||||
gchar *parent;
|
||||
GtkWidget *up_button;
|
||||
GtkToolItem *up_button;
|
||||
|
||||
/* Loads the images for the demo and returns whether the operation succeeded */
|
||||
static void
|
||||
@@ -188,8 +188,8 @@ item_activated (GtkIconView *icon_view,
|
||||
}
|
||||
|
||||
static void
|
||||
up_clicked (GtkButton *item,
|
||||
gpointer user_data)
|
||||
up_clicked (GtkToolItem *item,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkListStore *store;
|
||||
gchar *dir_name;
|
||||
@@ -209,8 +209,8 @@ up_clicked (GtkButton *item,
|
||||
}
|
||||
|
||||
static void
|
||||
home_clicked (GtkButton *item,
|
||||
gpointer user_data)
|
||||
home_clicked (GtkToolItem *item,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkListStore *store;
|
||||
|
||||
@@ -248,9 +248,9 @@ do_iconview (GtkWidget *do_widget)
|
||||
GtkListStore *store;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *tool_bar;
|
||||
GtkWidget *home_button;
|
||||
GtkToolItem *home_button;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
|
||||
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
@@ -265,19 +265,28 @@ do_iconview (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
tool_bar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
tool_bar = gtk_toolbar_new ();
|
||||
gtk_container_add (GTK_CONTAINER (vbox), tool_bar);
|
||||
|
||||
up_button = gtk_button_new_with_mnemonic ("_Up");
|
||||
up_button = gtk_tool_button_new (NULL, NULL);
|
||||
gtk_tool_button_set_label (GTK_TOOL_BUTTON (up_button), _("_Up"));
|
||||
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (up_button), TRUE);
|
||||
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (up_button), "go-up");
|
||||
gtk_tool_item_set_is_important (up_button, TRUE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (tool_bar), up_button);
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), up_button, -1);
|
||||
|
||||
home_button = gtk_button_new_with_mnemonic ("_Home");
|
||||
gtk_container_add (GTK_CONTAINER (tool_bar), home_button);
|
||||
home_button = gtk_tool_button_new (NULL, NULL);
|
||||
gtk_tool_button_set_label (GTK_TOOL_BUTTON (home_button), _("_Home"));
|
||||
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (home_button), TRUE);
|
||||
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (home_button), "go-home");
|
||||
gtk_tool_item_set_is_important (home_button, TRUE);
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), home_button, -1);
|
||||
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_ETCHED_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
@@ -106,7 +106,7 @@ do_iconview_edit (GtkWidget *do_widget)
|
||||
GtkListStore *store;
|
||||
GtkCellRenderer *renderer;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
|
@@ -331,7 +331,7 @@ do_images (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Images");
|
||||
@@ -342,10 +342,7 @@ do_images (GtkWidget *do_widget)
|
||||
G_CALLBACK (cleanup_callback), NULL);
|
||||
|
||||
base_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (base_vbox, 16);
|
||||
gtk_widget_set_margin_end (base_vbox, 16);
|
||||
gtk_widget_set_margin_top (base_vbox, 16);
|
||||
gtk_widget_set_margin_bottom (base_vbox, 16);
|
||||
g_object_set (base_vbox, "margin", 16, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), base_vbox);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 16);
|
||||
@@ -360,6 +357,7 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
@@ -378,6 +376,7 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
@@ -394,6 +393,7 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
@@ -415,6 +415,7 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
@@ -437,6 +438,7 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
@@ -53,7 +53,7 @@ do_infobar (GtkWidget *do_widget)
|
||||
{
|
||||
actions = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Info Bars");
|
||||
@@ -61,19 +61,16 @@ do_infobar (GtkWidget *do_widget)
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
gtk_widget_set_margin_top (vbox, 8);
|
||||
gtk_widget_set_margin_bottom (vbox, 8);
|
||||
g_object_set (vbox, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
bar = gtk_info_bar_new ();
|
||||
gtk_container_add (GTK_CONTAINER (vbox), bar);
|
||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_INFO);
|
||||
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_INFO");
|
||||
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_container_add (GTK_CONTAINER (bar), label);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
|
||||
|
||||
button = gtk_toggle_button_new_with_label ("Message");
|
||||
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
@@ -83,9 +80,9 @@ do_infobar (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), bar);
|
||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_WARNING);
|
||||
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_WARNING");
|
||||
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_container_add (GTK_CONTAINER (bar), label);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
|
||||
|
||||
button = gtk_toggle_button_new_with_label ("Warning");
|
||||
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
@@ -97,10 +94,9 @@ do_infobar (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), bar);
|
||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_QUESTION);
|
||||
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_QUESTION");
|
||||
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_container_add (GTK_CONTAINER (bar), label);
|
||||
gtk_info_bar_set_default_response (GTK_INFO_BAR (bar), GTK_RESPONSE_OK);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
|
||||
|
||||
button = gtk_toggle_button_new_with_label ("Question");
|
||||
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
@@ -110,9 +106,9 @@ do_infobar (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), bar);
|
||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_ERROR);
|
||||
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_ERROR");
|
||||
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_container_add (GTK_CONTAINER (bar), label);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
|
||||
|
||||
button = gtk_toggle_button_new_with_label ("Error");
|
||||
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
@@ -123,9 +119,9 @@ do_infobar (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), bar);
|
||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_OTHER);
|
||||
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_OTHER");
|
||||
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_container_add (GTK_CONTAINER (bar), label);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
|
||||
|
||||
button = gtk_toggle_button_new_with_label ("Other");
|
||||
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
@@ -137,10 +133,7 @@ do_infobar (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox2, 8);
|
||||
gtk_widget_set_margin_end (vbox2, 8);
|
||||
gtk_widget_set_margin_top (vbox2, 8);
|
||||
gtk_widget_set_margin_bottom (vbox2, 8);
|
||||
g_object_set (vbox2, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox2);
|
||||
|
||||
/* Standard message dialog */
|
||||
|
@@ -18,10 +18,6 @@
|
||||
|
||||
#include "language-names.h"
|
||||
|
||||
#ifndef ISO_CODES_PREFIX
|
||||
#define ISO_CODES_PREFIX "/usr"
|
||||
#endif
|
||||
|
||||
#define ISO_CODES_DATADIR ISO_CODES_PREFIX "/share/xml/iso-codes"
|
||||
#define ISO_CODES_LOCALESDIR ISO_CODES_PREFIX "/share/locale"
|
||||
|
||||
|
@@ -52,7 +52,7 @@ do_links (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Links");
|
||||
|
@@ -16,9 +16,10 @@ typedef struct
|
||||
{
|
||||
const gboolean fixed;
|
||||
const guint number;
|
||||
const char *severity;
|
||||
const char *description;
|
||||
} Bug;
|
||||
const gchar *severity;
|
||||
const gchar *description;
|
||||
}
|
||||
Bug;
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -33,7 +34,7 @@ enum
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
static Bug bugs[] =
|
||||
static Bug data[] =
|
||||
{
|
||||
{ FALSE, 60482, "Normal", "scrollable notebooks and hidden tabs" },
|
||||
{ FALSE, 60620, "Critical", "gdk_surface_clear_area (gdksurface-win32.c) is not thread-safe" },
|
||||
@@ -97,9 +98,9 @@ create_model (void)
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
/* add data to the list store */
|
||||
for (i = 0; i < G_N_ELEMENTS (bugs); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (data); i++)
|
||||
{
|
||||
const char *icon_name;
|
||||
gchar *icon_name;
|
||||
gboolean sensitive;
|
||||
|
||||
if (i == 1 || i == 3)
|
||||
@@ -112,10 +113,10 @@ create_model (void)
|
||||
sensitive = TRUE;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_FIXED, bugs[i].fixed,
|
||||
COLUMN_NUMBER, bugs[i].number,
|
||||
COLUMN_SEVERITY, bugs[i].severity,
|
||||
COLUMN_DESCRIPTION, bugs[i].description,
|
||||
COLUMN_FIXED, data[i].fixed,
|
||||
COLUMN_NUMBER, data[i].number,
|
||||
COLUMN_SEVERITY, data[i].severity,
|
||||
COLUMN_DESCRIPTION, data[i].description,
|
||||
COLUMN_PULSE, 0,
|
||||
COLUMN_ICON, icon_name,
|
||||
COLUMN_ACTIVE, FALSE,
|
||||
@@ -128,23 +129,23 @@ create_model (void)
|
||||
|
||||
static void
|
||||
fixed_toggled (GtkCellRendererToggle *cell,
|
||||
char *path_str,
|
||||
gchar *path_str,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *tree_model = (GtkTreeModel *)data;
|
||||
GtkTreeModel *model = (GtkTreeModel *)data;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
||||
gboolean fixed;
|
||||
|
||||
/* get toggled iter */
|
||||
gtk_tree_model_get_iter (tree_model, &iter, path);
|
||||
gtk_tree_model_get (tree_model, &iter, COLUMN_FIXED, &fixed, -1);
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get (model, &iter, COLUMN_FIXED, &fixed, -1);
|
||||
|
||||
/* do something with the value */
|
||||
fixed ^= 1;
|
||||
|
||||
/* set new value */
|
||||
gtk_list_store_set (GTK_LIST_STORE (tree_model), &iter, COLUMN_FIXED, fixed, -1);
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_FIXED, fixed, -1);
|
||||
|
||||
/* clean up */
|
||||
gtk_tree_path_free (path);
|
||||
@@ -155,6 +156,7 @@ add_columns (GtkTreeView *treeview)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
|
||||
|
||||
/* column for fixed toggles */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
@@ -253,7 +255,7 @@ do_list_store (GtkWidget *do_widget)
|
||||
GtkWidget *treeview;
|
||||
|
||||
/* create window, etc */
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Store");
|
||||
@@ -262,17 +264,15 @@ do_list_store (GtkWidget *do_widget)
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
gtk_widget_set_margin_top (vbox, 8);
|
||||
gtk_widget_set_margin_bottom (vbox, 8);
|
||||
g_object_set (vbox, "margin", 8, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
label = gtk_label_new ("This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).");
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_ETCHED_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
@@ -347,7 +347,7 @@ do_listbox (GtkWidget *do_widget)
|
||||
{
|
||||
avatar_pixbuf_other = gdk_pixbuf_new_from_resource_at_scale ("/listbox/apple-red.png", 32, 32, FALSE, NULL);
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Box");
|
||||
|
@@ -1,15 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk40">
|
||||
<menu id="menu1">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Email message</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Embed message</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<object class="GtkMenu" id="menu1">
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menuitem1">
|
||||
<property name="label" translatable="yes">Email message</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menuitem2">
|
||||
<property name="label" translatable="yes">Embed message</property>
|
||||
<property name="use-underline">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<template class="GtkMessageRow" parent="GtkListBoxRow">
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid1">
|
||||
@@ -38,9 +42,10 @@
|
||||
<property name="baseline-position">top</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="relief">none</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="source_name">
|
||||
<property name="valign">baseline</property>
|
||||
@@ -108,8 +113,9 @@
|
||||
<child>
|
||||
<object class="GtkLinkButton" id="resent_by_button">
|
||||
<property name="label" translatable="0">reshareer</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="uri">http://www.gtk.org</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -125,8 +131,9 @@
|
||||
<child>
|
||||
<object class="GtkButton" id="expand_button">
|
||||
<property name="label" translatable="yes">Expand</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="relief">none</property>
|
||||
<signal name="clicked" handler="expand_clicked" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
@@ -137,31 +144,35 @@
|
||||
<child>
|
||||
<object class="GtkButton" id="reply-button">
|
||||
<property name="label" translatable="yes">Reply</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="relief">none</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="reshare-button">
|
||||
<property name="label" translatable="yes">Reshare</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="relief">none</property>
|
||||
<signal name="clicked" handler="reshare_clicked" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="favorite-buttton">
|
||||
<property name="label" translatable="yes">Favorite</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="relief">none</property>
|
||||
<signal name="clicked" handler="favorite_clicked" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="more-button">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="menu-model">menu1</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="popup">menu1</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="label" translatable="yes">More...</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -185,6 +196,7 @@
|
||||
<property name="spacing">8</property>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame1">
|
||||
<property name="shadow-type">none</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="n_reshares_label">
|
||||
<property name="label" translatable="0"><b>2</b>
|
||||
@@ -197,6 +209,7 @@ Reshares</property>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame2">
|
||||
<property name="shadow-type">none</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="n_favorites_label">
|
||||
<property name="label" translatable="0"><b>2</b>
|
||||
@@ -222,8 +235,9 @@ FAVORITES</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button5">
|
||||
<property name="label" translatable="yes">Details</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="relief">none</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
|
@@ -205,14 +205,14 @@ enum {
|
||||
STATE_IN_COMMENT
|
||||
};
|
||||
|
||||
static const char *tokens[] =
|
||||
static gchar *tokens[] =
|
||||
{
|
||||
"/*",
|
||||
"\"",
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *types[] =
|
||||
static gchar *types[] =
|
||||
{
|
||||
"static",
|
||||
"const ",
|
||||
@@ -310,6 +310,7 @@ static const char *types[] =
|
||||
"GtkIconView ",
|
||||
"GtkCellRendererText ",
|
||||
"GtkContainer ",
|
||||
"GtkAccelGroup ",
|
||||
"GtkPaned ",
|
||||
"GtkPrintOperation ",
|
||||
"GtkPrintContext ",
|
||||
@@ -336,7 +337,7 @@ static const char *types[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *control[] =
|
||||
static gchar *control[] =
|
||||
{
|
||||
" if ",
|
||||
" while ",
|
||||
@@ -350,11 +351,11 @@ static const char *control[] =
|
||||
NULL
|
||||
};
|
||||
void
|
||||
parse_chars (gchar *text,
|
||||
gchar **end_ptr,
|
||||
gint *state,
|
||||
const char **tag,
|
||||
gboolean start)
|
||||
parse_chars (gchar *text,
|
||||
gchar **end_ptr,
|
||||
gint *state,
|
||||
gchar **tag,
|
||||
gboolean start)
|
||||
{
|
||||
gint i;
|
||||
gchar *next_token;
|
||||
@@ -486,14 +487,14 @@ parse_chars (gchar *text,
|
||||
}
|
||||
|
||||
/* While not as cool as c-mode, this will do as a quick attempt at highlighting */
|
||||
void
|
||||
static void
|
||||
fontify (GtkTextBuffer *source_buffer)
|
||||
{
|
||||
GtkTextIter start_iter, next_iter, tmp_iter;
|
||||
gint state;
|
||||
gchar *text;
|
||||
gchar *start_ptr, *end_ptr;
|
||||
const char *tag;
|
||||
gchar *tag;
|
||||
|
||||
gtk_text_buffer_create_tag (source_buffer, "source",
|
||||
"font", "monospace",
|
||||
@@ -612,6 +613,8 @@ display_text (const char *resource)
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_NONE);
|
||||
gtk_container_add (GTK_CONTAINER (sw), textview);
|
||||
|
||||
return sw;
|
||||
@@ -636,7 +639,7 @@ display_nothing (const char *resource)
|
||||
|
||||
str = g_strdup_printf ("The lazy GTK developers forgot to add a way to display the resource '%s'", resource);
|
||||
widget = gtk_label_new (str);
|
||||
gtk_label_set_wrap (GTK_LABEL (widget), TRUE);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
|
||||
|
||||
g_free (str);
|
||||
|
||||
@@ -745,9 +748,6 @@ load_file (const gchar *demoname,
|
||||
|
||||
source_buffer = gtk_text_buffer_new (NULL);
|
||||
|
||||
gtk_text_buffer_begin_irreversible_action (info_buffer);
|
||||
gtk_text_buffer_begin_irreversible_action (source_buffer);
|
||||
|
||||
resource_filename = g_strconcat ("/sources/", filename, NULL);
|
||||
bytes = g_resources_lookup_data (resource_filename, 0, &err);
|
||||
g_free (resource_filename);
|
||||
@@ -865,7 +865,7 @@ load_file (const gchar *demoname,
|
||||
|
||||
p = lines[i];
|
||||
state++;
|
||||
G_GNUC_FALLTHROUGH;
|
||||
/* Fall through */
|
||||
|
||||
case 3:
|
||||
/* Reading program body */
|
||||
@@ -873,9 +873,6 @@ load_file (const gchar *demoname,
|
||||
if (lines[i+1] != NULL)
|
||||
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,11 +880,9 @@ load_file (const gchar *demoname,
|
||||
|
||||
fontify (source_buffer);
|
||||
|
||||
gtk_text_buffer_end_irreversible_action (source_buffer);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (source_view), source_buffer);
|
||||
g_object_unref (source_buffer);
|
||||
|
||||
gtk_text_buffer_end_irreversible_action (info_buffer);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (info_view), info_buffer);
|
||||
g_object_unref (info_buffer);
|
||||
}
|
||||
@@ -975,7 +970,7 @@ startup (GApplication *app)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GMenuModel *appmenu;
|
||||
const char *ids[] = { "appmenu", NULL };
|
||||
gchar *ids[] = { "appmenu", NULL };
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_add_objects_from_resource (builder, "/ui/appmenu.ui", ids, NULL);
|
||||
@@ -1003,6 +998,32 @@ row_activated_cb (GtkWidget *tree_view,
|
||||
run_example_for_row (window, model, &iter);
|
||||
}
|
||||
|
||||
static void
|
||||
start_cb (GtkMenuItem *item, GtkWidget *scrollbar)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
|
||||
adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (scrollbar));
|
||||
gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
|
||||
}
|
||||
|
||||
static void
|
||||
end_cb (GtkMenuItem *item, GtkWidget *scrollbar)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
|
||||
adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (scrollbar));
|
||||
gtk_adjustment_set_value (adj, gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
scrollbar_popup (GtkWidget *scrollbar, GtkWidget *menu)
|
||||
{
|
||||
gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
activate (GApplication *app)
|
||||
{
|
||||
@@ -1011,12 +1032,23 @@ activate (GApplication *app)
|
||||
GtkWidget *widget;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GError *error = NULL;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *scrollbar;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *item;
|
||||
|
||||
static GActionEntry win_entries[] = {
|
||||
{ "run", activate_run, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/ui/main.ui");
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_resource (builder, "/ui/main.ui", &error);
|
||||
if (error != NULL)
|
||||
{
|
||||
g_critical ("%s", error->message);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
window = (GtkWindow *)gtk_builder_get_object (builder, "window");
|
||||
gtk_application_add_window (GTK_APPLICATION (app), window);
|
||||
@@ -1032,6 +1064,21 @@ activate (GApplication *app)
|
||||
treeview = (GtkWidget *)gtk_builder_get_object (builder, "treeview");
|
||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
|
||||
|
||||
sw = (GtkWidget *)gtk_builder_get_object (builder, "source-scrolledwindow");
|
||||
scrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (sw));
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Start");
|
||||
g_signal_connect (item, "activate", G_CALLBACK (start_cb), scrollbar);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
|
||||
item = gtk_menu_item_new_with_label ("End");
|
||||
g_signal_connect (item, "activate", G_CALLBACK (end_cb), scrollbar);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
|
||||
g_signal_connect (scrollbar, "popup-menu", G_CALLBACK (scrollbar_popup), menu);
|
||||
|
||||
load_file (gtk_demos[0].name, gtk_demos[0].filename);
|
||||
|
||||
populate_model (model);
|
||||
|
@@ -28,12 +28,14 @@
|
||||
<property name="default-width">800</property>
|
||||
<property name="default-height">600</property>
|
||||
<property name="title">GTK Demo</property>
|
||||
<signal name="destroy" handler="gtk_main_quit" swapped="no"/>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="headerbar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="valign">center</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="action-name">win.run</property>
|
||||
<style>
|
||||
<class name="text-button"/>
|
||||
@@ -61,10 +63,12 @@
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="width-request">120</property>
|
||||
<property name="can-focus">1</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="min-content-width">150</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="model">treestore</property>
|
||||
<property name="headers-visible">0</property>
|
||||
<child internal-child="selection">
|
||||
@@ -96,18 +100,20 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkNotebook" id="notebook">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="scrollable">1</property>
|
||||
<property name="enable-popup">1</property>
|
||||
<property name="show-border">0</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="expand">1</property>
|
||||
<child>
|
||||
<object class="GtkNotebookPage">
|
||||
<property name="tab-expand">1</property>
|
||||
<property name="child">
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="can-focus">1</property>
|
||||
<child>
|
||||
<object class="GtkTextView" id="info-textview">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="left-margin">20</property>
|
||||
<property name="right-margin">20</property>
|
||||
<property name="top-margin">20</property>
|
||||
@@ -135,8 +141,10 @@
|
||||
<property name="tab-expand">1</property>
|
||||
<property name="child">
|
||||
<object class="GtkScrolledWindow" id="source-scrolledwindow">
|
||||
<property name="can-focus">1</property>
|
||||
<child>
|
||||
<object class="GtkTextView" id="source-textview">
|
||||
<property name="can-focus">1</property>
|
||||
<property name="left-margin">20</property>
|
||||
<property name="right-margin">20</property>
|
||||
<property name="top-margin">20</property>
|
||||
|
@@ -29,10 +29,8 @@ source_toggled (GtkToggleButton *button)
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_get_bounds (buffer, &start, &end);
|
||||
gtk_text_buffer_begin_irreversible_action (buffer);
|
||||
gtk_text_buffer_delete (buffer, &start, &end);
|
||||
gtk_text_buffer_insert_markup (buffer, &start, markup, -1);
|
||||
gtk_text_buffer_end_irreversible_action (buffer);
|
||||
g_free (markup);
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), "formatted");
|
||||
@@ -54,7 +52,7 @@ do_markup (GtkWidget *do_widget)
|
||||
GtkWidget *header;
|
||||
GtkWidget *show_source;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
|
||||
@@ -78,7 +76,7 @@ do_markup (GtkWidget *do_widget)
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
|
||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 10);
|
||||
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 10);
|
||||
|
||||
@@ -108,15 +106,11 @@ do_markup (GtkWidget *do_widget)
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
gtk_text_buffer_begin_irreversible_action (buffer);
|
||||
gtk_text_buffer_insert_markup (buffer, &iter, markup, -1);
|
||||
gtk_text_buffer_end_irreversible_action (buffer);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view2));
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
gtk_text_buffer_begin_irreversible_action (buffer);
|
||||
gtk_text_buffer_insert (buffer, &iter, markup, -1);
|
||||
gtk_text_buffer_end_irreversible_action (buffer);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
|
@@ -14,7 +14,3 @@ Superscripts and subscripts: 𝜀<span rise="-6000" size="x-small" font_desc="it
|
||||
OpenType font features: <span font_desc="sans regular" font_features="dlig=0">feast</span> versus <span font_desc="sans regular" font_features="dlig=1">feast</span>
|
||||
|
||||
Shortcuts: <tt>Monospace</tt> – <b>Bold</b> – <i>Italic</i> – <big>Big</big> – <small>Small</small> – <u>Underlined</u> – <s>Strikethrough</s> – Super<sup>script</sup> – Sub<sub>script</sub>
|
||||
|
||||
<span allow_breaks="false">A</span> hyphenation algorithm is a set of rules, especially one codified for implementation in a computer program, that decides at which points a word can be broken over two lines with a hyphen. For example, a hyphenation algorithm might decide that impeachment can be broken as <span allow_breaks="false">impeach‧ment</span> or <span allow_breaks="false">im‧peachment</span> but not <span allow_breaks="false">impe‧achment.</span>
|
||||
|
||||
<span insert_hyphens="false">one/two three/four five/six seven/eight nine/ten</span>
|
||||
|
147
demos/gtk-demo/menus.c
Normal file
147
demos/gtk-demo/menus.c
Normal file
@@ -0,0 +1,147 @@
|
||||
/* Menus
|
||||
*
|
||||
* There are several widgets involved in displaying menus. The
|
||||
* GtkMenuBar widget is a menu bar, which normally appears horizontally
|
||||
* at the top of an application, but can also be layed out vertically.
|
||||
* The GtkMenu widget is the actual menu that pops up. Both GtkMenuBar
|
||||
* and GtkMenu are subclasses of GtkMenuShell; a GtkMenuShell contains
|
||||
* menu items (GtkMenuItem). Each menu item contains text and/or images
|
||||
* and can be selected by the user.
|
||||
*
|
||||
* There are several kinds of menu item, including plain GtkMenuItem,
|
||||
* GtkCheckMenuItem which can be checked/unchecked, GtkRadioMenuItem
|
||||
* which is a check menu item that's in a mutually exclusive group,
|
||||
* GtkSeparatorMenuItem which is a separator bar, GtkTearoffMenuItem
|
||||
* which allows a GtkMenu to be torn off, and GtkImageMenuItem which
|
||||
* can place a GtkImage or other widget next to the menu text.
|
||||
*
|
||||
* A GtkMenuItem can have a submenu, which is simply a GtkMenu to pop
|
||||
* up when the menu item is selected. Typically, all menu items in a menu bar
|
||||
* have submenus.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static GtkWidget *
|
||||
create_menu (gint depth)
|
||||
{
|
||||
GtkWidget *menu;
|
||||
GtkRadioMenuItem *last_item;
|
||||
char buf[32];
|
||||
int i, j;
|
||||
|
||||
if (depth < 1)
|
||||
return NULL;
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
last_item = NULL;
|
||||
|
||||
for (i = 0, j = 1; i < 5; i++, j++)
|
||||
{
|
||||
GtkWidget *menu_item;
|
||||
|
||||
sprintf (buf, "item %2d - %d", depth, j);
|
||||
|
||||
menu_item = gtk_radio_menu_item_new_with_label_from_widget (NULL, buf);
|
||||
gtk_radio_menu_item_join_group (GTK_RADIO_MENU_ITEM (menu_item), last_item);
|
||||
last_item = GTK_RADIO_MENU_ITEM (menu_item);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||
gtk_widget_show (menu_item);
|
||||
if (i == 3)
|
||||
gtk_widget_set_sensitive (menu_item, FALSE);
|
||||
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), create_menu (depth - 1));
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
static void
|
||||
change_orientation (GtkWidget *button,
|
||||
GtkWidget *menubar)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkOrientation orientation;
|
||||
|
||||
parent = gtk_widget_get_parent (menubar);
|
||||
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (parent));
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (parent), 1 - orientation);
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
do_menus (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *box;
|
||||
GtkWidget *box1;
|
||||
GtkWidget *box2;
|
||||
GtkWidget *button;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *menubar;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *menuitem;
|
||||
GtkAccelGroup *accel_group;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Menus");
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK(gtk_widget_destroyed), &window);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
|
||||
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (box), box1);
|
||||
|
||||
menubar = gtk_menu_bar_new ();
|
||||
gtk_widget_set_hexpand (menubar, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (box1), menubar);
|
||||
|
||||
menu = create_menu (2);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("test\nline2");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("foo");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3));
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("bar");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4));
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_container_add (GTK_CONTAINER (box1), box2);
|
||||
|
||||
button = gtk_button_new_with_label ("Flip");
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (change_orientation), menubar);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
g_signal_connect_swapped (button, "clicked",
|
||||
G_CALLBACK(gtk_widget_destroy), window);
|
||||
gtk_container_add (GTK_CONTAINER (box2), button);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_New</attribute>
|
||||
<attribute name="action">app.new</attribute>
|
||||
<attribute name="accel"><Control>n</attribute>
|
||||
<attribute name="accel"><Primary>n</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Open</attribute>
|
||||
@@ -14,19 +14,19 @@
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Save</attribute>
|
||||
<attribute name="action">app.save</attribute>
|
||||
<attribute name="accel"><Control>s</attribute>
|
||||
<attribute name="accel"><Primary>s</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Save _As...</attribute>
|
||||
<attribute name="action">app.save-as</attribute>
|
||||
<attribute name="accel"><Control>s</attribute>
|
||||
<attribute name="accel"><Primary>s</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Quit</attribute>
|
||||
<attribute name="action">app.quit</attribute>
|
||||
<attribute name="accel"><Control>q</attribute>
|
||||
<attribute name="accel"><Primary>q</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
@@ -45,19 +45,19 @@
|
||||
<attribute name="label" translatable="yes">_Red</attribute>
|
||||
<attribute name="action">app.color</attribute>
|
||||
<attribute name="target">red</attribute>
|
||||
<attribute name="accel"><Control>r</attribute>
|
||||
<attribute name="accel"><Primary>r</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Green</attribute>
|
||||
<attribute name="action">app.color</attribute>
|
||||
<attribute name="target">green</attribute>
|
||||
<attribute name="accel"><Control>g</attribute>
|
||||
<attribute name="accel"><Primary>g</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Blue</attribute>
|
||||
<attribute name="action">app.color</attribute>
|
||||
<attribute name="target">blue</attribute>
|
||||
<attribute name="accel"><Control>b</attribute>
|
||||
<attribute name="accel"><Primary>b</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</submenu>
|
||||
@@ -68,26 +68,26 @@
|
||||
<attribute name="label" translatable="yes">_Square</attribute>
|
||||
<attribute name="action">win.shape</attribute>
|
||||
<attribute name="target">square</attribute>
|
||||
<attribute name="accel"><Control>s</attribute>
|
||||
<attribute name="accel"><Primary>s</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Rectangle</attribute>
|
||||
<attribute name="action">win.shape</attribute>
|
||||
<attribute name="target">rectangle</attribute>
|
||||
<attribute name="accel"><Control>r</attribute>
|
||||
<attribute name="accel"><Primary>r</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Oval</attribute>
|
||||
<attribute name="action">win.shape</attribute>
|
||||
<attribute name="target">oval</attribute>
|
||||
<attribute name="accel"><Control>o</attribute>
|
||||
<attribute name="accel"><Primary>o</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</submenu>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Bold</attribute>
|
||||
<attribute name="action">win.bold</attribute>
|
||||
<attribute name="accel"><Control><Shift>b</attribute>
|
||||
<attribute name="accel"><Primary><Shift>b</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</submenu>
|
||||
@@ -96,7 +96,7 @@
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_About</attribute>
|
||||
<attribute name="action">win.about</attribute>
|
||||
<attribute name="accel"><Control>a</attribute>
|
||||
<attribute name="accel"><Primary>a</attribute>
|
||||
</item>
|
||||
</submenu>
|
||||
</menu>
|
||||
|
@@ -4,6 +4,7 @@ demos = files([
|
||||
'application_demo.c',
|
||||
'assistant.c',
|
||||
'builder.c',
|
||||
'changedisplay.c',
|
||||
'clipboard.c',
|
||||
'colorsel.c',
|
||||
'combobox.c',
|
||||
@@ -21,19 +22,18 @@ demos = files([
|
||||
'drawingarea.c',
|
||||
'dnd.c',
|
||||
'editable_cells.c',
|
||||
'entry_buffer.c',
|
||||
'entry_completion.c',
|
||||
'entry_undo.c',
|
||||
'expander.c',
|
||||
'filtermodel.c',
|
||||
'fishbowl.c',
|
||||
'fixed.c',
|
||||
'fontrendering.c',
|
||||
'gears.c',
|
||||
'foreigndrawing.c',
|
||||
'gestures.c',
|
||||
'glarea.c',
|
||||
'headerbar.c',
|
||||
'hypertext.c',
|
||||
'iconscroll.c',
|
||||
'iconview.c',
|
||||
'iconview_edit.c',
|
||||
'images.c',
|
||||
@@ -43,6 +43,7 @@ demos = files([
|
||||
'flowbox.c',
|
||||
'list_store.c',
|
||||
'markup.c',
|
||||
'menus.c',
|
||||
'modelbutton.c',
|
||||
'overlay.c',
|
||||
'overlay2.c',
|
||||
@@ -52,9 +53,9 @@ demos = files([
|
||||
'paintable_mediastream.c',
|
||||
'panes.c',
|
||||
'password_entry.c',
|
||||
'peg_solitaire.c',
|
||||
'pickers.c',
|
||||
'pixbufs.c',
|
||||
'popover.c',
|
||||
'printing.c',
|
||||
'revealer.c',
|
||||
'rotated_text.c',
|
||||
@@ -62,7 +63,6 @@ demos = files([
|
||||
'search_entry.c',
|
||||
'search_entry2.c',
|
||||
'shortcuts.c',
|
||||
'shortcut_triggers.c',
|
||||
'sidebar.c',
|
||||
'sizegroup.c',
|
||||
'sliding_puzzle.c',
|
||||
@@ -72,7 +72,6 @@ demos = files([
|
||||
'tabs.c',
|
||||
'tagged_entry.c',
|
||||
'textmask.c',
|
||||
'textundo.c',
|
||||
'textview.c',
|
||||
'textscroll.c',
|
||||
'themes.c',
|
||||
@@ -113,16 +112,9 @@ gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
|
||||
'demo.gresource.xml',
|
||||
source_dir: '.')
|
||||
|
||||
demo_cflags = []
|
||||
foreach flag: common_cflags
|
||||
if flag not in ['-Werror=missing-prototypes', '-Werror=missing-declarations', '-fvisibility=hidden']
|
||||
demo_cflags += flag
|
||||
endif
|
||||
endforeach
|
||||
|
||||
executable('gtk4-demo',
|
||||
demos, demos_h, extra_demo_sources, gtkdemo_resources,
|
||||
c_args: gtkdemo_args + demo_cflags,
|
||||
c_args: gtkdemo_args,
|
||||
dependencies: gtkdemo_deps,
|
||||
include_directories: confinc,
|
||||
gui_app: true,
|
||||
@@ -131,7 +123,7 @@ executable('gtk4-demo',
|
||||
|
||||
executable('gtk4-demo-application',
|
||||
'application.c', gtkdemo_resources,
|
||||
c_args: gtkdemo_args + common_cflags,
|
||||
c_args: gtkdemo_args,
|
||||
dependencies: gtkdemo_deps,
|
||||
include_directories: confinc,
|
||||
gui_app: true,
|
||||
|
@@ -378,7 +378,7 @@
|
||||
378|GTK+ and friends|GTKtoolkit|#GNUStep gets #GTK+ theming http://is.gd/95vHl more at http://is.gd/95wt8|1267029498|0||0|1
|
||||
379|GTK+ and friends|GTKtoolkit|GTK+ 2.19.6 released: http://mail.gnome.org/archives/gtk-devel-list/2010-February/msg00050.html #gtk|1266966985|0||0|0
|
||||
380|GTK+ and friends|GTKtoolkit|Did you know that #GTK+ is the official toolkit for the #LiMo software stack? http://bit.ly/cuEdHx|1266925406|0||0|0
|
||||
381|GTK+ and friends|GTKtoolkit|@lmedinas publishes a #javascript #example on how to put a status icon with #Gtk+ http://bit.ly/9py1uC Thanks a lot Luis!|1266886644|0||1|1
|
||||
381|GTK+ and friends|GTKtoolkit|@lmedinas publishes a #javascript #example on how to put an status icon with #Gtk+ http://bit.ly/9py1uC Thanks a lot Luis!|1266886644|0||1|1
|
||||
382|GTK+ and friends|GTKtoolkit|♺ @ebassi: I should really finish up the GDom API as well|1266880653|0||0|0
|
||||
383|GTK+ and friends|GTKtoolkit|♺ @ebassi: I hope to work on this for the next GIO release, and the GTK+ side for 3.0|1266880641|0||0|0
|
||||
384|GTK+ and friends|GTKtoolkit|♺ @ebassi: just updated the ApplicationClass design wiki page with the stuff @Cwiiis did for Mx - http://bit.ly/cfAOJk|1266880559|0||0|0
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
void
|
||||
modelbutton_tool_clicked (GtkButton *button)
|
||||
static void
|
||||
tool_clicked (GtkButton *button)
|
||||
{
|
||||
gboolean active;
|
||||
|
||||
@@ -40,6 +40,8 @@ do_modelbutton (GtkWidget *do_widget)
|
||||
GActionGroup *actions;
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/modelbutton/modelbutton.ui");
|
||||
gtk_builder_add_callback_symbol (builder, "tool_clicked", G_CALLBACK (tool_clicked));
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="resizable">0</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
@@ -11,46 +10,54 @@
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="margin-start">80</property>
|
||||
<property name="margin-end">80</property>
|
||||
<property name="margin-top">80</property>
|
||||
<property name="margin-bottom">80</property>
|
||||
<property name="margin">80</property>
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="popover">thing_a</property>
|
||||
<property name="label">_Color</property>
|
||||
<property name="use-underline">1</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Color</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="popover">thing_b</property>
|
||||
<property name="label">_Flavors</property>
|
||||
<property name="use-underline">1</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Flavors</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="popover">thing_c</property>
|
||||
<property name="label">_Tools</property>
|
||||
<property name="use-underline">1</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Tools</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="thing_a">
|
||||
<style>
|
||||
<class name="menu"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="action-name">win.color</property>
|
||||
<property name="action-target">'red'</property>
|
||||
<property name="text">Red</property>
|
||||
<property name="inverted">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -58,6 +65,7 @@
|
||||
<property name="action-name">win.color</property>
|
||||
<property name="action-target">'green'</property>
|
||||
<property name="text">Green</property>
|
||||
<property name="inverted">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -65,18 +73,18 @@
|
||||
<property name="action-name">win.color</property>
|
||||
<property name="action-target">'blue'</property>
|
||||
<property name="text">Blue</property>
|
||||
<property name="inverted">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="thing_b">
|
||||
<style>
|
||||
<class name="menu"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="action-name">win.chocolate</property>
|
||||
@@ -102,31 +110,30 @@
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="thing_c">
|
||||
<style>
|
||||
<class name="menu"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Hammer</property>
|
||||
<property name="role">check</property>
|
||||
<signal name="clicked" handler="modelbutton_tool_clicked"/>
|
||||
<signal name="clicked" handler="tool_clicked"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Screwdriver</property>
|
||||
<property name="role">check</property>
|
||||
<signal name="clicked" handler="modelbutton_tool_clicked"/>
|
||||
<signal name="clicked" handler="tool_clicked"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Drill</property>
|
||||
<property name="role">check</property>
|
||||
<signal name="clicked" handler="modelbutton_tool_clicked"/>
|
||||
<signal name="clicked" handler="tool_clicked"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@@ -31,7 +31,7 @@ do_overlay (GtkWidget *do_widget)
|
||||
int i, j;
|
||||
char *text;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 500, 510);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Interactive Overlay");
|
||||
|
||||
@@ -56,25 +56,23 @@ do_overlay (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_widget_set_can_target (vbox, FALSE);
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
|
||||
gtk_widget_set_can_target (vbox, FALSE);
|
||||
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (vbox, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
|
||||
|
||||
label = gtk_label_new ("<span foreground='blue' weight='ultrabold' font='40'>Numbers</span>");
|
||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
||||
gtk_widget_set_can_target (label, FALSE);
|
||||
gtk_widget_set_margin_top (label, 8);
|
||||
gtk_widget_set_margin_bottom (label, 8);
|
||||
gtk_widget_set_margin_bottom (label, 50);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
|
||||
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
|
||||
|
||||
gtk_entry_set_placeholder_text (GTK_ENTRY (entry), "Your Lucky Number");
|
||||
gtk_widget_set_margin_top (entry, 8);
|
||||
gtk_widget_set_margin_top (entry, 50);
|
||||
gtk_widget_set_margin_bottom (entry, 8);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), entry);
|
||||
|
||||
|
@@ -35,7 +35,7 @@ do_overlay2 (GtkWidget *do_widget)
|
||||
GtkTextIter start, end;
|
||||
GtkAdjustment *adjustment;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 500, 510);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Decorative Overlay");
|
||||
|
||||
|
@@ -47,7 +47,6 @@ static const gchar *pad_colors[] = {
|
||||
"orange"
|
||||
};
|
||||
|
||||
static GType drawing_area_get_type (void);
|
||||
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
|
||||
|
||||
static void drawing_area_set_color (DrawingArea *area,
|
||||
@@ -341,7 +340,7 @@ drawing_area_init (DrawingArea *area)
|
||||
area->draw_color = (GdkRGBA) { 0, 0, 0, 1 };
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
GtkWidget *
|
||||
drawing_area_new (void)
|
||||
{
|
||||
return g_object_new (drawing_area_get_type (), NULL);
|
||||
@@ -385,7 +384,7 @@ do_paint (GtkWidget *toplevel)
|
||||
{
|
||||
GtkWidget *draw_area, *headerbar, *colorbutton;
|
||||
|
||||
window = gtk_window_new ();
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
draw_area = drawing_area_new ();
|
||||
gtk_container_add (GTK_CONTAINER (window), draw_area);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user