Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a488be07a7 | |||
| 7d84cd8020 | |||
| 5fcc8b62ec | |||
| 1b61cc91bb | |||
| c65b978ac6 | |||
| 798234a776 | |||
| e75a27354c | |||
| 3b79ad1e7e | |||
| 1b57e5ac80 | |||
| 5aaa4cc452 | |||
| 56022d3a58 | |||
| 3f356d0b59 | |||
| dced4a4796 | |||
| 256d537242 | |||
| 2c2ee6a27a | |||
| eed54eac7a | |||
| 098c402a97 | |||
| b87095330a | |||
| 1037fc8387 | |||
| 3fc0df814c | |||
| ae552b3064 | |||
| 12d9d71449 | |||
| 7772e4f925 | |||
| 88055f62c5 | |||
| 4c7f009cc1 | |||
| 7c084b78f6 | |||
| e207e1ee9d | |||
| 598e14868c | |||
| ae09d17590 | |||
| d2e8c639ca | |||
| 06f0ab7e8f | |||
| 0d1fd1ce72 | |||
| d18ecca089 | |||
| 47560f8369 | |||
| 260be0300e | |||
| dca9fb5801 | |||
| f2012c6185 | |||
| cc43dee619 | |||
| 78f3d86a25 | |||
| 3869e4a818 | |||
| 7a6b489dc6 | |||
| 282c065b77 | |||
| 1f0622b27e | |||
| 0a85189e04 | |||
| 3301a1af0b | |||
| 245479f71d | |||
| d92b659d02 |
@@ -26,7 +26,7 @@ variables:
|
|||||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
|
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
|
||||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
|
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
|
||||||
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v48"
|
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v46"
|
||||||
|
|
||||||
workflow:
|
workflow:
|
||||||
rules:
|
rules:
|
||||||
@@ -418,11 +418,10 @@ reference:
|
|||||||
--buildtype=release
|
--buildtype=release
|
||||||
--force-fallback-for=gdk-pixbuf,pango
|
--force-fallback-for=gdk-pixbuf,pango
|
||||||
-Dintrospection=enabled
|
-Dintrospection=enabled
|
||||||
-Ddocumentation=true
|
|
||||||
-Dgtk_doc=true
|
-Dgtk_doc=true
|
||||||
-Dgdk-pixbuf:gtk_doc=true
|
-Dgdk-pixbuf:gtk_doc=true
|
||||||
-Dpango:gtk_doc=true
|
-Dpango:gtk_doc=true
|
||||||
-Dbuild-demos=false
|
-Ddemos=false
|
||||||
-Dbuild-examples=false
|
-Dbuild-examples=false
|
||||||
-Dbuild-tests=false
|
-Dbuild-tests=false
|
||||||
-Dbuild-testsuite=false
|
-Dbuild-testsuite=false
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ RUN dnf -y install \
|
|||||||
glib2-static \
|
glib2-static \
|
||||||
glibc-devel \
|
glibc-devel \
|
||||||
glibc-headers \
|
glibc-headers \
|
||||||
glslc \
|
|
||||||
gnupg2 \
|
gnupg2 \
|
||||||
gobject-introspection-devel \
|
gobject-introspection-devel \
|
||||||
graphene-devel \
|
graphene-devel \
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/sh
|
|
||||||
#
|
|
||||||
builddir=$1
|
|
||||||
suite=$2
|
|
||||||
unit=$3
|
|
||||||
|
|
||||||
echo "** builddir: ${builddir}"
|
|
||||||
echo "** suite: ${suite}"
|
|
||||||
echo "** unit: ${unit}"
|
|
||||||
|
|
||||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
|
||||||
|
|
||||||
weston --backend=headless-backend.so --socket=wayland-5 --idle-time=0 &
|
|
||||||
compositor=$!
|
|
||||||
|
|
||||||
export WAYLAND_DISPLAY=wayland-5
|
|
||||||
|
|
||||||
meson test -C ${builddir} \
|
|
||||||
--print-errorlogs \
|
|
||||||
--setup=wayland \
|
|
||||||
--suite=${suite} \
|
|
||||||
--no-suite=failing \
|
|
||||||
--no-suite=flaky \
|
|
||||||
--no-suite=wayland_failing \
|
|
||||||
--no-suite=gsk-compare-broadway \
|
|
||||||
--verbose \
|
|
||||||
"${unit}"
|
|
||||||
|
|
||||||
exit_code=$?
|
|
||||||
kill ${compositor}
|
|
||||||
|
|
||||||
exit ${exit_code}
|
|
||||||
@@ -32,8 +32,7 @@ pacman --noconfirm -S --needed \
|
|||||||
mingw-w64-$MSYS2_ARCH-fribidi \
|
mingw-w64-$MSYS2_ARCH-fribidi \
|
||||||
mingw-w64-$MSYS2_ARCH-gst-plugins-bad-libs \
|
mingw-w64-$MSYS2_ARCH-gst-plugins-bad-libs \
|
||||||
mingw-w64-$MSYS2_ARCH-shared-mime-info \
|
mingw-w64-$MSYS2_ARCH-shared-mime-info \
|
||||||
mingw-w64-$MSYS2_ARCH-python-gobject \
|
mingw-w64-$MSYS2_ARCH-python-gobject
|
||||||
mingw-w64-$MSYS2_ARCH-shaderc
|
|
||||||
|
|
||||||
mkdir -p _ccache
|
mkdir -p _ccache
|
||||||
export CCACHE_BASEDIR="$(pwd)"
|
export CCACHE_BASEDIR="$(pwd)"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Peter Mattis <petm@xcf.berkeley.edu>
|
|||||||
Spencer Kimball <spencer@xcf.berkeley.edu>
|
Spencer Kimball <spencer@xcf.berkeley.edu>
|
||||||
Josh MacDonald <jmacd@xcf.berkeley.edu>
|
Josh MacDonald <jmacd@xcf.berkeley.edu>
|
||||||
|
|
||||||
The team that build GTK 2 (in alphabetical order)
|
The Team that build GTK 2 (in alphabetical order)
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
Shawn T. Amundson <amundson@gtk.org>
|
Shawn T. Amundson <amundson@gtk.org>
|
||||||
Jerome Bolliet <bolliet@gtk.org>
|
Jerome Bolliet <bolliet@gtk.org>
|
||||||
@@ -28,8 +28,9 @@ Jay Painter <jpaint@gtk.org>
|
|||||||
Manish Singh <manish@gtk.org>
|
Manish Singh <manish@gtk.org>
|
||||||
Owen Taylor <otaylor@gtk.org>
|
Owen Taylor <otaylor@gtk.org>
|
||||||
|
|
||||||
The team that built GTK 3
|
The current team (GTK 3 and 4)
|
||||||
-------------------------
|
------------------------------
|
||||||
|
|
||||||
Jonas Ådahl <jadahl@gmail.com>
|
Jonas Ådahl <jadahl@gmail.com>
|
||||||
Tim Bäder <mail@baedert.org>
|
Tim Bäder <mail@baedert.org>
|
||||||
Emmanuele Bassi <ebassi@gnome.org>
|
Emmanuele Bassi <ebassi@gnome.org>
|
||||||
@@ -39,16 +40,6 @@ Carlos Garnacho <mrgarnacho@gmail.com>
|
|||||||
Alexander Larsson <alexl@redhat.com>
|
Alexander Larsson <alexl@redhat.com>
|
||||||
Benjamin Otte <otte@gnome.org>
|
Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
The current team (GTK 4)
|
|
||||||
------------------------
|
|
||||||
Jonas Ådahl <jadahl@gmail.com>
|
|
||||||
Emmanuele Bassi <ebassi@gnome.org>
|
|
||||||
Christian Hergert <chergert@gnome.org>
|
|
||||||
Chun-wei Fan <fanchunwei@src.gnome.org>
|
|
||||||
Matthias Clasen <mclasen@redhat.com>
|
|
||||||
Carlos Garnacho <mrgarnacho@gmail.com>
|
|
||||||
Benjamin Otte <otte@gnome.org>
|
|
||||||
|
|
||||||
|
|
||||||
There are many others who have contributed patches; we thank them,
|
There are many others who have contributed patches; we thank them,
|
||||||
GTK is much better because of them.
|
GTK is much better because of them.
|
||||||
@@ -58,15 +49,35 @@ Over time, GTK has incorporated some pieces of software which
|
|||||||
started as independent projects. We list the original authors here:
|
started as independent projects. We list the original authors here:
|
||||||
|
|
||||||
|
|
||||||
|
MS-Windows theme engine
|
||||||
|
-----------------------
|
||||||
|
Raymond Penners
|
||||||
|
Dom Lachowicz
|
||||||
|
|
||||||
|
|
||||||
|
Pixbuf theme engine
|
||||||
|
-------------------
|
||||||
|
Owen Taylor
|
||||||
|
|
||||||
|
|
||||||
IME input method
|
IME input method
|
||||||
----------------
|
----------------
|
||||||
Takuro Ashie
|
Takuro Ashie
|
||||||
Kazuki IWAMOTO
|
Kazuki IWAMOTO
|
||||||
|
|
||||||
MacOS backend
|
|
||||||
-------------
|
Mac OS X backend
|
||||||
|
----------------
|
||||||
Anders Carlsson
|
Anders Carlsson
|
||||||
|
|
||||||
GtkInspector (originally gtkparasite)
|
|
||||||
-------------------------------------
|
DirectFB backend
|
||||||
|
----------------
|
||||||
|
Denis Oliver Kropp
|
||||||
|
Sven Neumann
|
||||||
|
Mike Emmel
|
||||||
|
|
||||||
|
|
||||||
|
gtkparasite
|
||||||
|
-----------
|
||||||
Christian Hammond
|
Christian Hammond
|
||||||
|
|||||||
@@ -1,139 +1,4 @@
|
|||||||
Overview of Changes in 4.13.0, xx-xx-xxxx
|
Overview of Changes in 4.11.4, xx-xx-xxxx
|
||||||
=========================================
|
|
||||||
|
|
||||||
Overview of Changes in 4.12.0, 05-08-2023
|
|
||||||
=========================================
|
|
||||||
|
|
||||||
* List widgets:
|
|
||||||
- Add scroll_to APIs
|
|
||||||
|
|
||||||
* GtkFileLauncher:
|
|
||||||
- Add an always-ask property
|
|
||||||
|
|
||||||
* GtkTextView:
|
|
||||||
- Make backspace behavior match GtkEntry
|
|
||||||
|
|
||||||
* gsk:
|
|
||||||
- Fix handling of luminance in mask nodes
|
|
||||||
|
|
||||||
* Text rendering:
|
|
||||||
- Automate the setting of gtk-hint-font-metrics from the
|
|
||||||
scale factor. This improves font rendering in flatpaks
|
|
||||||
|
|
||||||
* Wayland:
|
|
||||||
- Fix behavior of stylus buttons
|
|
||||||
- Support suspended window state
|
|
||||||
|
|
||||||
* Vulkan:
|
|
||||||
- Many improvements
|
|
||||||
|
|
||||||
* Tools:
|
|
||||||
- Add gtk4-rendernode-tool
|
|
||||||
|
|
||||||
* Debugging:
|
|
||||||
- Drop the GTK_DEBUG_TOUCHSCREEN flag
|
|
||||||
|
|
||||||
* Build:
|
|
||||||
- Some build options have been renamed:
|
|
||||||
gtk_doc -> documentation
|
|
||||||
update_screenshots -> screenshots
|
|
||||||
The old names still work
|
|
||||||
|
|
||||||
* Translation updates:
|
|
||||||
Georgian
|
|
||||||
Greek
|
|
||||||
Hebrew
|
|
||||||
Persian
|
|
||||||
Vietnamese
|
|
||||||
|
|
||||||
* Contributors:
|
|
||||||
Aleksandr Melman
|
|
||||||
Alexander Mikhaylenko
|
|
||||||
Alexander Shopov
|
|
||||||
Alexandre Franke
|
|
||||||
Alice Mikhaylenko
|
|
||||||
António Fernandes
|
|
||||||
Arjan Molenaar
|
|
||||||
Asier Sarasua Garmendia
|
|
||||||
Balázs Meskó
|
|
||||||
Balázs Úr
|
|
||||||
Barnabás Pőcze
|
|
||||||
Bart Jacobs
|
|
||||||
Benjamin Otte
|
|
||||||
Bilal Elmoussaoui
|
|
||||||
Boyuan Yang
|
|
||||||
Bruce Cowan
|
|
||||||
Calvin Walton
|
|
||||||
Cam Cook
|
|
||||||
Chris Mayo
|
|
||||||
Christian Hergert
|
|
||||||
Christopher Davis
|
|
||||||
Chun-wei Fan
|
|
||||||
Corey Berla
|
|
||||||
Danial Behzadi
|
|
||||||
Daniel Boles
|
|
||||||
Daniel Rusek
|
|
||||||
Efstathios Iosifidis
|
|
||||||
Ekaterine Papava
|
|
||||||
Emin Tufan Çetin
|
|
||||||
Emmanuele Bassi
|
|
||||||
Erik Schilling
|
|
||||||
Fabio Tomat
|
|
||||||
FeRD (Frank Dana)
|
|
||||||
Fina Wilke
|
|
||||||
FineFindus
|
|
||||||
Fran Dieguez
|
|
||||||
G.Willems
|
|
||||||
Georges Basile Stavracas Neto
|
|
||||||
Guillaume Bernard
|
|
||||||
Hugo Carvalho
|
|
||||||
Ivan Molodetskikh
|
|
||||||
Jason Francis
|
|
||||||
Jonas Ådahl
|
|
||||||
Jordan Petridis
|
|
||||||
Jordi Mas
|
|
||||||
José Expósito
|
|
||||||
José Roberto de Souza
|
|
||||||
Khalid Abu Shawarib
|
|
||||||
Kévin Commaille
|
|
||||||
Leônidas Araújo
|
|
||||||
Luca Bacci
|
|
||||||
Ludovico de Nittis
|
|
||||||
Lukáš Tyrychtr
|
|
||||||
Marc-André Lureau
|
|
||||||
Marco Trevisan (Treviño)
|
|
||||||
Matt Turner
|
|
||||||
Matthias Clasen
|
|
||||||
Maximiliano Sandoval R
|
|
||||||
Michael Catanzaro
|
|
||||||
Michel Dänzer
|
|
||||||
Mohammed Sadiq
|
|
||||||
Nathan Follens
|
|
||||||
Nelson Benítez León
|
|
||||||
Ngọc Quân Trần
|
|
||||||
Niels De Graef
|
|
||||||
Olivier Crête
|
|
||||||
Patrick Griffis
|
|
||||||
Piotr Drąg
|
|
||||||
Sabri Ünal
|
|
||||||
Sebastian Keller
|
|
||||||
Sophie Herold
|
|
||||||
Sébastien Le Roux
|
|
||||||
Takao Fujiwara
|
|
||||||
Thomas Lange
|
|
||||||
Yiğit Burak
|
|
||||||
Yosef Or Boczko
|
|
||||||
Yuri Chornoivan
|
|
||||||
Zander Brown
|
|
||||||
al_SeveR
|
|
||||||
dgsasha
|
|
||||||
sumibi-yakitori
|
|
||||||
tszymanski
|
|
||||||
velsinki
|
|
||||||
Алексей Шилин
|
|
||||||
Арсений Засыпкин
|
|
||||||
|
|
||||||
Overview of Changes in 4.11.4, 03-07-2023
|
|
||||||
=========================================
|
=========================================
|
||||||
|
|
||||||
* GtkFileChooser:
|
* GtkFileChooser:
|
||||||
@@ -161,9 +26,6 @@ Overview of Changes in 4.11.4, 03-07-2023
|
|||||||
* GtkDropDown:
|
* GtkDropDown:
|
||||||
- Update on expression changes
|
- Update on expression changes
|
||||||
|
|
||||||
* GtkMapListModel:
|
|
||||||
- Implement GtkSectionModel
|
|
||||||
|
|
||||||
* Accessibility:
|
* Accessibility:
|
||||||
- Improvements all over the place: GtkButton, GtkPasswordEntry,
|
- Improvements all over the place: GtkButton, GtkPasswordEntry,
|
||||||
GtkFontChooserDialog, GtkColorChooserDialog, GtkShortcutsWindow,
|
GtkFontChooserDialog, GtkColorChooserDialog, GtkShortcutsWindow,
|
||||||
@@ -210,7 +72,6 @@ Overview of Changes in 4.11.4, 03-07-2023
|
|||||||
* Build:
|
* Build:
|
||||||
- Require GLib 2.76
|
- Require GLib 2.76
|
||||||
- Make asan builds work again
|
- Make asan builds work again
|
||||||
- Fix the build if ld is not ld.bdf
|
|
||||||
|
|
||||||
* Translation updates:
|
* Translation updates:
|
||||||
Brazilian Portuguese
|
Brazilian Portuguese
|
||||||
|
|||||||
@@ -67,13 +67,6 @@ building for:
|
|||||||
- [Graphene](https://github.com/ebassi/graphene)
|
- [Graphene](https://github.com/ebassi/graphene)
|
||||||
- [Xkb-common](https://github.com/xkbcommon/libxkbcommon)
|
- [Xkb-common](https://github.com/xkbcommon/libxkbcommon)
|
||||||
|
|
||||||
If you are building the Wayland backend, you will also need:
|
|
||||||
|
|
||||||
- Wayland-client
|
|
||||||
- Wayland-protocols
|
|
||||||
- Wayland-cursor
|
|
||||||
- Wayland-EGL
|
|
||||||
|
|
||||||
If you are building the X11 backend, you will also need:
|
If you are building the X11 backend, you will also need:
|
||||||
|
|
||||||
- Xlib, and the following X extensions:
|
- Xlib, and the following X extensions:
|
||||||
@@ -86,24 +79,32 @@ If you are building the X11 backend, you will also need:
|
|||||||
- xdamage
|
- xdamage
|
||||||
- xcomposite
|
- xcomposite
|
||||||
|
|
||||||
|
If you are building the Wayland backend, you will also need:
|
||||||
|
|
||||||
|
- Wayland-client
|
||||||
|
- Wayland-protocols
|
||||||
|
- Wayland-cursor
|
||||||
|
- Wayland-EGL
|
||||||
|
|
||||||
Once you have all the necessary dependencies, you can build GTK by using
|
Once you have all the necessary dependencies, you can build GTK by using
|
||||||
Meson:
|
Meson:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ meson setup _build
|
$ meson _build .
|
||||||
$ meson compile -C_build
|
$ cd _build
|
||||||
|
$ ninja
|
||||||
```
|
```
|
||||||
|
|
||||||
You can run the test suite using:
|
You can run the test suite using:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ meson test -C_build
|
$ meson test
|
||||||
```
|
```
|
||||||
|
|
||||||
And, finally, you can install GTK using:
|
And, finally, you can install GTK using:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo meson install -C_build
|
$ sudo ninja install
|
||||||
```
|
```
|
||||||
|
|
||||||
Complete information about installing GTK and related libraries
|
Complete information about installing GTK and related libraries
|
||||||
|
|||||||
@@ -483,8 +483,6 @@ constraint_editor_window_class_init (ConstraintEditorWindowClass *class)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||||
|
|
||||||
g_type_ensure (CONSTRAINT_VIEW_TYPE);
|
|
||||||
|
|
||||||
object_class->dispose = constraint_editor_window_dispose;
|
object_class->dispose = constraint_editor_window_dispose;
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class,
|
gtk_widget_class_set_template_from_resource (widget_class,
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "constraint-editor.h"
|
#include "constraint-editor.h"
|
||||||
#include "constraint-view.h"
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
struct _ConstraintEditor
|
struct _ConstraintEditor
|
||||||
{
|
{
|
||||||
@@ -65,7 +66,7 @@ static const char *
|
|||||||
get_target_name (GtkConstraintTarget *target)
|
get_target_name (GtkConstraintTarget *target)
|
||||||
{
|
{
|
||||||
if (target == NULL)
|
if (target == NULL)
|
||||||
return "Super";
|
return "super";
|
||||||
else if (GTK_IS_WIDGET (target))
|
else if (GTK_IS_WIDGET (target))
|
||||||
return gtk_widget_get_name (GTK_WIDGET (target));
|
return gtk_widget_get_name (GTK_WIDGET (target));
|
||||||
else if (GTK_IS_CONSTRAINT_GUIDE (target))
|
else if (GTK_IS_CONSTRAINT_GUIDE (target))
|
||||||
@@ -79,29 +80,62 @@ constraint_target_combo (GListModel *model,
|
|||||||
GtkWidget *combo,
|
GtkWidget *combo,
|
||||||
gboolean is_source)
|
gboolean is_source)
|
||||||
{
|
{
|
||||||
GtkStringList *targets;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
targets = gtk_string_list_new (NULL);
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "super", "Super");
|
||||||
|
|
||||||
gtk_string_list_append (targets, "Super");
|
|
||||||
|
|
||||||
if (model)
|
if (model)
|
||||||
{
|
{
|
||||||
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
||||||
{
|
{
|
||||||
GObject *item = g_list_model_get_object (model, i);
|
GObject *item = g_list_model_get_object (model, i);
|
||||||
|
const char *name;
|
||||||
|
|
||||||
if (GTK_IS_CONSTRAINT (item))
|
if (GTK_IS_CONSTRAINT (item))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gtk_string_list_append (targets, get_target_name (GTK_CONSTRAINT_TARGET (item)));
|
name = get_target_name (GTK_CONSTRAINT_TARGET (item));
|
||||||
|
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), name, name);
|
||||||
g_object_unref (item);
|
g_object_unref (item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gtk_drop_down_set_model (GTK_DROP_DOWN (combo), G_LIST_MODEL (targets));
|
static void
|
||||||
g_object_unref (targets);
|
constraint_attribute_combo (GtkWidget *combo,
|
||||||
|
gboolean is_source)
|
||||||
|
{
|
||||||
|
if (is_source)
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "none", "None");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "top", "Top");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "bottom", "Bottom");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "width", "Width");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "height", "Height");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center-x", "Center X");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center-y", "Center Y");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "baseline", "Baseline");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
constraint_relation_combo (GtkWidget *combo)
|
||||||
|
{
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "le", "≤");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "eq", "=");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "ge", "≥");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
constraint_strength_combo (GtkWidget *combo)
|
||||||
|
{
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "weak", "Weak");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "medium", "Medium");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "strong", "Strong");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "required", "Required");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
@@ -113,7 +147,7 @@ get_target (GListModel *model,
|
|||||||
if (id == NULL)
|
if (id == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (strcmp ("Super", id) == 0)
|
if (strcmp ("super", id) == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
||||||
@@ -137,65 +171,16 @@ get_target (GListModel *model,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
select_target (GtkDropDown *combo,
|
|
||||||
const char *target_name)
|
|
||||||
{
|
|
||||||
GListModel *model = gtk_drop_down_get_model (combo);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < g_list_model_get_n_items (model); i++)
|
|
||||||
{
|
|
||||||
GtkStringObject *s = g_list_model_get_item (model, i);
|
|
||||||
|
|
||||||
g_object_unref (s);
|
|
||||||
if (strcmp (target_name, gtk_string_object_get_string (s)) == 0)
|
|
||||||
{
|
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkConstraintAttribute
|
static GtkConstraintAttribute
|
||||||
get_attr (unsigned int id)
|
get_target_attr (const char *id)
|
||||||
{
|
{
|
||||||
switch (id)
|
GtkConstraintAttribute attr;
|
||||||
{
|
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_ATTRIBUTE);
|
||||||
case 0: return GTK_CONSTRAINT_ATTRIBUTE_NONE;
|
GEnumValue *value = g_enum_get_value_by_nick (class, id);
|
||||||
case 1: return GTK_CONSTRAINT_ATTRIBUTE_LEFT;
|
attr = value->value;
|
||||||
case 2: return GTK_CONSTRAINT_ATTRIBUTE_RIGHT;
|
g_type_class_unref (class);
|
||||||
case 3: return GTK_CONSTRAINT_ATTRIBUTE_TOP;
|
|
||||||
case 4: return GTK_CONSTRAINT_ATTRIBUTE_BOTTOM;
|
|
||||||
case 5: return GTK_CONSTRAINT_ATTRIBUTE_START;
|
|
||||||
case 6: return GTK_CONSTRAINT_ATTRIBUTE_END;
|
|
||||||
case 7: return GTK_CONSTRAINT_ATTRIBUTE_WIDTH;
|
|
||||||
case 8: return GTK_CONSTRAINT_ATTRIBUTE_HEIGHT;
|
|
||||||
case 9: return GTK_CONSTRAINT_ATTRIBUTE_CENTER_X;
|
|
||||||
case 10: return GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y;
|
|
||||||
case 11: return GTK_CONSTRAINT_ATTRIBUTE_BASELINE;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
return attr;
|
||||||
get_attr_id (GtkConstraintAttribute attr)
|
|
||||||
{
|
|
||||||
switch (attr)
|
|
||||||
{
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_NONE: return 0;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_LEFT: return 1;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_RIGHT: return 2;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_TOP: return 3;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_BOTTOM: return 4;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_START: return 5;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_END: return 6;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_WIDTH: return 7;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_HEIGHT: return 8;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_CENTER_X: return 9;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y: return 10;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_BASELINE: return 11;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -210,27 +195,15 @@ get_attr_nick (GtkConstraintAttribute attr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GtkConstraintRelation
|
static GtkConstraintRelation
|
||||||
get_relation (unsigned int id)
|
get_relation (const char *id)
|
||||||
{
|
{
|
||||||
switch (id)
|
GtkConstraintRelation relation;
|
||||||
{
|
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_RELATION);
|
||||||
case 0: return GTK_CONSTRAINT_RELATION_LE;
|
GEnumValue *value = g_enum_get_value_by_nick (class, id);
|
||||||
case 1: return GTK_CONSTRAINT_RELATION_EQ;
|
relation = value->value;
|
||||||
case 2: return GTK_CONSTRAINT_RELATION_GE;
|
g_type_class_unref (class);
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
return relation;
|
||||||
get_relation_id (GtkConstraintRelation relation)
|
|
||||||
{
|
|
||||||
switch (relation)
|
|
||||||
{
|
|
||||||
case GTK_CONSTRAINT_RELATION_LE: return 0;
|
|
||||||
case GTK_CONSTRAINT_RELATION_EQ: return 1;
|
|
||||||
case GTK_CONSTRAINT_RELATION_GE: return 2;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -261,29 +234,15 @@ get_relation_display_name (GtkConstraintRelation relation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GtkConstraintStrength
|
static GtkConstraintStrength
|
||||||
get_strength (unsigned int id)
|
get_strength (const char *id)
|
||||||
{
|
|
||||||
switch (id)
|
|
||||||
{
|
|
||||||
case 0: return GTK_CONSTRAINT_STRENGTH_WEAK;
|
|
||||||
case 1: return GTK_CONSTRAINT_STRENGTH_MEDIUM;
|
|
||||||
case 2: return GTK_CONSTRAINT_STRENGTH_STRONG;
|
|
||||||
case 3: return GTK_CONSTRAINT_STRENGTH_REQUIRED;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
|
||||||
get_strength_id (GtkConstraintStrength strength)
|
|
||||||
{
|
{
|
||||||
switch (strength)
|
GtkConstraintStrength strength;
|
||||||
{
|
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
|
||||||
case GTK_CONSTRAINT_STRENGTH_WEAK: return 0;
|
GEnumValue *value = g_enum_get_value_by_nick (class, id);
|
||||||
case GTK_CONSTRAINT_STRENGTH_MEDIUM: return 1;
|
strength = value->value;
|
||||||
case GTK_CONSTRAINT_STRENGTH_STRONG: return 2;
|
g_type_class_unref (class);
|
||||||
case GTK_CONSTRAINT_STRENGTH_REQUIRED: return 3;
|
|
||||||
default: g_assert_not_reached ();
|
return strength;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -335,7 +294,7 @@ static void
|
|||||||
create_constraint (GtkButton *button,
|
create_constraint (GtkButton *button,
|
||||||
ConstraintEditor *editor)
|
ConstraintEditor *editor)
|
||||||
{
|
{
|
||||||
gpointer obj;
|
const char *id;
|
||||||
gpointer target;
|
gpointer target;
|
||||||
GtkConstraintAttribute target_attr;
|
GtkConstraintAttribute target_attr;
|
||||||
gpointer source;
|
gpointer source;
|
||||||
@@ -346,27 +305,25 @@ create_constraint (GtkButton *button,
|
|||||||
int strength;
|
int strength;
|
||||||
GtkConstraint *constraint;
|
GtkConstraint *constraint;
|
||||||
|
|
||||||
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
|
||||||
if (obj)
|
target = get_target (editor->model, id);
|
||||||
target = get_target (editor->model, gtk_string_object_get_string (GTK_STRING_OBJECT (obj)));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target_attr));
|
||||||
else
|
target_attr = get_target_attr (id);
|
||||||
target = NULL;
|
|
||||||
target_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->target_attr)));
|
|
||||||
|
|
||||||
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
|
||||||
if (obj)
|
source = get_target (editor->model, id);
|
||||||
source = get_target (editor->model, gtk_string_object_get_string (GTK_STRING_OBJECT (obj)));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||||
else
|
source_attr = get_target_attr (id);
|
||||||
source = NULL;
|
|
||||||
source_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN(editor->source_attr)));
|
|
||||||
|
|
||||||
relation = get_relation (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->relation)));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->relation));
|
||||||
|
relation = get_relation (id);
|
||||||
|
|
||||||
multiplier = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->multiplier)), NULL);
|
multiplier = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->multiplier)), NULL);
|
||||||
|
|
||||||
constant = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->constant)), NULL);
|
constant = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->constant)), NULL);
|
||||||
|
|
||||||
strength = get_strength (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->strength)));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->strength));
|
||||||
|
strength = get_strength (id);
|
||||||
|
|
||||||
constraint = gtk_constraint_new (target, target_attr,
|
constraint = gtk_constraint_new (target, target_attr,
|
||||||
relation,
|
relation,
|
||||||
@@ -381,9 +338,12 @@ create_constraint (GtkButton *button,
|
|||||||
static void
|
static void
|
||||||
source_attr_changed (ConstraintEditor *editor)
|
source_attr_changed (ConstraintEditor *editor)
|
||||||
{
|
{
|
||||||
if (get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr))) == GTK_CONSTRAINT_ATTRIBUTE_NONE)
|
const char *id;
|
||||||
|
|
||||||
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||||
|
if (strcmp (id, "none") == 0)
|
||||||
{
|
{
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source), GTK_INVALID_LIST_POSITION);
|
gtk_combo_box_set_active (GTK_COMBO_BOX (editor->source), -1);
|
||||||
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "");
|
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "");
|
||||||
gtk_widget_set_sensitive (editor->source, FALSE);
|
gtk_widget_set_sensitive (editor->source, FALSE);
|
||||||
gtk_widget_set_sensitive (editor->multiplier, FALSE);
|
gtk_widget_set_sensitive (editor->multiplier, FALSE);
|
||||||
@@ -449,7 +409,7 @@ update_preview (ConstraintEditor *editor)
|
|||||||
GString *str;
|
GString *str;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *attr;
|
const char *attr;
|
||||||
const char *relation;
|
char *relation;
|
||||||
const char *multiplier;
|
const char *multiplier;
|
||||||
const char *constant;
|
const char *constant;
|
||||||
double c, m;
|
double c, m;
|
||||||
@@ -459,22 +419,23 @@ update_preview (ConstraintEditor *editor)
|
|||||||
|
|
||||||
str = g_string_new ("");
|
str = g_string_new ("");
|
||||||
|
|
||||||
name = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target))));
|
name = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
|
||||||
attr = get_attr_nick (get_attr (gtk_drop_down_get_selected ((GTK_DROP_DOWN (editor->target_attr)))));
|
attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target_attr));
|
||||||
relation = get_relation_nick (get_relation (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->relation))));
|
relation = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (editor->relation));
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "[ ]";
|
name = "[ ]";
|
||||||
|
|
||||||
g_string_append_printf (str, "%s.%s %s ", name, attr, relation);
|
g_string_append_printf (str, "%s.%s %s ", name, attr, relation);
|
||||||
|
g_free (relation);
|
||||||
|
|
||||||
constant = gtk_editable_get_text (GTK_EDITABLE (editor->constant));
|
constant = gtk_editable_get_text (GTK_EDITABLE (editor->constant));
|
||||||
c = g_ascii_strtod (constant, NULL);
|
c = g_ascii_strtod (constant, NULL);
|
||||||
|
|
||||||
attr = get_attr_nick (get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr))));
|
attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||||
if (strcmp (attr, "none") != 0)
|
if (strcmp (attr, "none") != 0)
|
||||||
{
|
{
|
||||||
name = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source))));
|
name = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
|
||||||
multiplier = gtk_editable_get_text (GTK_EDITABLE (editor->multiplier));
|
multiplier = gtk_editable_get_text (GTK_EDITABLE (editor->multiplier));
|
||||||
m = g_ascii_strtod (multiplier, NULL);
|
m = g_ascii_strtod (multiplier, NULL);
|
||||||
|
|
||||||
@@ -502,18 +463,12 @@ update_preview (ConstraintEditor *editor)
|
|||||||
static void
|
static void
|
||||||
update_button (ConstraintEditor *editor)
|
update_button (ConstraintEditor *editor)
|
||||||
{
|
{
|
||||||
gpointer obj;
|
const char *target = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
|
||||||
const char *target;
|
const char *source = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
|
||||||
const char *source;
|
const char *source_attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||||
GtkConstraintAttribute source_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr)));
|
|
||||||
|
|
||||||
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target));
|
if (target &&
|
||||||
target = obj ? gtk_string_object_get_string (GTK_STRING_OBJECT (obj)) : NULL;
|
(source || (source_attr && get_target_attr (source_attr) == GTK_CONSTRAINT_ATTRIBUTE_NONE)))
|
||||||
|
|
||||||
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source));
|
|
||||||
source = obj ? gtk_string_object_get_string (GTK_STRING_OBJECT (obj)) : NULL;
|
|
||||||
|
|
||||||
if (target && (source || (source_attr == GTK_CONSTRAINT_ATTRIBUTE_NONE)))
|
|
||||||
gtk_widget_set_sensitive (editor->button, TRUE);
|
gtk_widget_set_sensitive (editor->button, TRUE);
|
||||||
else
|
else
|
||||||
gtk_widget_set_sensitive (editor->button, FALSE);
|
gtk_widget_set_sensitive (editor->button, FALSE);
|
||||||
@@ -531,7 +486,12 @@ constraint_editor_constructed (GObject *object)
|
|||||||
ConstraintEditor *editor = CONSTRAINT_EDITOR (object);
|
ConstraintEditor *editor = CONSTRAINT_EDITOR (object);
|
||||||
|
|
||||||
constraint_target_combo (editor->model, editor->target, FALSE);
|
constraint_target_combo (editor->model, editor->target, FALSE);
|
||||||
|
constraint_attribute_combo (editor->target_attr, FALSE);
|
||||||
|
constraint_relation_combo (editor->relation);
|
||||||
constraint_target_combo (editor->model, editor->source, TRUE);
|
constraint_target_combo (editor->model, editor->source, TRUE);
|
||||||
|
constraint_attribute_combo (editor->source_attr, TRUE);
|
||||||
|
|
||||||
|
constraint_strength_combo (editor->strength);
|
||||||
|
|
||||||
if (editor->constraint)
|
if (editor->constraint)
|
||||||
{
|
{
|
||||||
@@ -539,24 +499,30 @@ constraint_editor_constructed (GObject *object)
|
|||||||
GtkConstraintAttribute attr;
|
GtkConstraintAttribute attr;
|
||||||
GtkConstraintRelation relation;
|
GtkConstraintRelation relation;
|
||||||
GtkConstraintStrength strength;
|
GtkConstraintStrength strength;
|
||||||
|
const char *nick;
|
||||||
char *val;
|
char *val;
|
||||||
double multiplier;
|
double multiplier;
|
||||||
double constant;
|
double constant;
|
||||||
|
|
||||||
target = gtk_constraint_get_target (editor->constraint);
|
target = gtk_constraint_get_target (editor->constraint);
|
||||||
select_target (GTK_DROP_DOWN (editor->target), get_target_name (target));
|
nick = get_target_name (target);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target), nick);
|
||||||
|
|
||||||
attr = gtk_constraint_get_target_attribute (editor->constraint);
|
attr = gtk_constraint_get_target_attribute (editor->constraint);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->target_attr), get_attr_id (attr));
|
nick = get_attr_nick (attr);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target_attr), nick);
|
||||||
|
|
||||||
target = gtk_constraint_get_source (editor->constraint);
|
target = gtk_constraint_get_source (editor->constraint);
|
||||||
select_target (GTK_DROP_DOWN (editor->source), get_target_name (target));
|
nick = get_target_name (target);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source), nick);
|
||||||
|
|
||||||
attr = gtk_constraint_get_source_attribute (editor->constraint);
|
attr = gtk_constraint_get_source_attribute (editor->constraint);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source_attr), get_attr_id (attr));
|
nick = get_attr_nick (attr);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source_attr), nick);
|
||||||
|
|
||||||
relation = gtk_constraint_get_relation (editor->constraint);
|
relation = gtk_constraint_get_relation (editor->constraint);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->relation), get_relation_id (relation));
|
nick = get_relation_nick (relation);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->relation), nick);
|
||||||
|
|
||||||
multiplier = gtk_constraint_get_multiplier (editor->constraint);
|
multiplier = gtk_constraint_get_multiplier (editor->constraint);
|
||||||
val = g_strdup_printf ("%g", multiplier);
|
val = g_strdup_printf ("%g", multiplier);
|
||||||
@@ -569,16 +535,17 @@ constraint_editor_constructed (GObject *object)
|
|||||||
g_free (val);
|
g_free (val);
|
||||||
|
|
||||||
strength = gtk_constraint_get_strength (editor->constraint);
|
strength = gtk_constraint_get_strength (editor->constraint);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (strength));
|
nick = get_strength_nick (strength);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), nick);
|
||||||
|
|
||||||
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
|
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->target_attr), get_attr_id (GTK_CONSTRAINT_ATTRIBUTE_LEFT));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target_attr), "left");
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source_attr), get_attr_id (GTK_CONSTRAINT_ATTRIBUTE_LEFT));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source_attr), "left");
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->relation), get_relation_id (GTK_CONSTRAINT_RELATION_EQ));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->relation), "eq");
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), "required");
|
||||||
|
|
||||||
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1.0");
|
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1.0");
|
||||||
gtk_editable_set_text (GTK_EDITABLE (editor->constant), "0.0");
|
gtk_editable_set_text (GTK_EDITABLE (editor->constant), "0.0");
|
||||||
|
|||||||
@@ -1,21 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<object class="GtkStringList" id="targets">
|
|
||||||
<items>
|
|
||||||
<item>None</item>
|
|
||||||
<item>Left</item>
|
|
||||||
<item>Right</item>
|
|
||||||
<item>Top</item>
|
|
||||||
<item>Bottom</item>
|
|
||||||
<item>Start</item>
|
|
||||||
<item>End</item>
|
|
||||||
<item>Width</item>
|
|
||||||
<item>Height</item>
|
|
||||||
<item>Center X</item>
|
|
||||||
<item>Center Y</item>
|
|
||||||
<item>Baseline</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
<template class="ConstraintEditor" parent="GtkWidget">
|
<template class="ConstraintEditor" parent="GtkWidget">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="grid">
|
<object class="GtkGrid" id="grid">
|
||||||
@@ -35,9 +19,9 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="target">
|
<object class="GtkComboBoxText" id="target">
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_button" swapped="yes"/>
|
<signal name="changed" handler="update_button" swapped="yes"/>
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
@@ -45,9 +29,8 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="target_attr">
|
<object class="GtkComboBoxText" id="target_attr">
|
||||||
<property name="model">targets</property>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">2</property>
|
<property name="column">2</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
@@ -64,17 +47,8 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="relation">
|
<object class="GtkComboBoxText" id="relation">
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<property name="model">
|
|
||||||
<object class="GtkStringList">
|
|
||||||
<items>
|
|
||||||
<item>≤</item>
|
|
||||||
<item>=</item>
|
|
||||||
<item>≥</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">2</property>
|
<property name="row">2</property>
|
||||||
@@ -91,9 +65,9 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="source">
|
<object class="GtkComboBoxText" id="source">
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_button" swapped="yes"/>
|
<signal name="changed" handler="update_button" swapped="yes"/>
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">3</property>
|
<property name="row">3</property>
|
||||||
@@ -101,11 +75,10 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="source_attr">
|
<object class="GtkComboBoxText" id="source_attr">
|
||||||
<property name="model">targets</property>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
<signal name="changed" handler="source_attr_changed" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="source_attr_changed" swapped="yes"/>
|
<signal name="changed" handler="update_button" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_button" swapped="yes"/>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">2</property>
|
<property name="column">2</property>
|
||||||
<property name="row">3</property>
|
<property name="row">3</property>
|
||||||
@@ -158,17 +131,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="strength">
|
<object class="GtkComboBoxText" id="strength">
|
||||||
<property name="model">
|
|
||||||
<object class="GtkStringList">
|
|
||||||
<items>
|
|
||||||
<item>Weak</item>
|
|
||||||
<item>Medium</item>
|
|
||||||
<item>Strong</item>
|
|
||||||
<item>Required</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">6</property>
|
<property name="row">6</property>
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "guide-editor.h"
|
#include "guide-editor.h"
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
struct _GuideEditor
|
struct _GuideEditor
|
||||||
{
|
{
|
||||||
GtkWidget parent_instance;
|
GtkWidget parent_instance;
|
||||||
@@ -57,30 +59,25 @@ static guint signals[LAST_SIGNAL];
|
|||||||
|
|
||||||
G_DEFINE_TYPE(GuideEditor, guide_editor, GTK_TYPE_WIDGET);
|
G_DEFINE_TYPE(GuideEditor, guide_editor, GTK_TYPE_WIDGET);
|
||||||
|
|
||||||
static GtkConstraintStrength
|
static void
|
||||||
get_strength (unsigned int id)
|
guide_strength_combo (GtkWidget *combo)
|
||||||
{
|
{
|
||||||
switch (id)
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "weak", "Weak");
|
||||||
{
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "medium", "Medium");
|
||||||
case 0: return GTK_CONSTRAINT_STRENGTH_WEAK;
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "strong", "Strong");
|
||||||
case 1: return GTK_CONSTRAINT_STRENGTH_MEDIUM;
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "required", "Required");
|
||||||
case 2: return GTK_CONSTRAINT_STRENGTH_STRONG;
|
|
||||||
case 3: return GTK_CONSTRAINT_STRENGTH_REQUIRED;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static GtkConstraintStrength
|
||||||
get_strength_id (GtkConstraintStrength strength)
|
get_strength (const char *id)
|
||||||
{
|
{
|
||||||
switch (strength)
|
GtkConstraintStrength strength;
|
||||||
{
|
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
|
||||||
case GTK_CONSTRAINT_STRENGTH_WEAK: return 0;
|
GEnumValue *value = g_enum_get_value_by_nick (class, id);
|
||||||
case GTK_CONSTRAINT_STRENGTH_MEDIUM: return 1;
|
strength = value->value;
|
||||||
case GTK_CONSTRAINT_STRENGTH_STRONG: return 2;
|
g_type_class_unref (class);
|
||||||
case GTK_CONSTRAINT_STRENGTH_REQUIRED: return 3;
|
|
||||||
default: g_assert_not_reached ();
|
return strength;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -121,11 +118,11 @@ static void
|
|||||||
create_guide (GtkButton *button,
|
create_guide (GtkButton *button,
|
||||||
GuideEditor *editor)
|
GuideEditor *editor)
|
||||||
{
|
{
|
||||||
|
const char *id;
|
||||||
int strength;
|
int strength;
|
||||||
const char *name;
|
const char *name;
|
||||||
int w, h;
|
int w, h;
|
||||||
GtkConstraintGuide *guide;
|
GtkConstraintGuide *guide;
|
||||||
unsigned int id;
|
|
||||||
|
|
||||||
if (editor->guide)
|
if (editor->guide)
|
||||||
guide = g_object_ref (editor->guide);
|
guide = g_object_ref (editor->guide);
|
||||||
@@ -147,7 +144,7 @@ create_guide (GtkButton *button,
|
|||||||
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->max_height));
|
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->max_height));
|
||||||
gtk_constraint_guide_set_max_size (guide, w, h);
|
gtk_constraint_guide_set_max_size (guide, w, h);
|
||||||
|
|
||||||
id = gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->strength));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->strength));
|
||||||
strength = get_strength (id);
|
strength = get_strength (id);
|
||||||
gtk_constraint_guide_set_strength (guide, strength);
|
gtk_constraint_guide_set_strength (guide, strength);
|
||||||
|
|
||||||
@@ -194,9 +191,14 @@ guide_editor_constructed (GObject *object)
|
|||||||
{
|
{
|
||||||
GuideEditor *editor = GUIDE_EDITOR (object);
|
GuideEditor *editor = GUIDE_EDITOR (object);
|
||||||
|
|
||||||
|
guide_strength_combo (editor->strength);
|
||||||
|
|
||||||
g_signal_connect (editor->min_width, "input", G_CALLBACK (min_input), NULL);
|
g_signal_connect (editor->min_width, "input", G_CALLBACK (min_input), NULL);
|
||||||
|
|
||||||
g_signal_connect (editor->min_height, "input", G_CALLBACK (min_input), NULL);
|
g_signal_connect (editor->min_height, "input", G_CALLBACK (min_input), NULL);
|
||||||
|
|
||||||
g_signal_connect (editor->max_width, "input", G_CALLBACK (max_input), NULL);
|
g_signal_connect (editor->max_width, "input", G_CALLBACK (max_input), NULL);
|
||||||
|
|
||||||
g_signal_connect (editor->max_height, "input", G_CALLBACK (max_input), NULL);
|
g_signal_connect (editor->max_height, "input", G_CALLBACK (max_input), NULL);
|
||||||
|
|
||||||
if (editor->guide)
|
if (editor->guide)
|
||||||
@@ -222,7 +224,8 @@ guide_editor_constructed (GObject *object)
|
|||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), h);
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), h);
|
||||||
|
|
||||||
strength = gtk_constraint_guide_get_strength (editor->guide);
|
strength = gtk_constraint_guide_get_strength (editor->guide);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (strength));
|
nick = get_strength_nick (strength);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), nick);
|
||||||
|
|
||||||
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
|
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
|
||||||
}
|
}
|
||||||
@@ -242,7 +245,7 @@ guide_editor_constructed (GObject *object)
|
|||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_width), G_MAXINT);
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_width), G_MAXINT);
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), G_MAXINT);
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), G_MAXINT);
|
||||||
|
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (GTK_CONSTRAINT_STRENGTH_MEDIUM));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), "medium");
|
||||||
|
|
||||||
gtk_button_set_label (GTK_BUTTON (editor->button), "Create");
|
gtk_button_set_label (GTK_BUTTON (editor->button), "Create");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,17 +167,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="strength">
|
<object class="GtkComboBoxText" id="strength">
|
||||||
<property name="model">
|
|
||||||
<object class="GtkStringList">
|
|
||||||
<items>
|
|
||||||
<item>Weak</item>
|
|
||||||
<item>Medium</item>
|
|
||||||
<item>Strong</item>
|
|
||||||
<item>Required</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">4</property>
|
<property name="row">4</property>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
typedef GtkApplication DemoApplication;
|
typedef GtkApplication DemoApplication;
|
||||||
typedef GtkApplicationClass DemoApplicationClass;
|
typedef GtkApplicationClass DemoApplicationClass;
|
||||||
|
|
||||||
@@ -214,41 +216,6 @@ activate_quit (GSimpleAction *action,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
delete_messages (gpointer data)
|
|
||||||
{
|
|
||||||
g_list_free_full ((GList *)data, g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pop_message (GtkWidget *status)
|
|
||||||
{
|
|
||||||
GList *messages = (GList *) g_object_get_data (G_OBJECT (status), "messages");
|
|
||||||
|
|
||||||
if (messages)
|
|
||||||
{
|
|
||||||
char *message = messages->data;
|
|
||||||
messages = g_list_remove (messages, message);
|
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (status), "messages",
|
|
||||||
messages, delete_messages);
|
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (status), message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
push_message (GtkWidget *status,
|
|
||||||
const char *message)
|
|
||||||
{
|
|
||||||
GList *messages = (GList *) g_object_get_data (G_OBJECT (status), "messages");
|
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (status), message);
|
|
||||||
messages = g_list_prepend (messages, g_strdup (message));
|
|
||||||
g_object_set_data_full (G_OBJECT (status), "messages",
|
|
||||||
messages, delete_messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_statusbar (GtkTextBuffer *buffer,
|
update_statusbar (GtkTextBuffer *buffer,
|
||||||
DemoApplicationWindow *window)
|
DemoApplicationWindow *window)
|
||||||
@@ -259,7 +226,7 @@ update_statusbar (GtkTextBuffer *buffer,
|
|||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
|
|
||||||
/* clear any previous message, underflow is allowed */
|
/* clear any previous message, underflow is allowed */
|
||||||
pop_message (window->status);
|
gtk_statusbar_pop (GTK_STATUSBAR (window->status), 0);
|
||||||
|
|
||||||
count = gtk_text_buffer_get_char_count (buffer);
|
count = gtk_text_buffer_get_char_count (buffer);
|
||||||
|
|
||||||
@@ -273,7 +240,7 @@ update_statusbar (GtkTextBuffer *buffer,
|
|||||||
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
|
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
|
||||||
row, col, count);
|
row, col, count);
|
||||||
|
|
||||||
push_message (window->status, msg);
|
gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, msg);
|
||||||
|
|
||||||
g_free (msg);
|
g_free (msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,13 +76,8 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="status">
|
<object class="GtkStatusbar" id="status">
|
||||||
<property name="hexpand">1</property>
|
<property name="hexpand">1</property>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="margin-start">2</property>
|
|
||||||
<property name="margin-end">2</property>
|
|
||||||
<property name="margin-top">2</property>
|
|
||||||
<property name="margin-bottom">2</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">0</property>
|
<property name="column">0</property>
|
||||||
<property name="row">3</property>
|
<property name="row">3</property>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Builder
|
/* Builder
|
||||||
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkShortcutController, toolbar
|
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, GtkShortcutController, toolbar
|
||||||
*
|
*
|
||||||
* Demonstrates a traditional interface, loaded from a XML description,
|
* Demonstrates a traditional interface, loaded from a XML description,
|
||||||
* and shows how to connect actions to the menu items and toolbar buttons.
|
* and shows how to connect actions to the menu items and toolbar buttons.
|
||||||
@@ -37,34 +37,30 @@ remove_timeout (gpointer data)
|
|||||||
g_source_remove (id);
|
g_source_remove (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
pop_message (gpointer data)
|
|
||||||
|
static gboolean
|
||||||
|
pop_status (gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *status = data;
|
gtk_statusbar_pop (GTK_STATUSBAR (data), 0);
|
||||||
|
g_object_set_data (G_OBJECT (data), "timeout", NULL);
|
||||||
gtk_label_set_label (GTK_LABEL (status), "");
|
|
||||||
g_object_set_data (G_OBJECT (status), "timeout", GUINT_TO_POINTER (0));
|
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
status_message (GtkWidget *status,
|
status_message (GtkStatusbar *status,
|
||||||
const char *text)
|
const char *text)
|
||||||
{
|
{
|
||||||
guint id;
|
guint id;
|
||||||
|
|
||||||
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (status), "timeout"));
|
gtk_statusbar_push (GTK_STATUSBAR (status), 0, text);
|
||||||
if (id)
|
id = g_timeout_add (5000, pop_status, status);
|
||||||
g_source_remove (id);
|
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (status), text);
|
|
||||||
|
|
||||||
id = g_timeout_add (5000, pop_message, status);
|
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (status), "timeout", GUINT_TO_POINTER (id), remove_timeout);
|
g_object_set_data_full (G_OBJECT (status), "timeout", GUINT_TO_POINTER (id), remove_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help_activate (GSimpleAction *action,
|
help_activate (GSimpleAction *action,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
@@ -73,7 +69,7 @@ help_activate (GSimpleAction *action,
|
|||||||
GtkWidget *status;
|
GtkWidget *status;
|
||||||
|
|
||||||
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
||||||
status_message (status, "Help not available");
|
status_message (GTK_STATUSBAR (status), "Help not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -86,7 +82,7 @@ not_implemented (GSimpleAction *action,
|
|||||||
|
|
||||||
text = g_strdup_printf ("Action “%s” not implemented", g_action_get_name (G_ACTION (action)));
|
text = g_strdup_printf ("Action “%s” not implemented", g_action_get_name (G_ACTION (action)));
|
||||||
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
||||||
status_message (status, text);
|
status_message (GTK_STATUSBAR (status), text);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_parsing_error (GtkCssProvider *provider,
|
show_parsing_error (GtkCssProvider *provider,
|
||||||
GtkCssSection *section,
|
GtkCssSection *section,
|
||||||
@@ -47,23 +49,20 @@ css_text_changed (GtkTextBuffer *buffer,
|
|||||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||||
|
|
||||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
gtk_css_provider_load_from_string (provider, text);
|
gtk_css_provider_load_from_data (provider, text, -1);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
clear_provider (gpointer data)
|
|
||||||
{
|
|
||||||
GtkStyleProvider *provider = data;
|
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
GtkWidget *child;
|
||||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -82,7 +81,6 @@ do_css_basics (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
|
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||||
gtk_widget_add_css_class (window, "demo");
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
text = gtk_text_buffer_new (NULL);
|
text = gtk_text_buffer_new (NULL);
|
||||||
|
|||||||
@@ -4,24 +4,23 @@
|
|||||||
* anymore. :)
|
* anymore. :)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This resets all properties to their defaults values
|
/* This CSS resets all properties to their defaults values
|
||||||
* and overrides all user settings and the theme in use
|
* and overrides all user settings and the theme in use */
|
||||||
*/
|
@import url("resource://css_basics/reset.css");
|
||||||
@import url("resource://css_shadows/reset.css");
|
|
||||||
|
|
||||||
/* Set a very futuristic style by default */
|
/* Set a very futuristic style by default */
|
||||||
.demo * {
|
* {
|
||||||
color: green;
|
color: green;
|
||||||
font-family: Monospace;
|
font-family: Monospace;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo {
|
window {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure selections are visible */
|
/* Make sure selections are visible */
|
||||||
.demo selection {
|
selection {
|
||||||
background-color: darkGreen;
|
background-color: darkGreen;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_parsing_error (GtkCssProvider *provider,
|
show_parsing_error (GtkCssProvider *provider,
|
||||||
GtkCssSection *section,
|
GtkCssSection *section,
|
||||||
@@ -48,23 +50,33 @@ css_text_changed (GtkTextBuffer *buffer,
|
|||||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||||
|
|
||||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
gtk_css_provider_load_from_string (provider, text);
|
gtk_css_provider_load_from_data (provider, text, -1);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clear_provider (gpointer data)
|
drawing_area_draw (GtkDrawingArea *da,
|
||||||
|
cairo_t *cr,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkStyleProvider *provider = data;
|
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (da));
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
gtk_render_background (context, cr, 0, 0, width, height);
|
||||||
|
gtk_render_frame (context, cr, 0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
GtkWidget *child;
|
||||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -83,17 +95,16 @@ do_css_multiplebgs (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
|
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||||
gtk_widget_add_css_class (window, "demo");
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
overlay = gtk_overlay_new ();
|
overlay = gtk_overlay_new ();
|
||||||
gtk_window_set_child (GTK_WINDOW (window), overlay);
|
gtk_window_set_child (GTK_WINDOW (window), overlay);
|
||||||
|
|
||||||
child = gtk_drawing_area_new ();
|
child = gtk_drawing_area_new ();
|
||||||
/* Don't set a draw_func, since we are only interested in CSS drawing,
|
|
||||||
* which happens automatically.
|
|
||||||
*/
|
|
||||||
gtk_widget_set_name (child, "canvas");
|
gtk_widget_set_name (child, "canvas");
|
||||||
|
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (child),
|
||||||
|
drawing_area_draw,
|
||||||
|
NULL, NULL);
|
||||||
gtk_overlay_set_child (GTK_OVERLAY (overlay), child);
|
gtk_overlay_set_child (GTK_OVERLAY (overlay), child);
|
||||||
|
|
||||||
child = gtk_button_new ();
|
child = gtk_button_new ();
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_parsing_error (GtkCssProvider *provider,
|
show_parsing_error (GtkCssProvider *provider,
|
||||||
GtkCssSection *section,
|
GtkCssSection *section,
|
||||||
@@ -49,23 +51,20 @@ css_text_changed (GtkTextBuffer *buffer,
|
|||||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||||
|
|
||||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
gtk_css_provider_load_from_string (provider, text);
|
gtk_css_provider_load_from_data (provider, text, -1);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
clear_provider (gpointer data)
|
|
||||||
{
|
|
||||||
GtkStyleProvider *provider = data;
|
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
GtkWidget *child;
|
||||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -84,7 +83,6 @@ do_css_pixbufs (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
|
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||||
gtk_widget_add_css_class (window, "demo");
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
100% { background-size: 12px, 96px, 12px, 96px, 12px, 96px, 12px, 96px, auto; }
|
100% { background-size: 12px, 96px, 12px, 96px, 12px, 96px, 12px, 96px, auto; }
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo {
|
window {
|
||||||
background-image: url("resource://css_pixbufs/images/apple-red.png"),
|
background-image: url("resource://css_pixbufs/images/apple-red.png"),
|
||||||
url("resource://css_pixbufs/images/gnome-applets.png"),
|
url("resource://css_pixbufs/images/gnome-applets.png"),
|
||||||
url("resource://css_pixbufs/images/gnome-calendar.png"),
|
url("resource://css_pixbufs/images/gnome-calendar.png"),
|
||||||
@@ -66,11 +66,11 @@ window.demo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make the text editor has a nice style */
|
/* Make the text editor has a nice style */
|
||||||
window.demo .view, scrollbar, separator {
|
.view, scrollbar, separator {
|
||||||
color: black;
|
color: black;
|
||||||
background-color: rgba(255,255,255,0.5);
|
background-color: rgba(255,255,255,0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo .view:selected {
|
.view:selected {
|
||||||
background-color: rgba(127,127,255,0.5);
|
background-color: rgba(127,127,255,0.5);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_parsing_error (GtkCssProvider *provider,
|
show_parsing_error (GtkCssProvider *provider,
|
||||||
GtkCssSection *section,
|
GtkCssSection *section,
|
||||||
@@ -46,23 +48,20 @@ css_text_changed (GtkTextBuffer *buffer,
|
|||||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||||
|
|
||||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
gtk_css_provider_load_from_string (provider, text);
|
gtk_css_provider_load_from_data (provider, text, -1);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
clear_provider (gpointer data)
|
|
||||||
{
|
|
||||||
GtkStyleProvider *provider = data;
|
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
GtkWidget *child;
|
||||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
@@ -102,7 +101,6 @@ do_css_shadows (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
|
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||||
gtk_widget_add_css_class (window, "demo");
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
||||||
@@ -144,7 +142,7 @@ do_css_shadows (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
gtk_widget_set_visible (window, TRUE);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* This CSS resets all properties to their defaults values
|
/* This CSS resets all properties to their defaults values
|
||||||
* and overrides all user settings and the theme in use
|
* and overrides all user settings and the theme in use */
|
||||||
*/
|
|
||||||
@import url("resource://css_shadows/reset.css");
|
@import url("resource://css_shadows/reset.css");
|
||||||
@import url("resource://css_shadows/cssview.css");
|
@import url("resource://css_shadows/cssview.css");
|
||||||
|
|
||||||
/* Get a nice background for the window */
|
/* Get a nice background for the window */
|
||||||
window.demo.background {
|
.background {
|
||||||
background-color: #4870bc;
|
background-color: #4870bc;
|
||||||
background-image: linear-gradient(to left, transparent, rgba(255,255,255,.07) 50%, transparent 50%),
|
background-image: linear-gradient(to left, transparent, rgba(255,255,255,.07) 50%, transparent 50%),
|
||||||
linear-gradient(to left, transparent, rgba(255,255,255,.13) 50%, transparent 50%),
|
linear-gradient(to left, transparent, rgba(255,255,255,.13) 50%, transparent 50%),
|
||||||
@@ -20,7 +19,7 @@ window.demo.background {
|
|||||||
background-size: 29px, 59px, 73px, 109px;
|
background-size: 29px, 59px, 73px, 109px;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo button {
|
button {
|
||||||
color: black;
|
color: black;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
@@ -28,15 +27,18 @@ window.demo button {
|
|||||||
border: 1px transparent solid;
|
border: 1px transparent solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo button:hover {
|
button:hover {
|
||||||
text-shadow: 3px 3px 5px alpha(black, 0.75);
|
text-shadow: 3px 3px 5px alpha(black, 0.75);
|
||||||
-gtk-icon-shadow: 3px 3px 5px alpha(black, 0.75);
|
-gtk-icon-shadow: 3px 3px 5px alpha(black, 0.75);
|
||||||
box-shadow: 3px 3px 5px alpha(black, 0.5) inset;
|
box-shadow: 3px 3px 5px alpha(black, 0.5) inset;
|
||||||
border: solid 1px alpha(black, 0.75);
|
border: solid 1px alpha(black, 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo button:active {
|
button:active {
|
||||||
padding: 11px 9px 9px 11px;
|
padding: 11px 9px 9px 11px;
|
||||||
text-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
text-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
||||||
-gtk-icon-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
-gtk-icon-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
/* Make the text editor has a nice style */
|
/* Make the text editor has a nice style */
|
||||||
window.demo .view {
|
.view {
|
||||||
color: #2e3436;
|
color: #2e3436;
|
||||||
font-family: Monospace;
|
font-family: Monospace;
|
||||||
background-color: alpha(white, 0.30);
|
background-color: alpha(white, 0.30);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo .view:selected {
|
.view:selected {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: #4a90d9;
|
background-color: #4a90d9;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo scrollbar trough,
|
scrollbar trough,
|
||||||
.scrollbars-junction {
|
.scrollbars-junction {
|
||||||
background-color: alpha(white, 0.80);
|
background-color: alpha(white, 0.80);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo scrollbar slider {
|
scrollbar slider {
|
||||||
border-width: 3px;
|
border-width: 3px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
@@ -24,11 +24,11 @@ window.demo scrollbar slider {
|
|||||||
background-color: #999;
|
background-color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo scrollbar slider:hover {
|
scrollbar slider:hover {
|
||||||
background-color: #555;
|
background-color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo paned separator {
|
paned separator {
|
||||||
background-color: alpha(white, 0.80);
|
background-color: alpha(white, 0.80);
|
||||||
background-image: linear-gradient(transparent, transparent 1px, #999 1px, #999 4px, transparent 4px);
|
background-image: linear-gradient(transparent, transparent 1px, #999 1px, #999 4px, transparent 4px);
|
||||||
background-size: 40px auto;
|
background-size: 40px auto;
|
||||||
@@ -36,6 +36,6 @@ window.demo paned separator {
|
|||||||
background-position: center;
|
background-position: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo paned separator:hover {
|
paned separator:hover {
|
||||||
background-image: linear-gradient(transparent, transparent 1px, #555 1px, #555 4px, transparent 4px);
|
background-image: linear-gradient(transparent, transparent 1px, #555 1px, #555 4px, transparent 4px);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,6 +336,8 @@
|
|||||||
<file>panes.c</file>
|
<file>panes.c</file>
|
||||||
<file>password_entry.c</file>
|
<file>password_entry.c</file>
|
||||||
<file>path_fill.c</file>
|
<file>path_fill.c</file>
|
||||||
|
<file>path_maze.c</file>
|
||||||
|
<file>path_text.c</file>
|
||||||
<file>peg_solitaire.c</file>
|
<file>peg_solitaire.c</file>
|
||||||
<file>pickers.c</file>
|
<file>pickers.c</file>
|
||||||
<file>printing.c</file>
|
<file>printing.c</file>
|
||||||
@@ -421,6 +423,9 @@
|
|||||||
<gresource prefix="/fontrendering">
|
<gresource prefix="/fontrendering">
|
||||||
<file>fontrendering.ui</file>
|
<file>fontrendering.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
|
<gresource prefix="/path_text">
|
||||||
|
<file>path_text.ui</file>
|
||||||
|
</gresource>
|
||||||
<gresource prefix="/org/gtk/Demo4">
|
<gresource prefix="/org/gtk/Demo4">
|
||||||
<file>icons/16x16/actions/application-exit.png</file>
|
<file>icons/16x16/actions/application-exit.png</file>
|
||||||
<file>icons/16x16/actions/document-new.png</file>
|
<file>icons/16x16/actions/document-new.png</file>
|
||||||
|
|||||||
@@ -208,13 +208,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="statusbar1">
|
<object class="GtkStatusbar" id="statusbar1"/>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="margin-start">2</property>
|
|
||||||
<property name="margin-end">2</property>
|
|
||||||
<property name="margin-top">2</property>
|
|
||||||
<property name="margin-bottom">2</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|||||||
@@ -760,7 +760,9 @@ do_dnd (GtkWidget *do_widget)
|
|||||||
GtkCssProvider *provider;
|
GtkCssProvider *provider;
|
||||||
GString *css;
|
GString *css;
|
||||||
|
|
||||||
button = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
button = gtk_color_button_new ();
|
||||||
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
g_object_unref (g_object_ref_sink (button));
|
g_object_unref (g_object_ref_sink (button));
|
||||||
|
|
||||||
provider = gtk_css_provider_new ();
|
provider = gtk_css_provider_new ();
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
static GtkWidget *window = NULL;
|
static GtkWidget *window = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -43,22 +45,21 @@ do_expander (GtkWidget *do_widget)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
toplevel = GTK_WIDGET (gtk_widget_get_root (do_widget));
|
toplevel = GTK_WIDGET (gtk_widget_get_root (do_widget));
|
||||||
window = gtk_window_new ();
|
window = gtk_message_dialog_new_with_markup (GTK_WINDOW (toplevel),
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "Expander");
|
0,
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
|
GTK_MESSAGE_ERROR,
|
||||||
area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
GTK_BUTTONS_CLOSE,
|
||||||
gtk_widget_set_margin_start (area, 10);
|
"<big><b>%s</b></big>",
|
||||||
gtk_widget_set_margin_end (area, 10);
|
"Something went wrong");
|
||||||
gtk_widget_set_margin_top (area, 10);
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (window),
|
||||||
gtk_widget_set_margin_bottom (area, 10);
|
"Here are some more details "
|
||||||
gtk_window_set_child (GTK_WINDOW (window), area);
|
"but not the full story.");
|
||||||
label = gtk_label_new ("<big><b>Something went wrong</b></big>");
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (window));
|
||||||
gtk_box_append (GTK_BOX (area), label);
|
|
||||||
label = gtk_label_new ("Here are some more details but not the full story");
|
label = gtk_widget_get_last_child (area);
|
||||||
gtk_label_set_wrap (GTK_LABEL (label), FALSE);
|
gtk_label_set_wrap (GTK_LABEL (label), FALSE);
|
||||||
gtk_widget_set_vexpand (label, FALSE);
|
gtk_widget_set_vexpand (label, FALSE);
|
||||||
gtk_box_append (GTK_BOX (area), label);
|
|
||||||
|
|
||||||
expander = gtk_expander_new ("Details:");
|
expander = gtk_expander_new ("Details:");
|
||||||
gtk_widget_set_vexpand (expander, TRUE);
|
gtk_widget_set_vexpand (expander, TRUE);
|
||||||
@@ -121,7 +122,7 @@ do_expander (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
gtk_widget_set_visible (window, TRUE);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
|||||||
@@ -68,18 +68,13 @@ create_blurred_button (void)
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
create_font_button (void)
|
create_font_button (void)
|
||||||
{
|
{
|
||||||
GtkFontDialog *dialog;
|
return gtk_font_button_new ();
|
||||||
GtkWidget *button;
|
|
||||||
|
|
||||||
dialog = gtk_font_dialog_new ();
|
|
||||||
button = gtk_font_dialog_button_new (dialog);
|
|
||||||
g_object_unref (dialog);
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
}
|
||||||
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
create_level_bar (void)
|
create_level_bar (void)
|
||||||
@@ -315,20 +310,11 @@ do_fishbowl (GtkWidget *do_widget)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkBuilderScope *scope;
|
|
||||||
GtkWidget *bowl;
|
GtkWidget *bowl;
|
||||||
|
|
||||||
g_type_ensure (GTK_TYPE_FISHBOWL);
|
g_type_ensure (GTK_TYPE_FISHBOWL);
|
||||||
|
|
||||||
scope = gtk_builder_cscope_new ();
|
builder = gtk_builder_new_from_resource ("/fishbowl/fishbowl.ui");
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_prev_button_clicked_cb);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_next_button_clicked_cb);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_changes_toggled_cb);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), format_header_cb);
|
|
||||||
|
|
||||||
builder = gtk_builder_new ();
|
|
||||||
gtk_builder_set_scope (builder, scope);
|
|
||||||
gtk_builder_add_from_resource (builder, "/fishbowl/fishbowl.ui", NULL);
|
|
||||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
@@ -340,7 +326,6 @@ do_fishbowl (GtkWidget *do_widget)
|
|||||||
|
|
||||||
gtk_widget_realize (window);
|
gtk_widget_realize (window);
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
g_object_unref (scope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
|
|||||||
@@ -354,18 +354,10 @@ do_iconscroll (GtkWidget *do_widget)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkBuilderScope *scope;
|
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
guint id;
|
guint id;
|
||||||
|
|
||||||
scope = gtk_builder_cscope_new ();
|
builder = gtk_builder_new_from_resource ("/iconscroll/iconscroll.ui");
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), iconscroll_prev_clicked_cb);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), iconscroll_next_clicked_cb);
|
|
||||||
|
|
||||||
builder = gtk_builder_new ();
|
|
||||||
gtk_builder_set_scope (builder, scope);
|
|
||||||
|
|
||||||
gtk_builder_add_from_resource (builder, "/iconscroll/iconscroll.ui", NULL);
|
|
||||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
gtk_window_set_display (GTK_WINDOW (window),
|
gtk_window_set_display (GTK_WINDOW (window),
|
||||||
@@ -383,7 +375,6 @@ do_iconscroll (GtkWidget *do_widget)
|
|||||||
GUINT_TO_POINTER (id), remove_timeout);
|
GUINT_TO_POINTER (id), remove_timeout);
|
||||||
|
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
g_object_unref (scope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ demos = files([
|
|||||||
'panes.c',
|
'panes.c',
|
||||||
'password_entry.c',
|
'password_entry.c',
|
||||||
'path_fill.c',
|
'path_fill.c',
|
||||||
|
'path_maze.c',
|
||||||
|
'path_text.c',
|
||||||
'peg_solitaire.c',
|
'peg_solitaire.c',
|
||||||
'pickers.c',
|
'pickers.c',
|
||||||
'printing.c',
|
'printing.c',
|
||||||
@@ -151,6 +153,8 @@ if librsvg_dep.found()
|
|||||||
gtkdemo_deps += [ librsvg_dep ]
|
gtkdemo_deps += [ librsvg_dep ]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
gtkdemo_args = [ '-DGDK_DISABLE_DEPRECATED', '-DGTK_DISABLE_DEPRECATED', ]
|
||||||
|
|
||||||
demos_h = custom_target('gtk4 demo header',
|
demos_h = custom_target('gtk4 demo header',
|
||||||
output: 'demos.h',
|
output: 'demos.h',
|
||||||
input: demos,
|
input: demos,
|
||||||
@@ -205,7 +209,6 @@ if can_use_objcopy_for_resources
|
|||||||
output : 'gtkdemo_resources2.o',
|
output : 'gtkdemo_resources2.o',
|
||||||
command : [objcopy,
|
command : [objcopy,
|
||||||
'--strip-all',
|
'--strip-all',
|
||||||
'--set-section-alignment', '.data=8',
|
|
||||||
'--add-symbol','_g_binary_gtkdemo_resource_data=.data:0',
|
'--add-symbol','_g_binary_gtkdemo_resource_data=.data:0',
|
||||||
'@INPUT@',
|
'@INPUT@',
|
||||||
'@OUTPUT@'])
|
'@OUTPUT@'])
|
||||||
@@ -234,7 +237,7 @@ gtkdemo_deps += [ demo_conf_h ]
|
|||||||
|
|
||||||
executable('gtk4-demo',
|
executable('gtk4-demo',
|
||||||
sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
|
sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
|
||||||
c_args: demo_cflags,
|
c_args: gtkdemo_args + demo_cflags,
|
||||||
dependencies: gtkdemo_deps,
|
dependencies: gtkdemo_deps,
|
||||||
include_directories: confinc,
|
include_directories: confinc,
|
||||||
win_subsystem: 'windows',
|
win_subsystem: 'windows',
|
||||||
@@ -244,7 +247,7 @@ executable('gtk4-demo',
|
|||||||
|
|
||||||
executable('gtk4-demo-application',
|
executable('gtk4-demo-application',
|
||||||
sources: ['application.c', gtkdemo_resources],
|
sources: ['application.c', gtkdemo_resources],
|
||||||
c_args: common_cflags,
|
c_args: gtkdemo_args + common_cflags,
|
||||||
dependencies: gtkdemo_deps,
|
dependencies: gtkdemo_deps,
|
||||||
include_directories: confinc,
|
include_directories: confinc,
|
||||||
win_subsystem: 'windows',
|
win_subsystem: 'windows',
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
COLOR_SET,
|
COLOR_SET,
|
||||||
N_SIGNALS
|
N_SIGNALS
|
||||||
@@ -122,16 +124,19 @@ drawing_area_unmap (GtkWidget *widget)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
drawing_area_snapshot (GtkWidget *widget,
|
drawing_area_snapshot (GtkWidget *widget,
|
||||||
GtkSnapshot *snapshot)
|
GtkSnapshot *snapshot)
|
||||||
{
|
{
|
||||||
DrawingArea *area = (DrawingArea *) widget;
|
DrawingArea *area = (DrawingArea *) widget;
|
||||||
int width, height;
|
GtkAllocation allocation;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
width = gtk_widget_get_width (widget);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
height = gtk_widget_get_height (widget);
|
cr = gtk_snapshot_append_cairo (snapshot,
|
||||||
|
&GRAPHENE_RECT_INIT (
|
||||||
cr = gtk_snapshot_append_cairo (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
0, 0,
|
||||||
|
allocation.width,
|
||||||
|
allocation.height
|
||||||
|
));
|
||||||
|
|
||||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
@@ -140,7 +145,7 @@ drawing_area_snapshot (GtkWidget *widget,
|
|||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
|
|
||||||
cairo_set_source_rgb (cr, 0.6, 0.6, 0.6);
|
cairo_set_source_rgb (cr, 0.6, 0.6, 0.6);
|
||||||
cairo_rectangle (cr, 0, 0, width, height);
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* Path/Fill and Stroke
|
/* Path/Fill
|
||||||
*
|
*
|
||||||
* This demo shows how to use GskPath to draw shapes that are (a bit)
|
* This demo shows how to use PangoCairo to draw text with more than
|
||||||
* more complex than a rounded rectangle.
|
* just a single color.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
@@ -9,162 +9,264 @@
|
|||||||
|
|
||||||
#include "paintable.h"
|
#include "paintable.h"
|
||||||
|
|
||||||
#define GTK_TYPE_LOGO_PAINTABLE (gtk_logo_paintable_get_type ())
|
#define GTK_TYPE_PATH_PAINTABLE (gtk_path_paintable_get_type ())
|
||||||
G_DECLARE_FINAL_TYPE (GtkLogoPaintable, gtk_logo_paintable, GTK, LOGO_PAINTABLE, GObject)
|
G_DECLARE_FINAL_TYPE (GtkPathPaintable, gtk_path_paintable, GTK, PATH_PAINTABLE, GObject)
|
||||||
|
|
||||||
struct _GtkLogoPaintable
|
struct _GtkPathPaintable
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
GskPath *path[3];
|
GskPath *path;
|
||||||
GdkRGBA color[3];
|
GdkPaintable *background;
|
||||||
|
|
||||||
GskPath *stroke_path;
|
|
||||||
GskStroke *stroke1;
|
|
||||||
GskStroke *stroke2;
|
|
||||||
GdkRGBA stroke_color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkLogoPaintableClass
|
struct _GtkPathPaintableClass
|
||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
gtk_logo_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
gtk_path_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||||
{
|
{
|
||||||
GtkLogoPaintable *self = GTK_LOGO_PAINTABLE (paintable);
|
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||||
|
|
||||||
return self->width;
|
if (self->background)
|
||||||
|
return MAX (gdk_paintable_get_intrinsic_width (self->background), self->width);
|
||||||
|
else
|
||||||
|
return self->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
gtk_logo_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
gtk_path_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||||
{
|
{
|
||||||
GtkLogoPaintable *self = GTK_LOGO_PAINTABLE (paintable);
|
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||||
|
|
||||||
return self->height;
|
if (self->background)
|
||||||
|
return MAX (gdk_paintable_get_intrinsic_height (self->background), self->height);
|
||||||
|
else
|
||||||
|
return self->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_logo_paintable_snapshot (GdkPaintable *paintable,
|
gtk_path_paintable_snapshot (GdkPaintable *paintable,
|
||||||
GdkSnapshot *snapshot,
|
GdkSnapshot *snapshot,
|
||||||
double width,
|
double width,
|
||||||
double height)
|
double height)
|
||||||
{
|
{
|
||||||
GtkLogoPaintable *self = GTK_LOGO_PAINTABLE (paintable);
|
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 3; i++)
|
#if 0
|
||||||
|
gtk_snapshot_push_fill (snapshot, self->path, GSK_FILL_RULE_WINDING);
|
||||||
|
#else
|
||||||
|
GskStroke *stroke = gsk_stroke_new (4.0);
|
||||||
|
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
|
||||||
|
gsk_stroke_free (stroke);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (self->background)
|
||||||
{
|
{
|
||||||
gtk_snapshot_push_fill (snapshot, self->path[i], GSK_FILL_RULE_WINDING);
|
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||||
gtk_snapshot_append_color (snapshot,
|
|
||||||
&self->color[i],
|
|
||||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
|
||||||
gtk_snapshot_pop (snapshot);
|
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < 3; i++)
|
else
|
||||||
{
|
{
|
||||||
gtk_snapshot_push_stroke (snapshot, self->stroke_path, self->stroke1);
|
gtk_snapshot_append_linear_gradient (snapshot,
|
||||||
gtk_snapshot_append_color (snapshot,
|
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||||
&self->stroke_color,
|
&GRAPHENE_POINT_INIT (0, 0),
|
||||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
&GRAPHENE_POINT_INIT (width, height),
|
||||||
gtk_snapshot_pop (snapshot);
|
(GskColorStop[8]) {
|
||||||
|
{ 0.0, { 1.0, 0.0, 0.0, 1.0 } },
|
||||||
|
{ 0.2, { 1.0, 0.0, 0.0, 1.0 } },
|
||||||
|
{ 0.3, { 1.0, 1.0, 0.0, 1.0 } },
|
||||||
|
{ 0.4, { 0.0, 1.0, 0.0, 1.0 } },
|
||||||
|
{ 0.6, { 0.0, 1.0, 1.0, 1.0 } },
|
||||||
|
{ 0.7, { 0.0, 0.0, 1.0, 1.0 } },
|
||||||
|
{ 0.8, { 1.0, 0.0, 1.0, 1.0 } },
|
||||||
|
{ 1.0, { 1.0, 0.0, 1.0, 1.0 } }
|
||||||
|
},
|
||||||
|
8);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_snapshot_push_stroke (snapshot, self->stroke_path, self->stroke2);
|
|
||||||
gtk_snapshot_append_color (snapshot,
|
|
||||||
&self->stroke_color,
|
|
||||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkPaintableFlags
|
static GdkPaintableFlags
|
||||||
gtk_logo_paintable_get_flags (GdkPaintable *paintable)
|
gtk_path_paintable_get_flags (GdkPaintable *paintable)
|
||||||
{
|
{
|
||||||
return GDK_PAINTABLE_STATIC_CONTENTS | GDK_PAINTABLE_STATIC_SIZE;
|
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||||
|
|
||||||
|
if (self->background)
|
||||||
|
return gdk_paintable_get_flags (self->background);
|
||||||
|
else
|
||||||
|
return GDK_PAINTABLE_STATIC_CONTENTS | GDK_PAINTABLE_STATIC_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_logo_paintable_paintable_init (GdkPaintableInterface *iface)
|
gtk_path_paintable_paintable_init (GdkPaintableInterface *iface)
|
||||||
{
|
{
|
||||||
iface->get_intrinsic_width = gtk_logo_paintable_get_intrinsic_width;
|
iface->get_intrinsic_width = gtk_path_paintable_get_intrinsic_width;
|
||||||
iface->get_intrinsic_height = gtk_logo_paintable_get_intrinsic_height;
|
iface->get_intrinsic_height = gtk_path_paintable_get_intrinsic_height;
|
||||||
iface->snapshot = gtk_logo_paintable_snapshot;
|
iface->snapshot = gtk_path_paintable_snapshot;
|
||||||
iface->get_flags = gtk_logo_paintable_get_flags;
|
iface->get_flags = gtk_path_paintable_get_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When defining the GType, we need to implement the GdkPaintable interface */
|
/* When defining the GType, we need to implement the GdkPaintable interface */
|
||||||
G_DEFINE_TYPE_WITH_CODE (GtkLogoPaintable, gtk_logo_paintable, G_TYPE_OBJECT,
|
G_DEFINE_TYPE_WITH_CODE (GtkPathPaintable, gtk_path_paintable, G_TYPE_OBJECT,
|
||||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||||
gtk_logo_paintable_paintable_init))
|
gtk_path_paintable_paintable_init))
|
||||||
|
|
||||||
static void
|
/* Here's the boilerplate for the GObject declaration.
|
||||||
gtk_logo_paintable_dispose (GObject *object)
|
* We need to disconnect the signals here that we set up elsewhere
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
gtk_path_paintable_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
GtkLogoPaintable *self = GTK_LOGO_PAINTABLE (object);
|
GtkPathPaintable *self = GTK_PATH_PAINTABLE (object);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 3; i++)
|
if (self->background)
|
||||||
gsk_path_unref (self->path[i]);
|
{
|
||||||
|
g_signal_handlers_disconnect_by_func (self->background, gdk_paintable_invalidate_contents, self);
|
||||||
|
g_signal_handlers_disconnect_by_func (self->background, gdk_paintable_invalidate_size, self);
|
||||||
|
g_clear_object (&self->background);
|
||||||
|
}
|
||||||
|
|
||||||
gsk_path_unref (self->stroke_path);
|
G_OBJECT_CLASS (gtk_path_paintable_parent_class)->dispose (object);
|
||||||
|
|
||||||
gsk_stroke_free (self->stroke1);
|
|
||||||
gsk_stroke_free (self->stroke2);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_logo_paintable_parent_class)->dispose (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_logo_paintable_class_init (GtkLogoPaintableClass *klass)
|
gtk_path_paintable_class_init (GtkPathPaintableClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->dispose = gtk_logo_paintable_dispose;
|
object_class->dispose = gtk_path_paintable_dispose;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_logo_paintable_init (GtkLogoPaintable *self)
|
gtk_path_paintable_init (GtkPathPaintable *self)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkPaintable *
|
/* And finally, we add a simple constructor.
|
||||||
gtk_logo_paintable_new (void)
|
* It is declared in the header so that the other examples
|
||||||
|
* can use it.
|
||||||
|
*/
|
||||||
|
GdkPaintable *
|
||||||
|
gtk_path_paintable_new (GskPath *path,
|
||||||
|
GdkPaintable *background,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
{
|
{
|
||||||
GtkLogoPaintable *self;
|
GtkPathPaintable *self;
|
||||||
graphene_rect_t bounds, bounds2;
|
|
||||||
|
|
||||||
self = g_object_new (GTK_TYPE_LOGO_PAINTABLE, NULL);
|
self = g_object_new (GTK_TYPE_PATH_PAINTABLE, NULL);
|
||||||
|
self->path = path;
|
||||||
/* Paths and colors extracted from gtk-logo.svg */
|
self->background = background;
|
||||||
self->path[0] = gsk_path_parse ("m3.12,66.17 -2.06,-51.46 32.93,24.7 v55.58 l-30.87,-28.82 z");
|
if (self->background)
|
||||||
self->path[1] = gsk_path_parse ("m34,95 49.4,-20.58 4.12,-51.46 -53.52,16.47 v55.58 z");
|
{
|
||||||
self->path[2] = gsk_path_parse ("m1.06,14.71 32.93,24.7 53.52,-16.47 -36.75,-21.88 -49.7,13.65 z");
|
g_object_ref (self->background);
|
||||||
|
g_signal_connect_swapped (self->background, "invalidate-contents", G_CALLBACK (gdk_paintable_invalidate_contents), self);
|
||||||
gdk_rgba_parse (&self->color[0], "#e40000");
|
g_signal_connect_swapped (self->background, "invalidate-size", G_CALLBACK (gdk_paintable_invalidate_size), self);
|
||||||
gdk_rgba_parse (&self->color[1], "#7fe719");
|
}
|
||||||
gdk_rgba_parse (&self->color[2], "#729fcf");
|
self->width = width;
|
||||||
|
self->height = height;
|
||||||
self->stroke_path = gsk_path_parse ("m50.6,51.3 -47.3,14 z l33,23 z v-50");
|
|
||||||
self->stroke1 = gsk_stroke_new (2.12);
|
|
||||||
self->stroke2 = gsk_stroke_new (1.25);
|
|
||||||
gdk_rgba_parse (&self->stroke_color, "#ffffff");
|
|
||||||
|
|
||||||
gsk_path_get_stroke_bounds (self->path[0], self->stroke1, &bounds);
|
|
||||||
gsk_path_get_stroke_bounds (self->path[1], self->stroke1, &bounds2);
|
|
||||||
graphene_rect_union (&bounds, &bounds2, &bounds);
|
|
||||||
gsk_path_get_stroke_bounds (self->path[2], self->stroke1, &bounds2);
|
|
||||||
graphene_rect_union (&bounds, &bounds2, &bounds);
|
|
||||||
gsk_path_get_stroke_bounds (self->stroke_path, self->stroke2, &bounds2);
|
|
||||||
graphene_rect_union (&bounds, &bounds2, &bounds);
|
|
||||||
|
|
||||||
self->width = bounds.origin.x + bounds.size.width;
|
|
||||||
self->height = bounds.origin.y + bounds.size.height;
|
|
||||||
|
|
||||||
return GDK_PAINTABLE (self);
|
return GDK_PAINTABLE (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_path_paintable_set_path (GtkPathPaintable *self,
|
||||||
|
GskPath *path)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&self->path, gsk_path_unref);
|
||||||
|
self->path = gsk_path_ref (path);
|
||||||
|
|
||||||
|
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
static GskPath *
|
||||||
|
create_hexagon (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GskPathBuilder *builder;
|
||||||
|
|
||||||
|
builder = gsk_path_builder_new ();
|
||||||
|
|
||||||
|
gsk_path_builder_move_to (builder, 120, 0);
|
||||||
|
gsk_path_builder_line_to (builder, 360, 0);
|
||||||
|
gsk_path_builder_line_to (builder, 480, 208);
|
||||||
|
gsk_path_builder_line_to (builder, 360, 416);
|
||||||
|
gsk_path_builder_line_to (builder, 120, 416);
|
||||||
|
gsk_path_builder_line_to (builder, 0, 208);
|
||||||
|
gsk_path_builder_close (builder);
|
||||||
|
|
||||||
|
return gsk_path_builder_free_to_path (builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GskPath *
|
||||||
|
create_path_from_text (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
cairo_t *cr;
|
||||||
|
cairo_path_t *path;
|
||||||
|
PangoLayout *layout;
|
||||||
|
PangoFontDescription *desc;
|
||||||
|
GskPath *result;
|
||||||
|
|
||||||
|
surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
||||||
|
cr = cairo_create (surface);
|
||||||
|
|
||||||
|
layout = gtk_widget_create_pango_layout (widget, "Pango power!\nPango power!\nPango power!");
|
||||||
|
desc = pango_font_description_from_string ("sans bold 36");
|
||||||
|
pango_layout_set_font_description (layout, desc);
|
||||||
|
pango_font_description_free (desc);
|
||||||
|
|
||||||
|
pango_cairo_layout_path (cr, layout);
|
||||||
|
path = cairo_copy_path_flat (cr);
|
||||||
|
result = gsk_path_new_from_cairo (path);
|
||||||
|
|
||||||
|
cairo_path_destroy (path);
|
||||||
|
g_object_unref (layout);
|
||||||
|
cairo_destroy (cr);
|
||||||
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
update_path (GtkWidget *widget,
|
||||||
|
GdkFrameClock *frame_clock,
|
||||||
|
gpointer measure)
|
||||||
|
{
|
||||||
|
float progress = gdk_frame_clock_get_frame_time (frame_clock) % (60 * G_USEC_PER_SEC) / (float) (30 * G_USEC_PER_SEC);
|
||||||
|
GskPathBuilder *builder;
|
||||||
|
GskPath *path;
|
||||||
|
graphene_point_t pos;
|
||||||
|
graphene_vec2_t tangent;
|
||||||
|
|
||||||
|
builder = gsk_path_builder_new ();
|
||||||
|
gsk_path_measure_add_segment (measure,
|
||||||
|
builder,
|
||||||
|
progress > 1 ? (progress - 1) * gsk_path_measure_get_length (measure) : 0.0,
|
||||||
|
(progress < 1 ? progress : 1.0) * gsk_path_measure_get_length (measure));
|
||||||
|
|
||||||
|
gsk_path_measure_get_point (measure,
|
||||||
|
(progress > 1 ? (progress - 1) : progress) * gsk_path_measure_get_length (measure),
|
||||||
|
&pos,
|
||||||
|
&tangent);
|
||||||
|
gsk_path_builder_move_to (builder, pos.x + 5 * graphene_vec2_get_x (&tangent), pos.y + 5 * graphene_vec2_get_y (&tangent));
|
||||||
|
gsk_path_builder_line_to (builder, pos.x + 3 * graphene_vec2_get_y (&tangent), pos.y + 3 * graphene_vec2_get_x (&tangent));
|
||||||
|
gsk_path_builder_line_to (builder, pos.x - 3 * graphene_vec2_get_y (&tangent), pos.y - 3 * graphene_vec2_get_x (&tangent));
|
||||||
|
gsk_path_builder_close (builder);
|
||||||
|
path = gsk_path_builder_free_to_path (builder);
|
||||||
|
|
||||||
|
gtk_path_paintable_set_path (GTK_PATH_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget))),
|
||||||
|
path);
|
||||||
|
gsk_path_unref (path);
|
||||||
|
|
||||||
|
return G_SOURCE_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
do_path_fill (GtkWidget *do_widget)
|
do_path_fill (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
@@ -174,14 +276,35 @@ do_path_fill (GtkWidget *do_widget)
|
|||||||
{
|
{
|
||||||
GtkWidget *picture;
|
GtkWidget *picture;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
|
GtkMediaStream *stream;
|
||||||
|
GskPath *path;
|
||||||
|
graphene_rect_t bounds;
|
||||||
|
GskPathMeasure *measure;
|
||||||
|
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "Path Fill");
|
gtk_window_set_title (GTK_WINDOW (window), "Path Fill");
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
paintable = gtk_logo_paintable_new ();
|
#if 0
|
||||||
|
stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||||
|
#else
|
||||||
|
stream = gtk_nuclear_media_stream_new ();
|
||||||
|
#endif
|
||||||
|
gtk_media_stream_play (stream);
|
||||||
|
gtk_media_stream_set_loop (stream, TRUE);
|
||||||
|
|
||||||
|
path = create_hexagon (window);
|
||||||
|
path = create_path_from_text (window);
|
||||||
|
gsk_path_get_bounds (path, &bounds);
|
||||||
|
|
||||||
|
paintable = gtk_path_paintable_new (path,
|
||||||
|
GDK_PAINTABLE (stream),
|
||||||
|
bounds.origin.x + bounds.size.width,
|
||||||
|
bounds.origin.y + bounds.size.height);
|
||||||
picture = gtk_picture_new_for_paintable (paintable);
|
picture = gtk_picture_new_for_paintable (paintable);
|
||||||
|
measure = gsk_path_measure_new (path);
|
||||||
|
gtk_widget_add_tick_callback (picture, update_path, measure, (GDestroyNotify) gsk_path_measure_unref);
|
||||||
gtk_picture_set_content_fit (GTK_PICTURE (picture), GTK_CONTENT_FIT_CONTAIN);
|
gtk_picture_set_content_fit (GTK_PICTURE (picture), GTK_CONTENT_FIT_CONTAIN);
|
||||||
gtk_picture_set_can_shrink (GTK_PICTURE (picture), FALSE);
|
gtk_picture_set_can_shrink (GTK_PICTURE (picture), FALSE);
|
||||||
g_object_unref (paintable);
|
g_object_unref (paintable);
|
||||||
|
|||||||
@@ -0,0 +1,338 @@
|
|||||||
|
/* Path/Maze
|
||||||
|
*
|
||||||
|
* This demo shows how to use a GskPath to create a maze and use
|
||||||
|
* gsk_path_measure_get_closest_point() to check the mouse stays
|
||||||
|
* on the path.
|
||||||
|
*
|
||||||
|
* It also shows off the performance of GskPath (or not) as this
|
||||||
|
* is a rather complex path.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "paintable.h"
|
||||||
|
|
||||||
|
#define MAZE_GRID_SIZE 20
|
||||||
|
#define MAZE_STROKE_SIZE_ACTIVE (MAZE_GRID_SIZE - 4)
|
||||||
|
#define MAZE_STROKE_SIZE_INACTIVE (MAZE_GRID_SIZE - 12)
|
||||||
|
#define MAZE_WIDTH 31
|
||||||
|
#define MAZE_HEIGHT 21
|
||||||
|
|
||||||
|
#define GTK_TYPE_MAZE (gtk_maze_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (GtkMaze, gtk_maze, GTK, MAZE, GtkWidget)
|
||||||
|
|
||||||
|
struct _GtkMaze
|
||||||
|
{
|
||||||
|
GtkWidget parent_instance;
|
||||||
|
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
GskPath *path;
|
||||||
|
GskPathMeasure *measure;
|
||||||
|
GdkPaintable *background;
|
||||||
|
|
||||||
|
gboolean active;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GtkMazeClass
|
||||||
|
{
|
||||||
|
GtkWidgetClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GtkMaze, gtk_maze, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_maze_measure (GtkWidget *widget,
|
||||||
|
GtkOrientation orientation,
|
||||||
|
int for_size,
|
||||||
|
int *minimum,
|
||||||
|
int *natural,
|
||||||
|
int *minimum_baseline,
|
||||||
|
int *natural_baseline)
|
||||||
|
{
|
||||||
|
GtkMaze *self = GTK_MAZE (widget);
|
||||||
|
|
||||||
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
|
*minimum = *natural = self->width;
|
||||||
|
else
|
||||||
|
*minimum = *natural = self->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_maze_snapshot (GtkWidget *widget,
|
||||||
|
GdkSnapshot *snapshot)
|
||||||
|
{
|
||||||
|
GtkMaze *self = GTK_MAZE (widget);
|
||||||
|
double width = gtk_widget_get_width (widget);
|
||||||
|
double height = gtk_widget_get_height (widget);
|
||||||
|
GskStroke *stroke;
|
||||||
|
|
||||||
|
stroke = gsk_stroke_new (MAZE_STROKE_SIZE_INACTIVE);
|
||||||
|
if (self->active)
|
||||||
|
gsk_stroke_set_line_width (stroke, MAZE_STROKE_SIZE_ACTIVE);
|
||||||
|
gsk_stroke_set_line_join (stroke, GSK_LINE_JOIN_ROUND);
|
||||||
|
gsk_stroke_set_line_cap (stroke, GSK_LINE_CAP_ROUND);
|
||||||
|
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
|
||||||
|
gsk_stroke_free (stroke);
|
||||||
|
|
||||||
|
if (self->background)
|
||||||
|
{
|
||||||
|
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_snapshot_append_linear_gradient (snapshot,
|
||||||
|
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||||
|
&GRAPHENE_POINT_INIT (0, 0),
|
||||||
|
&GRAPHENE_POINT_INIT (width, height),
|
||||||
|
(GskColorStop[8]) {
|
||||||
|
{ 0.0, { 1.0, 0.0, 0.0, 1.0 } },
|
||||||
|
{ 0.2, { 1.0, 0.0, 0.0, 1.0 } },
|
||||||
|
{ 0.3, { 1.0, 1.0, 0.0, 1.0 } },
|
||||||
|
{ 0.4, { 0.0, 1.0, 0.0, 1.0 } },
|
||||||
|
{ 0.6, { 0.0, 1.0, 1.0, 1.0 } },
|
||||||
|
{ 0.7, { 0.0, 0.0, 1.0, 1.0 } },
|
||||||
|
{ 0.8, { 1.0, 0.0, 1.0, 1.0 } },
|
||||||
|
{ 1.0, { 1.0, 0.0, 1.0, 1.0 } }
|
||||||
|
},
|
||||||
|
8);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_maze_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GtkMaze *self = GTK_MAZE (object);
|
||||||
|
|
||||||
|
g_clear_pointer (&self->path, gsk_path_unref);
|
||||||
|
g_clear_pointer (&self->measure, gsk_path_measure_unref);
|
||||||
|
if (self->background)
|
||||||
|
{
|
||||||
|
g_signal_handlers_disconnect_matched (self->background, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
|
||||||
|
g_clear_object (&self->background);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gtk_maze_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_maze_class_init (GtkMazeClass *klass)
|
||||||
|
{
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = gtk_maze_dispose;
|
||||||
|
|
||||||
|
widget_class->measure = gtk_maze_measure;
|
||||||
|
widget_class->snapshot = gtk_maze_snapshot;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pointer_motion (GtkEventControllerMotion *controller,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
GtkMaze *self)
|
||||||
|
{
|
||||||
|
if (!self->active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gsk_path_measure_get_closest_point (self->measure, &GRAPHENE_POINT_INIT (x, y), NULL) <= MAZE_STROKE_SIZE_ACTIVE / 2.0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
self->active = FALSE;
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pointer_leave (GtkEventControllerMotion *controller,
|
||||||
|
GtkMaze *self)
|
||||||
|
{
|
||||||
|
if (!self->active)
|
||||||
|
{
|
||||||
|
self->active = TRUE;
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_maze_init (GtkMaze *self)
|
||||||
|
{
|
||||||
|
GtkEventController *controller;
|
||||||
|
|
||||||
|
controller = GTK_EVENT_CONTROLLER (gtk_event_controller_motion_new ());
|
||||||
|
g_signal_connect (controller, "motion", G_CALLBACK (pointer_motion), self);
|
||||||
|
g_signal_connect (controller, "leave", G_CALLBACK (pointer_leave), self);
|
||||||
|
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||||
|
|
||||||
|
self->active = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_maze_set_path (GtkMaze *self,
|
||||||
|
GskPath *path)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&self->path, gsk_path_unref);
|
||||||
|
g_clear_pointer (&self->measure, gsk_path_measure_unref);
|
||||||
|
self->path = gsk_path_ref (path);
|
||||||
|
self->measure = gsk_path_measure_new (path);
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gtk_maze_new (GskPath *path,
|
||||||
|
GdkPaintable *background,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
GtkMaze *self;
|
||||||
|
|
||||||
|
self = g_object_new (GTK_TYPE_MAZE, NULL);
|
||||||
|
|
||||||
|
gtk_maze_set_path (self, path);
|
||||||
|
gsk_path_unref (path);
|
||||||
|
self->background = background;
|
||||||
|
if (self->background)
|
||||||
|
{
|
||||||
|
g_signal_connect_swapped (self->background, "invalidate-contents", G_CALLBACK (gtk_widget_queue_draw), self);
|
||||||
|
g_signal_connect_swapped (self->background, "invalidate-size", G_CALLBACK (gtk_widget_queue_resize), self);
|
||||||
|
}
|
||||||
|
self->width = width;
|
||||||
|
self->height = height;
|
||||||
|
|
||||||
|
return GTK_WIDGET (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_point_to_maze (GtkBitset *maze,
|
||||||
|
GskPathBuilder *builder,
|
||||||
|
guint x,
|
||||||
|
guint y)
|
||||||
|
{
|
||||||
|
gboolean set[4] = { FALSE, FALSE, FALSE, FALSE };
|
||||||
|
guint dir;
|
||||||
|
|
||||||
|
gtk_bitset_add (maze, y * MAZE_WIDTH + x);
|
||||||
|
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
set[0] = set[0] || x == 0 || gtk_bitset_contains (maze, y * MAZE_WIDTH + x - 1);
|
||||||
|
set[1] = set[1] || y == 0 || gtk_bitset_contains (maze, (y - 1) * MAZE_WIDTH + x);
|
||||||
|
set[2] = set[2] || x + 1 == MAZE_WIDTH || gtk_bitset_contains (maze, y * MAZE_WIDTH + x + 1);
|
||||||
|
set[3] = set[3] || y + 1 == MAZE_HEIGHT || gtk_bitset_contains (maze, (y + 1) * MAZE_WIDTH + x);
|
||||||
|
|
||||||
|
if (set[0] && set[1] && set[2] && set[3])
|
||||||
|
return;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
dir = g_random_int_range (0, 4);
|
||||||
|
}
|
||||||
|
while (set[dir]);
|
||||||
|
|
||||||
|
switch (dir)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||||
|
gsk_path_builder_line_to (builder, (x - 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||||
|
add_point_to_maze (maze, builder, x - 1, y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||||
|
gsk_path_builder_line_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y - 0.5) * MAZE_GRID_SIZE);
|
||||||
|
add_point_to_maze (maze, builder, x, y - 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||||
|
gsk_path_builder_line_to (builder, (x + 1.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||||
|
add_point_to_maze (maze, builder, x + 1, y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||||
|
gsk_path_builder_line_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 1.5) * MAZE_GRID_SIZE);
|
||||||
|
add_point_to_maze (maze, builder, x, y + 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GskPath *
|
||||||
|
create_path_for_maze (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GskPathBuilder *builder;
|
||||||
|
GtkBitset *maze;
|
||||||
|
|
||||||
|
builder = gsk_path_builder_new ();
|
||||||
|
maze = gtk_bitset_new_empty ();
|
||||||
|
/* make sure the outer lines are unreachable:
|
||||||
|
* Set the full range, then remove the center again. */
|
||||||
|
gtk_bitset_add_range (maze, 0, MAZE_WIDTH * MAZE_HEIGHT);
|
||||||
|
gtk_bitset_remove_rectangle (maze, MAZE_WIDTH + 1, MAZE_WIDTH - 2, MAZE_HEIGHT - 2, MAZE_WIDTH);
|
||||||
|
|
||||||
|
/* Fill the maze */
|
||||||
|
add_point_to_maze (maze, builder, MAZE_WIDTH / 2, MAZE_HEIGHT / 2);
|
||||||
|
|
||||||
|
/* Add start and stop lines */
|
||||||
|
gsk_path_builder_move_to (builder, 1.5 * MAZE_GRID_SIZE, -0.5 * MAZE_GRID_SIZE);
|
||||||
|
gsk_path_builder_line_to (builder, 1.5 * MAZE_GRID_SIZE, 1.5 * MAZE_GRID_SIZE);
|
||||||
|
gsk_path_builder_move_to (builder, (MAZE_WIDTH - 1.5) * MAZE_GRID_SIZE, (MAZE_HEIGHT - 1.5) * MAZE_GRID_SIZE);
|
||||||
|
gsk_path_builder_line_to (builder, (MAZE_WIDTH - 1.5) * MAZE_GRID_SIZE, (MAZE_HEIGHT + 0.5) * MAZE_GRID_SIZE);
|
||||||
|
|
||||||
|
|
||||||
|
gtk_bitset_unref (maze);
|
||||||
|
|
||||||
|
return gsk_path_builder_free_to_path (builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
do_path_maze (GtkWidget *do_widget)
|
||||||
|
{
|
||||||
|
static GtkWidget *window = NULL;
|
||||||
|
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
GtkWidget *maze;
|
||||||
|
GtkMediaStream *stream;
|
||||||
|
GskPath *path;
|
||||||
|
|
||||||
|
window = gtk_window_new ();
|
||||||
|
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||||
|
gtk_window_set_title (GTK_WINDOW (window), "Follow the maze with the mouse");
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||||
|
#else
|
||||||
|
stream = gtk_nuclear_media_stream_new ();
|
||||||
|
#endif
|
||||||
|
gtk_media_stream_play (stream);
|
||||||
|
gtk_media_stream_set_loop (stream, TRUE);
|
||||||
|
|
||||||
|
path = create_path_for_maze (window);
|
||||||
|
|
||||||
|
maze = gtk_maze_new (path,
|
||||||
|
GDK_PAINTABLE (stream),
|
||||||
|
MAZE_WIDTH * MAZE_GRID_SIZE,
|
||||||
|
MAZE_HEIGHT * MAZE_GRID_SIZE);
|
||||||
|
|
||||||
|
gtk_window_set_child (GTK_WINDOW (window), maze);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gtk_widget_get_visible (window))
|
||||||
|
gtk_window_present (GTK_WINDOW (window));
|
||||||
|
else
|
||||||
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
@@ -0,0 +1,580 @@
|
|||||||
|
/* Path/Text
|
||||||
|
*
|
||||||
|
* This demo shows how to use GskPath to animate a path along another path.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#define GTK_TYPE_PATH_WIDGET (gtk_path_widget_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (GtkPathWidget, gtk_path_widget, GTK, PATH_WIDGET, GtkWidget)
|
||||||
|
|
||||||
|
#define POINT_SIZE 8
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_TEXT,
|
||||||
|
PROP_EDITABLE,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GtkPathWidget
|
||||||
|
{
|
||||||
|
GtkWidget parent_instance;
|
||||||
|
|
||||||
|
char *text;
|
||||||
|
gboolean editable;
|
||||||
|
|
||||||
|
graphene_point_t points[4];
|
||||||
|
|
||||||
|
guint active_point;
|
||||||
|
float line_closest;
|
||||||
|
|
||||||
|
GskPath *line_path;
|
||||||
|
GskPathMeasure *line_measure;
|
||||||
|
GskPath *text_path;
|
||||||
|
|
||||||
|
GdkPaintable *background;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GtkPathWidgetClass
|
||||||
|
{
|
||||||
|
GtkWidgetClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GtkPathWidget, gtk_path_widget, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
|
static GskPath *
|
||||||
|
create_path_from_text (GtkWidget *widget,
|
||||||
|
const char *text)
|
||||||
|
{
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
cairo_t *cr;
|
||||||
|
cairo_path_t *path;
|
||||||
|
PangoLayout *layout;
|
||||||
|
PangoFontDescription *desc;
|
||||||
|
GskPath *result;
|
||||||
|
|
||||||
|
surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
||||||
|
cr = cairo_create (surface);
|
||||||
|
|
||||||
|
layout = gtk_widget_create_pango_layout (widget, text);
|
||||||
|
desc = pango_font_description_from_string ("sans bold 36");
|
||||||
|
pango_layout_set_font_description (layout, desc);
|
||||||
|
pango_font_description_free (desc);
|
||||||
|
|
||||||
|
cairo_move_to (cr, 0, - pango_layout_get_baseline (layout) / (double) PANGO_SCALE);
|
||||||
|
pango_cairo_layout_path (cr, layout);
|
||||||
|
path = cairo_copy_path_flat (cr);
|
||||||
|
result = gsk_path_new_from_cairo (path);
|
||||||
|
|
||||||
|
cairo_path_destroy (path);
|
||||||
|
g_object_unref (layout);
|
||||||
|
cairo_destroy (cr);
|
||||||
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GskPathMeasure *measure;
|
||||||
|
GskPathBuilder *builder;
|
||||||
|
double scale;
|
||||||
|
} GtkPathTransform;
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_transform_point (GskPathMeasure *measure,
|
||||||
|
const graphene_point_t *pt,
|
||||||
|
float scale,
|
||||||
|
graphene_point_t *res)
|
||||||
|
{
|
||||||
|
graphene_vec2_t tangent;
|
||||||
|
|
||||||
|
gsk_path_measure_get_point (measure, pt->x * scale, res, &tangent);
|
||||||
|
|
||||||
|
res->x -= pt->y * scale * graphene_vec2_get_y (&tangent);
|
||||||
|
res->y += pt->y * scale * graphene_vec2_get_x (&tangent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gtk_path_transform_op (GskPathOperation op,
|
||||||
|
const graphene_point_t *pts,
|
||||||
|
gsize n_pts,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkPathTransform *transform = data;
|
||||||
|
|
||||||
|
switch (op)
|
||||||
|
{
|
||||||
|
case GSK_PATH_MOVE:
|
||||||
|
{
|
||||||
|
graphene_point_t res;
|
||||||
|
gtk_path_transform_point (transform->measure, &pts[0], transform->scale, &res);
|
||||||
|
gsk_path_builder_move_to (transform->builder, res.x, res.y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GSK_PATH_LINE:
|
||||||
|
{
|
||||||
|
graphene_point_t res;
|
||||||
|
gtk_path_transform_point (transform->measure, &pts[1], transform->scale, &res);
|
||||||
|
gsk_path_builder_line_to (transform->builder, res.x, res.y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GSK_PATH_CURVE:
|
||||||
|
{
|
||||||
|
graphene_point_t res[3];
|
||||||
|
gtk_path_transform_point (transform->measure, &pts[1], transform->scale, &res[0]);
|
||||||
|
gtk_path_transform_point (transform->measure, &pts[2], transform->scale, &res[1]);
|
||||||
|
gtk_path_transform_point (transform->measure, &pts[3], transform->scale, &res[2]);
|
||||||
|
gsk_path_builder_curve_to (transform->builder, res[0].x, res[0].y, res[1].x, res[1].y, res[2].x, res[2].y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GSK_PATH_CLOSE:
|
||||||
|
gsk_path_builder_close (transform->builder);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_assert_not_reached();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GskPath *
|
||||||
|
gtk_path_transform (GskPathMeasure *measure,
|
||||||
|
GskPath *path)
|
||||||
|
{
|
||||||
|
GtkPathTransform transform = { measure, gsk_path_builder_new () };
|
||||||
|
graphene_rect_t bounds;
|
||||||
|
|
||||||
|
gsk_path_get_bounds (path, &bounds);
|
||||||
|
if (bounds.origin.x + bounds.size.width > 0)
|
||||||
|
transform.scale = gsk_path_measure_get_length (measure) / (bounds.origin.x + bounds.size.width);
|
||||||
|
else
|
||||||
|
transform.scale = 1.0f;
|
||||||
|
|
||||||
|
gsk_path_foreach (path, GSK_PATH_FOREACH_ALLOW_CURVES, gtk_path_transform_op, &transform);
|
||||||
|
|
||||||
|
return gsk_path_builder_free_to_path (transform.builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_clear_text_path (GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&self->text_path, gsk_path_unref);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_clear_paths (GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
gtk_path_widget_clear_text_path (self);
|
||||||
|
|
||||||
|
g_clear_pointer (&self->line_path, gsk_path_unref);
|
||||||
|
g_clear_pointer (&self->line_measure, gsk_path_measure_unref);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_create_text_path (GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
GskPath *path;
|
||||||
|
|
||||||
|
gtk_path_widget_clear_text_path (self);
|
||||||
|
|
||||||
|
if (self->line_measure == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
path = create_path_from_text (GTK_WIDGET (self), self->text);
|
||||||
|
self->text_path = gtk_path_transform (self->line_measure, path);
|
||||||
|
|
||||||
|
gsk_path_unref (path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_create_paths (GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||||
|
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||||
|
GskPathBuilder *builder;
|
||||||
|
|
||||||
|
gtk_path_widget_clear_paths (self);
|
||||||
|
|
||||||
|
if (width <= 0 || height <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
builder = gsk_path_builder_new ();
|
||||||
|
gsk_path_builder_move_to (builder,
|
||||||
|
self->points[0].x * width, self->points[0].y * height);
|
||||||
|
gsk_path_builder_curve_to (builder,
|
||||||
|
self->points[1].x * width, self->points[1].y * height,
|
||||||
|
self->points[2].x * width, self->points[2].y * height,
|
||||||
|
self->points[3].x * width, self->points[3].y * height);
|
||||||
|
self->line_path = gsk_path_builder_free_to_path (builder);
|
||||||
|
|
||||||
|
self->line_measure = gsk_path_measure_new (self->line_path);
|
||||||
|
|
||||||
|
gtk_path_widget_create_text_path (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_allocate (GtkWidget *widget,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
int baseline)
|
||||||
|
{
|
||||||
|
GtkPathWidget *self = GTK_PATH_WIDGET (widget);
|
||||||
|
|
||||||
|
GTK_WIDGET_CLASS (gtk_path_widget_parent_class)->size_allocate (widget, width, height, baseline);
|
||||||
|
|
||||||
|
gtk_path_widget_create_paths (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_snapshot (GtkWidget *widget,
|
||||||
|
GtkSnapshot *snapshot)
|
||||||
|
{
|
||||||
|
GtkPathWidget *self = GTK_PATH_WIDGET (widget);
|
||||||
|
double width = gtk_widget_get_width (widget);
|
||||||
|
double height = gtk_widget_get_height (widget);
|
||||||
|
GskPath *path;
|
||||||
|
GskStroke *stroke;
|
||||||
|
gsize i;
|
||||||
|
|
||||||
|
/* frosted glass the background */
|
||||||
|
gtk_snapshot_push_blur (snapshot, 100);
|
||||||
|
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||||
|
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 0.6 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
|
/* draw the text */
|
||||||
|
if (self->text_path)
|
||||||
|
{
|
||||||
|
gtk_snapshot_push_fill (snapshot, self->text_path, GSK_FILL_RULE_WINDING);
|
||||||
|
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||||
|
|
||||||
|
/* ... with an emboss effect */
|
||||||
|
stroke = gsk_stroke_new (2.0);
|
||||||
|
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT(1, 1));
|
||||||
|
gtk_snapshot_push_stroke (snapshot, self->text_path, stroke);
|
||||||
|
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 0.2 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||||
|
gsk_stroke_free (stroke);
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->editable && self->line_path)
|
||||||
|
{
|
||||||
|
GskPathBuilder *builder;
|
||||||
|
|
||||||
|
/* draw the control line */
|
||||||
|
stroke = gsk_stroke_new (1.0);
|
||||||
|
gtk_snapshot_push_stroke (snapshot, self->line_path, stroke);
|
||||||
|
gsk_stroke_free (stroke);
|
||||||
|
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
|
/* draw the points */
|
||||||
|
builder = gsk_path_builder_new ();
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
gsk_path_builder_add_circle (builder, &GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), POINT_SIZE);
|
||||||
|
}
|
||||||
|
path = gsk_path_builder_free_to_path (builder);
|
||||||
|
|
||||||
|
gtk_snapshot_push_fill (snapshot, path, GSK_FILL_RULE_WINDING);
|
||||||
|
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
|
stroke = gsk_stroke_new (1.0);
|
||||||
|
gtk_snapshot_push_stroke (snapshot, path, stroke);
|
||||||
|
gsk_stroke_free (stroke);
|
||||||
|
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
|
gsk_path_unref (path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->line_closest >= 0)
|
||||||
|
{
|
||||||
|
GskPathBuilder *builder;
|
||||||
|
graphene_point_t closest;
|
||||||
|
|
||||||
|
builder = gsk_path_builder_new ();
|
||||||
|
gsk_path_measure_get_point (self->line_measure, self->line_closest, &closest, NULL);
|
||||||
|
gsk_path_builder_add_circle (builder, &closest, POINT_SIZE);
|
||||||
|
path = gsk_path_builder_free_to_path (builder);
|
||||||
|
|
||||||
|
gtk_snapshot_push_fill (snapshot, path, GSK_FILL_RULE_WINDING);
|
||||||
|
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 1, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
|
gsk_path_unref (path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_set_text (GtkPathWidget *self,
|
||||||
|
const char *text)
|
||||||
|
{
|
||||||
|
if (g_strcmp0 (self->text, text) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_free (self->text);
|
||||||
|
self->text = g_strdup (text);
|
||||||
|
|
||||||
|
gtk_path_widget_create_paths (self);
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TEXT]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_set_editable (GtkPathWidget *self,
|
||||||
|
gboolean editable)
|
||||||
|
{
|
||||||
|
if (self->editable == editable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
self->editable = editable;
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EDITABLE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
|
||||||
|
{
|
||||||
|
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_TEXT:
|
||||||
|
gtk_path_widget_set_text (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_EDITABLE:
|
||||||
|
gtk_path_widget_set_editable (self, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_TEXT:
|
||||||
|
g_value_set_string (value, self->text);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_EDITABLE:
|
||||||
|
g_value_set_boolean (value, self->editable);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||||
|
|
||||||
|
gtk_path_widget_clear_paths (self);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gtk_path_widget_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_class_init (GtkPathWidgetClass *klass)
|
||||||
|
{
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = gtk_path_widget_dispose;
|
||||||
|
object_class->set_property = gtk_path_widget_set_property;
|
||||||
|
object_class->get_property = gtk_path_widget_get_property;
|
||||||
|
|
||||||
|
widget_class->size_allocate = gtk_path_widget_allocate;
|
||||||
|
widget_class->snapshot = gtk_path_widget_snapshot;
|
||||||
|
|
||||||
|
properties[PROP_TEXT] =
|
||||||
|
g_param_spec_string ("text",
|
||||||
|
"text",
|
||||||
|
"Text transformed along a path",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
properties[PROP_EDITABLE] =
|
||||||
|
g_param_spec_boolean ("editable",
|
||||||
|
"editable",
|
||||||
|
"If the path can be edited by the user",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
drag_begin (GtkGestureDrag *gesture,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
graphene_point_t mouse = GRAPHENE_POINT_INIT (x, y);
|
||||||
|
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||||
|
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||||
|
gsize i;
|
||||||
|
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (graphene_point_distance (&GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), &mouse, NULL, NULL) <= POINT_SIZE)
|
||||||
|
{
|
||||||
|
self->active_point = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == 4)
|
||||||
|
{
|
||||||
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
drag_update (GtkGestureDrag *drag,
|
||||||
|
double offset_x,
|
||||||
|
double offset_y,
|
||||||
|
GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||||
|
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||||
|
double start_x, start_y;
|
||||||
|
|
||||||
|
gtk_gesture_drag_get_start_point (drag, &start_x, &start_y);
|
||||||
|
|
||||||
|
self->points[self->active_point] = GRAPHENE_POINT_INIT ((start_x + offset_x) / width,
|
||||||
|
(start_y + offset_y) / height);
|
||||||
|
self->points[self->active_point].x = CLAMP (self->points[self->active_point].x, 0, 1);
|
||||||
|
self->points[self->active_point].y = CLAMP (self->points[self->active_point].y, 0, 1);
|
||||||
|
|
||||||
|
gtk_path_widget_create_paths (self);
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pointer_motion (GtkEventControllerMotion *controller,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
gsk_path_measure_get_closest_point_full (self->line_measure,
|
||||||
|
&GRAPHENE_POINT_INIT (x, y),
|
||||||
|
INFINITY,
|
||||||
|
&self->line_closest,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pointer_leave (GtkEventControllerMotion *controller,
|
||||||
|
GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
self->line_closest = -1;
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_path_widget_init (GtkPathWidget *self)
|
||||||
|
{
|
||||||
|
GtkEventController *controller;
|
||||||
|
|
||||||
|
controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ());
|
||||||
|
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
|
||||||
|
g_signal_connect (controller, "drag-update", G_CALLBACK (drag_update), self);
|
||||||
|
g_signal_connect (controller, "drag-end", G_CALLBACK (drag_update), self);
|
||||||
|
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||||
|
|
||||||
|
controller = GTK_EVENT_CONTROLLER (gtk_event_controller_motion_new ());
|
||||||
|
g_signal_connect (controller, "enter", G_CALLBACK (pointer_motion), self);
|
||||||
|
g_signal_connect (controller, "motion", G_CALLBACK (pointer_motion), self);
|
||||||
|
g_signal_connect (controller, "leave", G_CALLBACK (pointer_leave), self);
|
||||||
|
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||||
|
|
||||||
|
self->line_closest = -1;
|
||||||
|
|
||||||
|
self->points[0] = GRAPHENE_POINT_INIT (0.1, 0.9);
|
||||||
|
self->points[1] = GRAPHENE_POINT_INIT (0.3, 0.1);
|
||||||
|
self->points[2] = GRAPHENE_POINT_INIT (0.7, 0.1);
|
||||||
|
self->points[3] = GRAPHENE_POINT_INIT (0.9, 0.9);
|
||||||
|
|
||||||
|
self->background = GDK_PAINTABLE (gdk_texture_new_from_resource ("/sliding_puzzle/portland-rose.jpg"));
|
||||||
|
|
||||||
|
gtk_path_widget_set_text (self, "It's almost working");
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gtk_path_widget_new (void)
|
||||||
|
{
|
||||||
|
GtkPathWidget *self;
|
||||||
|
|
||||||
|
self = g_object_new (GTK_TYPE_PATH_WIDGET, NULL);
|
||||||
|
|
||||||
|
return GTK_WIDGET (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
do_path_text (GtkWidget *do_widget)
|
||||||
|
{
|
||||||
|
static GtkWidget *window = NULL;
|
||||||
|
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
GtkBuilder *builder;
|
||||||
|
|
||||||
|
g_type_ensure (GTK_TYPE_PATH_WIDGET);
|
||||||
|
|
||||||
|
builder = gtk_builder_new_from_resource ("/path_text/path_text.ui");
|
||||||
|
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||||
|
gtk_window_set_display (GTK_WINDOW (window),
|
||||||
|
gtk_widget_get_display (do_widget));
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||||
|
g_object_unref (builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gtk_widget_get_visible (window))
|
||||||
|
gtk_window_present (GTK_WINDOW (window));
|
||||||
|
else
|
||||||
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<object class="GtkWindow" id="window">
|
||||||
|
<property name="title" translatable="yes">Text along a Path</property>
|
||||||
|
<child type="titlebar">
|
||||||
|
<object class="GtkHeaderBar">
|
||||||
|
<child type="end">
|
||||||
|
<object class="GtkToggleButton" id="edit-toggle">
|
||||||
|
<property name="icon-name">document-edit-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRevealer">
|
||||||
|
<property name="reveal-child" bind-source="edit-toggle" bind-property="active" bind-flags="sync-create"></property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="text">
|
||||||
|
<property name="text">Through the looking glass</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkPathWidget" id="view">
|
||||||
|
<property name="editable" bind-source="edit-toggle" bind-property="active" bind-flags="sync-create"></property>
|
||||||
|
<property name="text" bind-source="text" bind-property="text" bind-flags="sync-create"></property>
|
||||||
|
<property name="hexpand">true</property>
|
||||||
|
<property name="vexpand">true</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
@@ -6,6 +6,6 @@
|
|||||||
* Also, when adding new style properties, please add them here.
|
* Also, when adding new style properties, please add them here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.demo * {
|
* {
|
||||||
all: unset;
|
all: unset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,20 +188,10 @@ do_spinbutton (GtkWidget *do_widget)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkBuilderScope *scope;
|
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adj;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
|
|
||||||
scope = gtk_builder_cscope_new ();
|
builder = gtk_builder_new_from_resource ("/spinbutton/spinbutton.ui");
|
||||||
builder = gtk_builder_new ();
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_hex_spin_input);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_hex_spin_output);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_time_spin_input);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_time_spin_output);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_month_spin_input);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_month_spin_output);
|
|
||||||
gtk_builder_set_scope (builder, scope);
|
|
||||||
gtk_builder_add_from_resource (builder, "/spinbutton/spinbutton.ui", NULL);
|
|
||||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||||
gtk_window_set_display (GTK_WINDOW (window),
|
gtk_window_set_display (GTK_WINDOW (window),
|
||||||
gtk_widget_get_display (do_widget));
|
gtk_widget_get_display (do_widget));
|
||||||
@@ -243,7 +233,6 @@ do_spinbutton (GtkWidget *do_widget)
|
|||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
g_object_unref (scope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ GtkWidget *
|
|||||||
do_spinner (GtkWidget *do_widget)
|
do_spinner (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
static GtkWidget *window = NULL;
|
static GtkWidget *window = NULL;
|
||||||
|
GtkWidget *content_area;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
@@ -34,19 +35,28 @@ do_spinner (GtkWidget *do_widget)
|
|||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
window = gtk_window_new ();
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
window = gtk_dialog_new_with_buttons ("Spinner",
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "Spinner");
|
GTK_WINDOW (do_widget),
|
||||||
|
0,
|
||||||
|
_("_Close"),
|
||||||
|
GTK_RESPONSE_NONE,
|
||||||
|
NULL);
|
||||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||||
|
|
||||||
|
g_signal_connect (window, "response",
|
||||||
|
G_CALLBACK (gtk_window_destroy), NULL);
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
|
||||||
gtk_widget_set_margin_top (vbox, 5);
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
gtk_widget_set_margin_bottom (vbox, 5);
|
|
||||||
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||||
gtk_widget_set_margin_start (vbox, 5);
|
gtk_widget_set_margin_start (vbox, 5);
|
||||||
gtk_widget_set_margin_end (vbox, 5);
|
gtk_widget_set_margin_end (vbox, 5);
|
||||||
|
gtk_widget_set_margin_top (vbox, 5);
|
||||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
gtk_widget_set_margin_bottom (vbox, 5);
|
||||||
|
gtk_box_append (GTK_BOX (content_area), vbox);
|
||||||
|
|
||||||
/* Sensitive */
|
/* Sensitive */
|
||||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||||
|
|||||||
@@ -801,7 +801,7 @@ suggestion_entry_key_pressed (GtkEventControllerKey *controller,
|
|||||||
selected = matches - 1;
|
selected = matches - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_list_view_scroll_to (GTK_LIST_VIEW (self->list), selected, GTK_LIST_SCROLL_SELECT, NULL);
|
gtk_single_selection_set_selected (self->selection, selected);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include "demo_conf.h"
|
#include "demo_conf.h"
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
static GtkWidget *main_window;
|
static GtkWidget *main_window;
|
||||||
static GFile *filename = NULL;
|
static GFile *filename = NULL;
|
||||||
static GtkPageSetup *page_setup = NULL;
|
static GtkPageSetup *page_setup = NULL;
|
||||||
@@ -41,7 +43,7 @@ update_statusbar (void)
|
|||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
const char *print_str;
|
const char *print_str;
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (statusbar), "");
|
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 0);
|
||||||
|
|
||||||
gtk_text_buffer_get_iter_at_mark (buffer,
|
gtk_text_buffer_get_iter_at_mark (buffer,
|
||||||
&iter,
|
&iter,
|
||||||
@@ -59,10 +61,10 @@ update_statusbar (void)
|
|||||||
|
|
||||||
msg = g_strdup_printf ("%d, %d%s %s",
|
msg = g_strdup_printf ("%d, %d%s %s",
|
||||||
row, col,
|
row, col,
|
||||||
file_changed?" - Modified":"",
|
file_changed?" - Modified":"",
|
||||||
print_str);
|
print_str);
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (statusbar), msg);
|
gtk_statusbar_push (GTK_STATUSBAR (statusbar), 0, msg);
|
||||||
|
|
||||||
g_free (msg);
|
g_free (msg);
|
||||||
}
|
}
|
||||||
@@ -825,12 +827,7 @@ activate (GApplication *app)
|
|||||||
contents);
|
contents);
|
||||||
|
|
||||||
/* Create statusbar */
|
/* Create statusbar */
|
||||||
statusbar = gtk_label_new ("");
|
statusbar = gtk_statusbar_new ();
|
||||||
gtk_label_set_xalign (GTK_LABEL (statusbar), 0);
|
|
||||||
gtk_widget_set_margin_start (statusbar, 2);
|
|
||||||
gtk_widget_set_margin_end (statusbar, 2);
|
|
||||||
gtk_widget_set_margin_top (statusbar, 2);
|
|
||||||
gtk_widget_set_margin_bottom (statusbar, 2);
|
|
||||||
gtk_box_append (GTK_BOX (box), statusbar);
|
gtk_box_append (GTK_BOX (box), statusbar);
|
||||||
|
|
||||||
/* Show text widget info in the statusbar */
|
/* Show text widget info in the statusbar */
|
||||||
|
|||||||
@@ -5,6 +5,16 @@ How to do a GTK release?
|
|||||||
|
|
||||||
Make sure you have suitable versions of Meson and Ninja.
|
Make sure you have suitable versions of Meson and Ninja.
|
||||||
|
|
||||||
|
Also make sure you have the following packages installed with all their
|
||||||
|
dependencies:
|
||||||
|
|
||||||
|
* gtk-doc
|
||||||
|
* docbook-utils
|
||||||
|
|
||||||
|
Without those packages make distcheck will *not* pass.
|
||||||
|
|
||||||
|
Make sure that gtk-doc is the latest released version.
|
||||||
|
|
||||||
## Release check list
|
## Release check list
|
||||||
|
|
||||||
0. Save all your work, then move to the branch from which you want
|
0. Save all your work, then move to the branch from which you want
|
||||||
@@ -18,8 +28,8 @@ $ git clean -dfx
|
|||||||
1. Build using the common sequence:
|
1. Build using the common sequence:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ meson setup _build
|
$ meson _build .
|
||||||
$ meson compile -C _build
|
$ ninja -C _build
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Update NEWS based on the content of git log; follow the format of prior
|
2. Update NEWS based on the content of git log; follow the format of prior
|
||||||
@@ -30,10 +40,11 @@ $ meson compile -C _build
|
|||||||
writers, committers, etc. Anybody who is mentioned in the commit log
|
writers, committers, etc. Anybody who is mentioned in the commit log
|
||||||
gets a credit, but only real names, not email addresses or nicknames.
|
gets a credit, but only real names, not email addresses or nicknames.
|
||||||
|
|
||||||
3. Update the pot file and commit the changes:
|
3. Update the pot files and commit the changes:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ninja -C _build gtk40-pot
|
$ ninja -C _build gtk40-pot
|
||||||
|
$ ninja -C _build gtk40-properties-pot
|
||||||
```
|
```
|
||||||
|
|
||||||
4. If this is a major, stable, release, verify that the release notes
|
4. If this is a major, stable, release, verify that the release notes
|
||||||
@@ -61,7 +72,7 @@ $ ninja -C _build gtk40-pot
|
|||||||
Make sure that all new symbols have proper Since: tags, and that there
|
Make sure that all new symbols have proper Since: tags, and that there
|
||||||
is an index in the main `-docs.xml` for the next stable version.
|
is an index in the main `-docs.xml` for the next stable version.
|
||||||
|
|
||||||
8. Run `meson dist -C_build` to generate the tarball.
|
8. Run `ninja dist` to generate the tarball.
|
||||||
|
|
||||||
9. Fix broken stuff found by 8), commit changes, repeat.
|
9. Fix broken stuff found by 8), commit changes, repeat.
|
||||||
|
|
||||||
@@ -83,8 +94,7 @@ $ ninja -C _build gtk40-pot
|
|||||||
$ git tag -m "GTK 4.2.0" 4.2.0
|
$ git tag -m "GTK 4.2.0" 4.2.0
|
||||||
```
|
```
|
||||||
|
|
||||||
13. Bump the version number in `meson.build`, and add a section for the next
|
13. Bump the version number in `meson.build` and commit the change.
|
||||||
release in NEWS and commit the change.
|
|
||||||
|
|
||||||
14. Push the changes upstream, and push the tag as well. The git command for
|
14. Push the changes upstream, and push the tag as well. The git command for
|
||||||
doing that is:
|
doing that is:
|
||||||
@@ -101,8 +111,7 @@ $ git push origin 4.2.0
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ scp gtk-4.2.0.tar.xz matthiasc@master.gnome.org:
|
$ scp gtk-4.2.0.tar.xz matthiasc@master.gnome.org:
|
||||||
$ ssh matthiasc@master.gnome.org
|
$ ssh matthiasc@master.gnome.org ftpadmin install gtk-4.2.0.tar.xz
|
||||||
$ ftpadmin install gtk-4.2.0.tar.xz
|
|
||||||
```
|
```
|
||||||
|
|
||||||
16. Go to the gnome-announce list archives, find the last announce message,
|
16. Go to the gnome-announce list archives, find the last announce message,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
expand_content_md_files = [
|
expand_content_md_files = [
|
||||||
]
|
]
|
||||||
|
|
||||||
if get_option('documentation')
|
if get_option('gtk_doc')
|
||||||
gdk4_toml = configure_file(
|
gdk4_toml = configure_file(
|
||||||
input: 'gdk4.toml.in',
|
input: 'gdk4.toml.in',
|
||||||
output: 'gdk4.toml',
|
output: 'gdk4.toml',
|
||||||
|
|||||||
@@ -34,11 +34,5 @@ base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/"
|
|||||||
[extra]
|
[extra]
|
||||||
content_images = [
|
content_images = [
|
||||||
"gtk-logo.svg",
|
"gtk-logo.svg",
|
||||||
"images/caps-dark.png",
|
|
||||||
"images/caps-light.png",
|
|
||||||
"images/join-dark.png",
|
|
||||||
"images/join-light.png",
|
|
||||||
"images/path-dark.png",
|
|
||||||
"images/path-light.png",
|
|
||||||
]
|
]
|
||||||
urlmap_file = "urlmap.js"
|
urlmap_file = "urlmap.js"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB |
@@ -1,81 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="210mm"
|
|
||||||
height="297mm"
|
|
||||||
viewBox="0 0 210 297"
|
|
||||||
version="1.1"
|
|
||||||
id="svg1"
|
|
||||||
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
|
|
||||||
sodipodi:docname="caps.svg"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="namedview1"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#000000"
|
|
||||||
borderopacity="0.25"
|
|
||||||
inkscape:showpageshadow="2"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pagecheckerboard="0"
|
|
||||||
inkscape:deskcolor="#d1d1d1"
|
|
||||||
inkscape:document-units="mm"
|
|
||||||
inkscape:zoom="2.1493149"
|
|
||||||
inkscape:cx="438.74445"
|
|
||||||
inkscape:cy="288.69664"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1123"
|
|
||||||
inkscape:window-x="0"
|
|
||||||
inkscape:window-y="0"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:current-layer="layer1" />
|
|
||||||
<defs
|
|
||||||
id="defs1">
|
|
||||||
<linearGradient
|
|
||||||
id="swatch1"
|
|
||||||
inkscape:swatch="solid">
|
|
||||||
<stop
|
|
||||||
style="stop-color:#000000;stop-opacity:1;"
|
|
||||||
offset="0"
|
|
||||||
id="stop1" />
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1">
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#000064;stroke-width:1;stroke-miterlimit:0;stroke-dasharray:none"
|
|
||||||
d="m 73.096455,77.084329 c 0,0 6.439436,18.711677 18.172676,26.635721"
|
|
||||||
id="path1"
|
|
||||||
sodipodi:nodetypes="cc" />
|
|
||||||
<path
|
|
||||||
style="color:#000000;fill:none;stroke:#000064;stroke-width:0.2;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 94.214979,99.722163 c -4.705477,-3.177832 -9.013472,-9.233699 -11.888672,-14.531169 -2.8752,-5.29748 -4.353516,-9.587833 -4.353516,-9.587833 L 68.51576,78.85704 c 0,0 1.743663,5.064163 5.021484,11.103457 3.277822,6.039297 8.05428,13.302573 15.082031,18.048773"
|
|
||||||
id="path1-1"
|
|
||||||
sodipodi:nodetypes="csccsc" />
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#000064;stroke-width:1;stroke-miterlimit:0;stroke-dasharray:none"
|
|
||||||
d="m 112.14213,75.736452 c 0,0 6.43944,18.711675 18.17268,26.635728"
|
|
||||||
id="path1-4"
|
|
||||||
sodipodi:nodetypes="cc" />
|
|
||||||
<path
|
|
||||||
style="color:#000000;fill:none;stroke:#000064;stroke-width:0.2;stroke-linecap:round;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 132.83284,98.590758 c -4.70551,-3.177807 -9.01347,-9.233742 -11.88867,-14.53125 -2.8752,-5.297508 -4.35351,-9.587891 -4.35351,-9.587891 -0.89828,-2.611719 -3.74396,-4.000453 -6.35547,-3.101562 -2.61172,0.898277 -4.00046,3.743958 -3.10157,6.355468 0,0 1.74367,5.064185 5.02149,11.103516 3.27782,6.039331 8.05428,13.302641 15.08203,18.048851"
|
|
||||||
id="path1-4-5"
|
|
||||||
sodipodi:nodetypes="cscccsc" />
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#000064;stroke-width:1;stroke-miterlimit:0;stroke-dasharray:none"
|
|
||||||
d="m 154.10911,73.84561 c 0,0 6.43943,18.711677 18.17267,26.63572"
|
|
||||||
id="path1-0"
|
|
||||||
sodipodi:nodetypes="cc" />
|
|
||||||
<path
|
|
||||||
style="color:#000000;fill:none;stroke:#000064;stroke-width:0.2;stroke-linecap:square;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="M 175.16683,96.47344 C 170.46135,93.295592 166.1514,87.239699 163.2762,81.94219 160.401,76.644682 158.92269,72.3543 158.92269,72.3543 l -1.62696,-4.728516 -9.45508,3.253906 1.62696,4.728516 c 0,0 1.74171,5.066138 5.01953,11.105469 3.27782,6.039331 8.05428,13.300675 15.08203,18.046895"
|
|
||||||
id="path1-4-1"
|
|
||||||
sodipodi:nodetypes="csccccsc" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 21 KiB |
@@ -1,72 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="210mm"
|
|
||||||
height="297mm"
|
|
||||||
viewBox="0 0 210 297"
|
|
||||||
version="1.1"
|
|
||||||
id="svg1"
|
|
||||||
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
|
|
||||||
sodipodi:docname="join.svg"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="namedview1"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#000000"
|
|
||||||
borderopacity="0.25"
|
|
||||||
inkscape:showpageshadow="2"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pagecheckerboard="0"
|
|
||||||
inkscape:deskcolor="#d1d1d1"
|
|
||||||
inkscape:document-units="mm"
|
|
||||||
inkscape:zoom="0.75989759"
|
|
||||||
inkscape:cx="118.43701"
|
|
||||||
inkscape:cy="570.47161"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1123"
|
|
||||||
inkscape:window-x="0"
|
|
||||||
inkscape:window-y="0"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:current-layer="layer1" />
|
|
||||||
<defs
|
|
||||||
id="defs1" />
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1">
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#000064;stroke-width:1;stroke-linecap:square;stroke-miterlimit:10;stroke-dasharray:none"
|
|
||||||
d="m 12.748727,122.15935 c 4.449842,-15.44496 4.175632,-15.92044 16.908788,-26.568585 0,0 8.478091,16.421195 35.150804,33.660325"
|
|
||||||
id="path1"
|
|
||||||
sodipodi:nodetypes="ccc" />
|
|
||||||
<path
|
|
||||||
style="color:#000000;fill:none;stroke:#000064;stroke-width:0.2;stroke-linecap:square;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 17.59375,123.72266 c 3.810222,-13.2249 3.591775,-14.13123 11.107422,-20.53516 1.289688,1.82186 2.604788,3.71164 4.800781,6.23242 5.743296,6.59272 14.891452,15.32766 28.632813,24.20899 M 67.5625,125.23047 C 54.631174,116.87268 46.204933,108.77726 41.041016,102.84961 35.877098,96.921954 34.140625,93.474609 34.140625,93.474609 l -2.861328,-5.544922 -4.789063,4.003907 C 13.673794,102.6514 12.411529,105.58692 7.984375,120.95313"
|
|
||||||
id="path1-3"
|
|
||||||
sodipodi:nodetypes="ccsccscccc" />
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#000064;stroke-width:1;stroke-linecap:square;stroke-miterlimit:10;stroke-dasharray:none"
|
|
||||||
d="m 147.99215,122.60257 c 4.44988,-15.44499 4.17566,-15.92048 16.90889,-26.568657 0,0 8.47814,16.421267 35.15101,33.660397"
|
|
||||||
id="path1-5"
|
|
||||||
sodipodi:nodetypes="ccc" />
|
|
||||||
<path
|
|
||||||
style="color:#000000;fill:none;stroke:#000064;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 152.79687,123.98633 c 3.81053,-13.22586 3.59005,-14.12993 11.10743,-20.53516 1.28968,1.82184 2.6029,3.71173 4.79882,6.23242 5.74333,6.59274 14.89333,15.32961 28.63477,24.21094 m 5.42773,-8.40039 c -12.9314,-8.35778 -21.35753,-16.45123 -26.52148,-22.37891 -5.16395,-5.927668 -6.90039,-9.374996 -6.90039,-9.374996 l -7.65039,-1.541015 C 148.87685,102.91706 147.61469,105.85252 143.1875,121.21875"
|
|
||||||
id="path1-5-8"
|
|
||||||
sodipodi:nodetypes="ccsccsccc" />
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#000064;stroke-width:1;stroke-linecap:square;stroke-miterlimit:10;stroke-dasharray:none"
|
|
||||||
d="m 79.729342,122.0734 c 4.449844,-15.44499 4.175634,-15.92048 16.908794,-26.568654 0,0 8.478114,16.421264 35.150984,33.660394"
|
|
||||||
id="path1-7"
|
|
||||||
sodipodi:nodetypes="ccc" />
|
|
||||||
<path
|
|
||||||
style="color:#000000;fill:none;stroke:#000064;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 84.533203,123.19336 c 3.810222,-13.22495 3.591776,-14.1312 11.107422,-20.53516 1.289696,1.82187 2.604775,3.71164 4.800785,6.23243 5.74333,6.59275 14.89136,15.32765 28.63281,24.20898 m 5.42969,-8.39844 c -12.93141,-8.35778 -21.35949,-16.45122 -26.52344,-22.3789 -5.16395,-5.927686 -6.90039,-9.375004 -6.90039,-9.375004 -0.69636,-1.348401 -1.967393,-2.307601 -3.45508,-2.607422 -1.487509,-0.300132 -3.03083,0.09145 -4.195313,1.064453 C 80.61325,102.12215 79.350982,105.05756 74.923828,120.42383"
|
|
||||||
id="path1-7-4"
|
|
||||||
sodipodi:nodetypes="ccsccscccc" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -1,108 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="210mm"
|
|
||||||
height="297mm"
|
|
||||||
viewBox="0 0 210 297"
|
|
||||||
version="1.1"
|
|
||||||
id="svg1"
|
|
||||||
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
|
|
||||||
sodipodi:docname="path.svg"
|
|
||||||
inkscape:export-filename="path-dark.png"
|
|
||||||
inkscape:export-xdpi="96"
|
|
||||||
inkscape:export-ydpi="96"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="namedview1"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#000000"
|
|
||||||
borderopacity="0.25"
|
|
||||||
inkscape:showpageshadow="2"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pagecheckerboard="0"
|
|
||||||
inkscape:deskcolor="#d1d1d1"
|
|
||||||
inkscape:document-units="mm"
|
|
||||||
inkscape:zoom="0.75989759"
|
|
||||||
inkscape:cx="397.42198"
|
|
||||||
inkscape:cy="561.25984"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1123"
|
|
||||||
inkscape:window-x="0"
|
|
||||||
inkscape:window-y="0"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:current-layer="layer1" />
|
|
||||||
<defs
|
|
||||||
id="defs1" />
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1">
|
|
||||||
<path
|
|
||||||
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="M 128.28233,149.47912 154.23127,90.244656 86.340809,68.820468"
|
|
||||||
id="path3" />
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;fill-opacity:1;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 33.956804,113.31099 c -9.049189,-11.90893 5.40551,-40.570358 20.351208,-39.990271 26.687501,1.035822 4.06495,71.984581 30.695656,74.009711 19.642072,1.49368 41.962402,-34.42048 30.634382,-50.536241 C 99.663884,74.068616 50.763019,135.42833 33.956804,113.31099 Z"
|
|
||||||
id="path1"
|
|
||||||
sodipodi:nodetypes="sssss" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000000;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path2"
|
|
||||||
cx="34.517788"
|
|
||||||
cy="113.66589"
|
|
||||||
r="1.5" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000064;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none"
|
|
||||||
id="path2-8"
|
|
||||||
cx="55.045853"
|
|
||||||
cy="73.566689"
|
|
||||||
r="1.5" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000064;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none"
|
|
||||||
id="path2-8-5"
|
|
||||||
cx="55.045834"
|
|
||||||
cy="73.831245"
|
|
||||||
r="1.5" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000000;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path2-8-9"
|
|
||||||
cx="55.045834"
|
|
||||||
cy="73.831245"
|
|
||||||
r="1.5" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000000;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path2-8-9-7"
|
|
||||||
cx="86.398613"
|
|
||||||
cy="68.897667"
|
|
||||||
r="1.5" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000000;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path2-8-9-7-8"
|
|
||||||
cx="153.87553"
|
|
||||||
cy="90.112595"
|
|
||||||
r="1.5" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000064;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none"
|
|
||||||
id="path2-8-7"
|
|
||||||
cx="84.803238"
|
|
||||||
cy="147.51736"
|
|
||||||
r="1.5" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000000;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path2-8-7-2"
|
|
||||||
cx="115.28235"
|
|
||||||
cy="96.705284"
|
|
||||||
r="1.5" />
|
|
||||||
<circle
|
|
||||||
style="fill:#ff0404;fill-opacity:1;stroke:#000000;stroke-width:0.2;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path2-8-9-7-9"
|
|
||||||
cx="127.92362"
|
|
||||||
cy="150.03427"
|
|
||||||
r="1.5" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 4.4 KiB |
@@ -1,4 +1,4 @@
|
|||||||
if get_option('documentation')
|
if get_option('gtk_doc')
|
||||||
gsk4_toml = configure_file(
|
gsk4_toml = configure_file(
|
||||||
input: 'gsk4.toml.in',
|
input: 'gsk4.toml.in',
|
||||||
output: 'gsk4.toml',
|
output: 'gsk4.toml',
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ support in the file chooser.
|
|||||||
This option controls whether GTK should use colord for color
|
This option controls whether GTK should use colord for color
|
||||||
calibration support in the cups print backend.
|
calibration support in the cups print backend.
|
||||||
|
|
||||||
### `documentation`, `man-pages` and `screenshots`
|
### `gtk_doc`, `man-pages` and `update_screenshots`
|
||||||
|
|
||||||
The *gi-docgen* package is used to generate the reference documentation
|
The *gi-docgen* package is used to generate the reference documentation
|
||||||
included with GTK. By default support for *gi-docgen* is disabled
|
included with GTK. By default support for *gi-docgen* is disabled
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ using `gtk_application_new()`.
|
|||||||
When creating a [class@Gtk.Application], you need to pick an application
|
When creating a [class@Gtk.Application], you need to pick an application
|
||||||
identifier (a name) and pass it to [ctor@Gtk.Application.new] as parameter. For
|
identifier (a name) and pass it to [ctor@Gtk.Application.new] as parameter. For
|
||||||
this example `org.gtk.example` is used. For choosing an identifier for your
|
this example `org.gtk.example` is used. For choosing an identifier for your
|
||||||
application, see [this guide](https://developer.gnome.org/documentation/tutorials/application-id.html).
|
application, see [this guide](https://wiki.gnome.org/HowDoI/ChooseApplicationID).
|
||||||
Lastly, [ctor@Gtk.Application.new] takes `GApplicationFlags` as input
|
Lastly, [ctor@Gtk.Application.new] takes `GApplicationFlags` as input
|
||||||
for your application, if your application would have special needs.
|
for your application, if your application would have special needs.
|
||||||
|
|
||||||
Next the [activate signal](https://developer.gnome.org/documentation/tutorials/application.html) is
|
Next the [activate signal](https://wiki.gnome.org/HowDoI/GtkApplication) is
|
||||||
connected to the activate() function above the `main()` function. The `activate`
|
connected to the activate() function above the `main()` function. The `activate`
|
||||||
signal will be emitted when your application is launched with `g_application_run()`
|
signal will be emitted when your application is launched with `g_application_run()`
|
||||||
on the line below. The `g_application_run()` call also takes as arguments the
|
on the line below. The `g_application_run()` call also takes as arguments the
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
.. _gtk4-rendernode-tool(1):
|
|
||||||
|
|
||||||
====================
|
|
||||||
gtk4-rendernode-tool
|
|
||||||
====================
|
|
||||||
|
|
||||||
-----------------------
|
|
||||||
GskRenderNode Utility
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
--------
|
|
||||||
| **gtk4-rendernode-tool** <COMMAND> [OPTIONS...] <FILE>
|
|
||||||
|
|
|
||||||
| **gtk4-rendernode-tool** info [OPTIONS...] <FILE>
|
|
||||||
| **gtk4-rendernode-tool** show [OPTIONS...] <FILE>
|
|
||||||
| **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>]
|
|
||||||
|
|
||||||
DESCRIPTION
|
|
||||||
-----------
|
|
||||||
|
|
||||||
``gtk4-rendernode-tool`` can perform various operations on serialized rendernodes.
|
|
||||||
|
|
||||||
COMMANDS
|
|
||||||
--------
|
|
||||||
|
|
||||||
Information
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
The ``info`` command shows general information about the rendernode, such
|
|
||||||
as the number of nodes, and the depth of the tree.
|
|
||||||
|
|
||||||
Showing
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
The ``show`` command displays the rendernode.
|
|
||||||
|
|
||||||
Rendering
|
|
||||||
^^^^^^^^^
|
|
||||||
|
|
||||||
The ``render`` command saves a rendering of the rendernode as a png or tiff image.
|
|
||||||
The name of the file to write can be specified as a second FILE argument.
|
|
||||||
|
|
||||||
``--renderer=RENDERER``
|
|
||||||
|
|
||||||
Use the given renderer. Use ``--renderer=help`` to get a information
|
|
||||||
about poassible values for the ``RENDERER``.
|
|
||||||
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 147 B |
@@ -78,7 +78,7 @@ ui_files = [
|
|||||||
|
|
||||||
gtk_builder_tool = find_program('gtk4-builder-tool')
|
gtk_builder_tool = find_program('gtk4-builder-tool')
|
||||||
|
|
||||||
if get_option('screenshots')
|
if get_option('update_screenshots')
|
||||||
foreach ui_file: ui_files
|
foreach ui_file: ui_files
|
||||||
png_file = ui_file.replace('.ui', '.png')
|
png_file = ui_file.replace('.ui', '.png')
|
||||||
gtk_images += custom_target('@0@ from @1@'.format(png_file, ui_file),
|
gtk_images += custom_target('@0@ from @1@'.format(png_file, ui_file),
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ gtk_images = []
|
|||||||
|
|
||||||
subdir('images')
|
subdir('images')
|
||||||
|
|
||||||
if get_option('documentation')
|
if get_option('gtk_doc')
|
||||||
gtk4_toml = configure_file(
|
gtk4_toml = configure_file(
|
||||||
input: 'gtk4.toml.in',
|
input: 'gtk4.toml.in',
|
||||||
output: 'gtk4.toml',
|
output: 'gtk4.toml',
|
||||||
@@ -75,7 +75,6 @@ if get_option('man-pages') and rst2man.found()
|
|||||||
[ 'gtk4-encode-symbolic-svg', '1', ],
|
[ 'gtk4-encode-symbolic-svg', '1', ],
|
||||||
[ 'gtk4-launch', '1', ],
|
[ 'gtk4-launch', '1', ],
|
||||||
[ 'gtk4-query-settings', '1', ],
|
[ 'gtk4-query-settings', '1', ],
|
||||||
[ 'gtk4-rendernode-tool', '1' ],
|
|
||||||
[ 'gtk4-update-icon-cache', '1', ],
|
[ 'gtk4-update-icon-cache', '1', ],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ A number of keys are influencing behavior instead of just logging:
|
|||||||
`no-css-cache`
|
`no-css-cache`
|
||||||
: Bypass caching for CSS style properties
|
: Bypass caching for CSS style properties
|
||||||
|
|
||||||
|
`touchscreen`
|
||||||
|
: Pretend the pointer is a touchscreen device
|
||||||
|
|
||||||
`snapshot`
|
`snapshot`
|
||||||
: Include debug render nodes in the generated snapshots
|
: Include debug render nodes in the generated snapshots
|
||||||
|
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ It is possible to set accessible attributes in UI files as well:
|
|||||||
<accessibility>
|
<accessibility>
|
||||||
<property name="label">Download</property>
|
<property name="label">Download</property>
|
||||||
<relation name="labelled-by">label1</relation>
|
<relation name="labelled-by">label1</relation>
|
||||||
</accessibility>
|
/accessibility>
|
||||||
</object>
|
</object>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ Views display data from a **_model_**. Models implement the [`iface@Gio.ListMode
|
|||||||
interface and can be provided in a variety of ways:
|
interface and can be provided in a variety of ways:
|
||||||
|
|
||||||
* List model implementations for many specific types of data already exist, for
|
* List model implementations for many specific types of data already exist, for
|
||||||
example [`class@Gtk.DirectoryList`] or [`class@Gtk.StringList`].
|
example `GtkDirectoryList` or `GtkStringList`.
|
||||||
|
|
||||||
* There are generic list model implementations like [`class@Gio.ListStore`] that allow building
|
* There are generic list model implementations like`GListStore` that allow building
|
||||||
lists of arbitrary objects.
|
lists of arbitrary objects.
|
||||||
|
|
||||||
* Wrapping list models like [`class@Gtk.FilterListModel`] or [`class@Gtk.SortListModel`]
|
* Wrapping list models like `GtkFilterListModel` or `GtkSortListModel`
|
||||||
modify, adapt or combine other models.
|
modify, adapt or combine other models.
|
||||||
|
|
||||||
* Last but not least, developers are encouraged to create their own `GListModel`
|
* Last but not least, developers are encouraged to create their own `GListModel`
|
||||||
@@ -133,8 +133,8 @@ tradeoffs of those and experiment with them.
|
|||||||
|
|
||||||
GTK offers a wide variety of wrapping models which change or supplement an
|
GTK offers a wide variety of wrapping models which change or supplement an
|
||||||
existing model (or models) in some way. But when it comes to storing your
|
existing model (or models) in some way. But when it comes to storing your
|
||||||
actual data, there are only a few ready-made choices available:
|
actual data, there are only a few ready-made choices available: [`class@Gio.ListStore`]
|
||||||
[`class@Gio.ListStore`], [`class@Gtk.StringList`], and [`class@Gtk.DirectoryList`].
|
and [`class@Gtk.StringList`].
|
||||||
|
|
||||||
`GListStore` is backed by a balanced tree and has performance characteristics
|
`GListStore` is backed by a balanced tree and has performance characteristics
|
||||||
that are expected for that data structure. It works reasonably well for dataset
|
that are expected for that data structure. It works reasonably well for dataset
|
||||||
@@ -147,10 +147,6 @@ that are expected for that data structure. `GtkStringList` is a good fit for any
|
|||||||
place where you would otherwise use `char*[]` and works best if the dataset
|
place where you would otherwise use `char*[]` and works best if the dataset
|
||||||
is not very dynamic.
|
is not very dynamic.
|
||||||
|
|
||||||
`GtkDirectoryList` is a list model that wraps [`method@Gio.File.enumerate_children_async`].
|
|
||||||
It presents a `GListModel` and fills it asynchronously with the [`iface@Gio.File`]s
|
|
||||||
returned from that function.
|
|
||||||
|
|
||||||
If these models don't fit your use case or scalability requirements, you
|
If these models don't fit your use case or scalability requirements, you
|
||||||
should make a custom `GListModel` implementation. It is a small interface and
|
should make a custom `GListModel` implementation. It is a small interface and
|
||||||
not very hard to implement.
|
not very hard to implement.
|
||||||
@@ -203,7 +199,7 @@ the `.data-table` style class.
|
|||||||
## Sections
|
## Sections
|
||||||
|
|
||||||
List models can optionally group their items into **_sections_**, by implementing
|
List models can optionally group their items into **_sections_**, by implementing
|
||||||
the `GtkSectionModel` interface. `GtkListView` can
|
the `GtkSectionModel` interface. Both `GtkListView` and `GtkGridView` can
|
||||||
display headers for sections, by installing a separate **_header factory_**.
|
display headers for sections, by installing a separate **_header factory_**.
|
||||||
|
|
||||||
Many GTK list models support section inherently, or they pass through the
|
Many GTK list models support section inherently, or they pass through the
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
toml_conf = configuration_data()
|
toml_conf = configuration_data()
|
||||||
toml_conf.set('version', meson.project_version())
|
toml_conf.set('version', meson.project_version())
|
||||||
|
|
||||||
gidocgen = find_program('gi-docgen', required: get_option('documentation'), native: true)
|
gidocgen = find_program('gi-docgen', required: get_option('gtk_doc'), native: true)
|
||||||
|
|
||||||
gidocgen_common_args = [
|
gidocgen_common_args = [
|
||||||
'--quiet',
|
'--quiet',
|
||||||
@@ -14,7 +14,7 @@ endif
|
|||||||
|
|
||||||
docs_dir = gtk_datadir / 'doc'
|
docs_dir = gtk_datadir / 'doc'
|
||||||
|
|
||||||
if get_option('documentation') and not build_gir
|
if get_option('gtk_doc') and not build_gir
|
||||||
error('API reference requires introspection.')
|
error('API reference requires introspection.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -15,78 +15,18 @@ struct _ExampleAppPrefs
|
|||||||
|
|
||||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
static gboolean
|
|
||||||
string_to_font_desc (GValue *value,
|
|
||||||
GVariant *variant,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
const char *s = g_variant_get_string (variant, NULL);
|
|
||||||
PangoFontDescription *desc;
|
|
||||||
|
|
||||||
desc = pango_font_description_from_string (s);
|
|
||||||
g_value_take_boxed (value, desc);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
font_desc_to_string (const GValue *value,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
PangoFontDescription *desc = g_value_get_boxed (value);
|
|
||||||
char *s = pango_font_description_to_string (desc);
|
|
||||||
return g_variant_new_take_string (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
transition_to_pos (GValue *value,
|
|
||||||
GVariant *variant,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
const char *s = g_variant_get_string (variant, NULL);
|
|
||||||
if (strcmp (s, "none") == 0)
|
|
||||||
g_value_set_uint (value, 0);
|
|
||||||
else if (strcmp (s, "crossfade") == 0)
|
|
||||||
g_value_set_uint (value, 1);
|
|
||||||
else
|
|
||||||
g_value_set_uint (value, 2);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
pos_to_transition (const GValue *value,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
switch (g_value_get_uint (value))
|
|
||||||
{
|
|
||||||
case 0: return g_variant_new_string ("none");
|
|
||||||
case 1: return g_variant_new_string ("crossfade");
|
|
||||||
case 2: return g_variant_new_string ("slide-left-right");
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||||
{
|
{
|
||||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||||
|
|
||||||
g_settings_bind_with_mapping (prefs->settings, "font",
|
g_settings_bind (prefs->settings, "font",
|
||||||
prefs->font, "font-desc",
|
prefs->font, "font",
|
||||||
G_SETTINGS_BIND_DEFAULT,
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
string_to_font_desc,
|
g_settings_bind (prefs->settings, "transition",
|
||||||
font_desc_to_string,
|
prefs->transition, "active-id",
|
||||||
NULL, NULL);
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
g_settings_bind_with_mapping (prefs->settings, "transition",
|
|
||||||
prefs->transition, "selected",
|
|
||||||
G_SETTINGS_BIND_DEFAULT,
|
|
||||||
transition_to_pos,
|
|
||||||
pos_to_transition,
|
|
||||||
NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -27,10 +27,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFontDialogButton" id="font">
|
<object class="GtkFontButton" id="font">
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkFontDialog"/>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">0</property>
|
<property name="row">0</property>
|
||||||
@@ -50,16 +47,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="transition">
|
<object class="GtkComboBoxText" id="transition">
|
||||||
<property name="model">
|
<items>
|
||||||
<object class="GtkStringList">
|
<item translatable="yes" id="none">None</item>
|
||||||
<items>
|
<item translatable="yes" id="crossfade">Fade</item>
|
||||||
<item translatable="yes">None</item>
|
<item translatable="yes" id="slide-left-right">Slide</item>
|
||||||
<item translatable="yes">Fade</item>
|
</items>
|
||||||
<item translatable="yes">Slide</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
|
|||||||
@@ -15,78 +15,18 @@ struct _ExampleAppPrefs
|
|||||||
|
|
||||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
static gboolean
|
|
||||||
string_to_font_desc (GValue *value,
|
|
||||||
GVariant *variant,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
const char *s = g_variant_get_string (variant, NULL);
|
|
||||||
PangoFontDescription *desc;
|
|
||||||
|
|
||||||
desc = pango_font_description_from_string (s);
|
|
||||||
g_value_take_boxed (value, desc);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
font_desc_to_string (const GValue *value,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
PangoFontDescription *desc = g_value_get_boxed (value);
|
|
||||||
char *s = pango_font_description_to_string (desc);
|
|
||||||
return g_variant_new_take_string (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
transition_to_pos (GValue *value,
|
|
||||||
GVariant *variant,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
const char *s = g_variant_get_string (variant, NULL);
|
|
||||||
if (strcmp (s, "none") == 0)
|
|
||||||
g_value_set_uint (value, 0);
|
|
||||||
else if (strcmp (s, "crossfade") == 0)
|
|
||||||
g_value_set_uint (value, 1);
|
|
||||||
else
|
|
||||||
g_value_set_uint (value, 2);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
pos_to_transition (const GValue *value,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
switch (g_value_get_uint (value))
|
|
||||||
{
|
|
||||||
case 0: return g_variant_new_string ("none");
|
|
||||||
case 1: return g_variant_new_string ("crossfade");
|
|
||||||
case 2: return g_variant_new_string ("slide-left-right");
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||||
{
|
{
|
||||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||||
|
|
||||||
g_settings_bind_with_mapping (prefs->settings, "font",
|
g_settings_bind (prefs->settings, "font",
|
||||||
prefs->font, "font-desc",
|
prefs->font, "font",
|
||||||
G_SETTINGS_BIND_DEFAULT,
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
string_to_font_desc,
|
g_settings_bind (prefs->settings, "transition",
|
||||||
font_desc_to_string,
|
prefs->transition, "active-id",
|
||||||
NULL, NULL);
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
g_settings_bind_with_mapping (prefs->settings, "transition",
|
|
||||||
prefs->transition, "selected",
|
|
||||||
G_SETTINGS_BIND_DEFAULT,
|
|
||||||
transition_to_pos,
|
|
||||||
pos_to_transition,
|
|
||||||
NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -27,10 +27,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFontDialogButton" id="font">
|
<object class="GtkFontButton" id="font">
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkFontDialog"/>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">0</property>
|
<property name="row">0</property>
|
||||||
@@ -50,16 +47,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="transition">
|
<object class="GtkComboBoxText" id="transition">
|
||||||
<property name="model">
|
<items>
|
||||||
<object class="GtkStringList">
|
<item translatable="yes" id="none">None</item>
|
||||||
<items>
|
<item translatable="yes" id="crossfade">Fade</item>
|
||||||
<item translatable="yes">None</item>
|
<item translatable="yes" id="slide-left-right">Slide</item>
|
||||||
<item translatable="yes">Fade</item>
|
</items>
|
||||||
<item translatable="yes">Slide</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
|
|||||||
@@ -15,78 +15,18 @@ struct _ExampleAppPrefs
|
|||||||
|
|
||||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
static gboolean
|
|
||||||
string_to_font_desc (GValue *value,
|
|
||||||
GVariant *variant,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
const char *s = g_variant_get_string (variant, NULL);
|
|
||||||
PangoFontDescription *desc;
|
|
||||||
|
|
||||||
desc = pango_font_description_from_string (s);
|
|
||||||
g_value_take_boxed (value, desc);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
font_desc_to_string (const GValue *value,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
PangoFontDescription *desc = g_value_get_boxed (value);
|
|
||||||
char *s = pango_font_description_to_string (desc);
|
|
||||||
return g_variant_new_take_string (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
transition_to_pos (GValue *value,
|
|
||||||
GVariant *variant,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
const char *s = g_variant_get_string (variant, NULL);
|
|
||||||
if (strcmp (s, "none") == 0)
|
|
||||||
g_value_set_uint (value, 0);
|
|
||||||
else if (strcmp (s, "crossfade") == 0)
|
|
||||||
g_value_set_uint (value, 1);
|
|
||||||
else
|
|
||||||
g_value_set_uint (value, 2);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
pos_to_transition (const GValue *value,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
switch (g_value_get_uint (value))
|
|
||||||
{
|
|
||||||
case 0: return g_variant_new_string ("none");
|
|
||||||
case 1: return g_variant_new_string ("crossfade");
|
|
||||||
case 2: return g_variant_new_string ("slide-left-right");
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||||
{
|
{
|
||||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||||
|
|
||||||
g_settings_bind_with_mapping (prefs->settings, "font",
|
g_settings_bind (prefs->settings, "font",
|
||||||
prefs->font, "font-desc",
|
prefs->font, "font",
|
||||||
G_SETTINGS_BIND_DEFAULT,
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
string_to_font_desc,
|
g_settings_bind (prefs->settings, "transition",
|
||||||
font_desc_to_string,
|
prefs->transition, "active-id",
|
||||||
NULL, NULL);
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
g_settings_bind_with_mapping (prefs->settings, "transition",
|
|
||||||
prefs->transition, "selected",
|
|
||||||
G_SETTINGS_BIND_DEFAULT,
|
|
||||||
transition_to_pos,
|
|
||||||
pos_to_transition,
|
|
||||||
NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -27,10 +27,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFontDialogButton" id="font">
|
<object class="GtkFontButton" id="font">
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkFontDialog"/>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">0</property>
|
<property name="row">0</property>
|
||||||
@@ -50,16 +47,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="transition">
|
<object class="GtkComboBoxText" id="transition">
|
||||||
<property name="model">
|
<items>
|
||||||
<object class="GtkStringList">
|
<item translatable="yes" id="none">None</item>
|
||||||
<items>
|
<item translatable="yes" id="crossfade">Fade</item>
|
||||||
<item translatable="yes">None</item>
|
<item translatable="yes" id="slide-left-right">Slide</item>
|
||||||
<item translatable="yes">Fade</item>
|
</items>
|
||||||
<item translatable="yes">Slide</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
|
|||||||
@@ -15,78 +15,18 @@ struct _ExampleAppPrefs
|
|||||||
|
|
||||||
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
static gboolean
|
|
||||||
string_to_font_desc (GValue *value,
|
|
||||||
GVariant *variant,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
const char *s = g_variant_get_string (variant, NULL);
|
|
||||||
PangoFontDescription *desc;
|
|
||||||
|
|
||||||
desc = pango_font_description_from_string (s);
|
|
||||||
g_value_take_boxed (value, desc);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
font_desc_to_string (const GValue *value,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
PangoFontDescription *desc = g_value_get_boxed (value);
|
|
||||||
char *s = pango_font_description_to_string (desc);
|
|
||||||
return g_variant_new_take_string (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
transition_to_pos (GValue *value,
|
|
||||||
GVariant *variant,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
const char *s = g_variant_get_string (variant, NULL);
|
|
||||||
if (strcmp (s, "none") == 0)
|
|
||||||
g_value_set_uint (value, 0);
|
|
||||||
else if (strcmp (s, "crossfade") == 0)
|
|
||||||
g_value_set_uint (value, 1);
|
|
||||||
else
|
|
||||||
g_value_set_uint (value, 2);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
pos_to_transition (const GValue *value,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
switch (g_value_get_uint (value))
|
|
||||||
{
|
|
||||||
case 0: return g_variant_new_string ("none");
|
|
||||||
case 1: return g_variant_new_string ("crossfade");
|
|
||||||
case 2: return g_variant_new_string ("slide-left-right");
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
example_app_prefs_init (ExampleAppPrefs *prefs)
|
example_app_prefs_init (ExampleAppPrefs *prefs)
|
||||||
{
|
{
|
||||||
gtk_widget_init_template (GTK_WIDGET (prefs));
|
gtk_widget_init_template (GTK_WIDGET (prefs));
|
||||||
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
prefs->settings = g_settings_new ("org.gtk.exampleapp");
|
||||||
|
|
||||||
g_settings_bind_with_mapping (prefs->settings, "font",
|
g_settings_bind (prefs->settings, "font",
|
||||||
prefs->font, "font-desc",
|
prefs->font, "font",
|
||||||
G_SETTINGS_BIND_DEFAULT,
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
string_to_font_desc,
|
g_settings_bind (prefs->settings, "transition",
|
||||||
font_desc_to_string,
|
prefs->transition, "active-id",
|
||||||
NULL, NULL);
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
g_settings_bind_with_mapping (prefs->settings, "transition",
|
|
||||||
prefs->transition, "selected",
|
|
||||||
G_SETTINGS_BIND_DEFAULT,
|
|
||||||
transition_to_pos,
|
|
||||||
pos_to_transition,
|
|
||||||
NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -27,10 +27,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFontDialogButton" id="font">
|
<object class="GtkFontButton" id="font">
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkFontDialog"/>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">0</property>
|
<property name="row">0</property>
|
||||||
@@ -50,16 +47,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="transition">
|
<object class="GtkComboBoxText" id="transition">
|
||||||
<property name="model">
|
<items>
|
||||||
<object class="GtkStringList">
|
<item translatable="yes" id="none">None</item>
|
||||||
<items>
|
<item translatable="yes" id="crossfade">Fade</item>
|
||||||
<item translatable="yes">None</item>
|
<item translatable="yes" id="slide-left-right">Slide</item>
|
||||||
<item translatable="yes">Fade</item>
|
</items>
|
||||||
<item translatable="yes">Slide</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GtkApplication parent_instance;
|
GtkApplication parent_instance;
|
||||||
@@ -354,8 +356,8 @@ combo_changed (GtkDropDown *combo,
|
|||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GtkDialog *dialog = user_data;
|
||||||
GtkEntry *entry = g_object_get_data (user_data, "entry");
|
GtkEntry *entry = g_object_get_data (user_data, "entry");
|
||||||
GtkWidget *set_button = g_object_get_data (user_data, "set-button");
|
|
||||||
const char *action;
|
const char *action;
|
||||||
char **accels;
|
char **accels;
|
||||||
char *str;
|
char *str;
|
||||||
@@ -370,7 +372,7 @@ combo_changed (GtkDropDown *combo,
|
|||||||
g_strfreev (accels);
|
g_strfreev (accels);
|
||||||
|
|
||||||
gtk_editable_set_text (GTK_EDITABLE (entry), str);
|
gtk_editable_set_text (GTK_EDITABLE (entry), str);
|
||||||
gtk_widget_set_sensitive (set_button, FALSE);
|
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -378,21 +380,15 @@ entry_changed (GtkEntry *entry,
|
|||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkWidget *set_button = g_object_get_data (user_data, "set-button");
|
GtkDialog *dialog = user_data;
|
||||||
|
|
||||||
gtk_widget_set_sensitive (set_button, TRUE);
|
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
close_clicked (GtkButton *button,
|
response (GtkDialog *dialog,
|
||||||
gpointer user_data)
|
guint response_id,
|
||||||
{
|
gpointer user_data)
|
||||||
gtk_window_destroy (GTK_WINDOW (user_data));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
set_clicked (GtkButton *button,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GtkEntry *entry = g_object_get_data (user_data, "entry");
|
GtkEntry *entry = g_object_get_data (user_data, "entry");
|
||||||
GtkDropDown *combo = g_object_get_data (user_data, "combo");
|
GtkDropDown *combo = g_object_get_data (user_data, "combo");
|
||||||
@@ -400,6 +396,12 @@ set_clicked (GtkButton *button,
|
|||||||
const char *str;
|
const char *str;
|
||||||
char **accels;
|
char **accels;
|
||||||
|
|
||||||
|
if (response_id == GTK_RESPONSE_CANCEL)
|
||||||
|
{
|
||||||
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
action = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (combo)));
|
action = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (combo)));
|
||||||
|
|
||||||
if (!action)
|
if (!action)
|
||||||
@@ -411,7 +413,7 @@ set_clicked (GtkButton *button,
|
|||||||
gtk_application_set_accels_for_action (gtk_window_get_application (user_data), action, (const char **) accels);
|
gtk_application_set_accels_for_action (gtk_window_get_application (user_data), action, (const char **) accels);
|
||||||
g_strfreev (accels);
|
g_strfreev (accels);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
|
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -422,45 +424,32 @@ edit_accels (GSimpleAction *action,
|
|||||||
GtkApplication *app = user_data;
|
GtkApplication *app = user_data;
|
||||||
GtkWidget *combo;
|
GtkWidget *combo;
|
||||||
GtkWidget *entry;
|
GtkWidget *entry;
|
||||||
GtkWidget *header;
|
|
||||||
GtkWidget *close_button;
|
|
||||||
GtkWidget *set_button;
|
|
||||||
GtkWidget *box;
|
|
||||||
char **actions;
|
char **actions;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
int i;
|
int i;
|
||||||
GtkStringList *strings;
|
GtkStringList *strings;
|
||||||
|
|
||||||
dialog = gtk_window_new ();
|
dialog = gtk_dialog_new_with_buttons ("Accelerators",
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), "Accelerators");
|
NULL,
|
||||||
|
GTK_DIALOG_USE_HEADER_BAR,
|
||||||
|
"Close", GTK_RESPONSE_CANCEL,
|
||||||
|
"Set", GTK_RESPONSE_APPLY,
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_window_set_application (GTK_WINDOW (dialog), app);
|
gtk_window_set_application (GTK_WINDOW (dialog), app);
|
||||||
actions = gtk_application_list_action_descriptions (app);
|
actions = gtk_application_list_action_descriptions (app);
|
||||||
|
|
||||||
header = gtk_header_bar_new ();
|
strings = gtk_string_list_new (NULL);
|
||||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
|
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||||
close_button = gtk_button_new_with_label ("Close");
|
g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
|
||||||
g_signal_connect (close_button, "clicked", G_CALLBACK (close_clicked), dialog);
|
|
||||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), close_button);
|
|
||||||
set_button = gtk_button_new_with_label ("Set");
|
|
||||||
g_signal_connect (set_button, "clicked", G_CALLBACK (set_clicked), dialog);
|
|
||||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), set_button);
|
|
||||||
|
|
||||||
gtk_window_set_titlebar (GTK_WINDOW (dialog), header);
|
|
||||||
|
|
||||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
|
||||||
g_object_set (box,
|
|
||||||
"margin-top", 10,
|
"margin-top", 10,
|
||||||
"margin-bottom", 10,
|
"margin-bottom", 10,
|
||||||
"margin-start", 10,
|
"margin-start", 10,
|
||||||
"margin-end", 10,
|
"margin-end", 10,
|
||||||
|
"spacing", 10,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_window_set_child (GTK_WINDOW (dialog), box);
|
|
||||||
|
|
||||||
strings = gtk_string_list_new (NULL);
|
|
||||||
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
|
||||||
|
|
||||||
gtk_box_append (GTK_BOX (box), combo);
|
|
||||||
|
|
||||||
|
gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), combo);
|
||||||
for (i = 0; actions[i]; i++)
|
for (i = 0; actions[i]; i++)
|
||||||
gtk_string_list_append (strings, actions[i]);
|
gtk_string_list_append (strings, actions[i]);
|
||||||
g_signal_connect (combo, "notify::selected", G_CALLBACK (combo_changed), dialog);
|
g_signal_connect (combo, "notify::selected", G_CALLBACK (combo_changed), dialog);
|
||||||
@@ -469,10 +458,10 @@ edit_accels (GSimpleAction *action,
|
|||||||
gtk_widget_set_hexpand (entry, TRUE);
|
gtk_widget_set_hexpand (entry, TRUE);
|
||||||
g_signal_connect (entry, "notify::text", G_CALLBACK (entry_changed), dialog);
|
g_signal_connect (entry, "notify::text", G_CALLBACK (entry_changed), dialog);
|
||||||
|
|
||||||
gtk_box_append (GTK_BOX (box), entry);
|
gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), entry);
|
||||||
|
g_signal_connect (dialog, "response", G_CALLBACK (response), dialog);
|
||||||
g_object_set_data (G_OBJECT (dialog), "combo", combo);
|
g_object_set_data (G_OBJECT (dialog), "combo", combo);
|
||||||
g_object_set_data (G_OBJECT (dialog), "entry", entry);
|
g_object_set_data (G_OBJECT (dialog), "entry", entry);
|
||||||
g_object_set_data (G_OBJECT (dialog), "set-button", set_button);
|
|
||||||
|
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), 0);
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), 0);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ foreach ex : examples
|
|||||||
example_name = ex == 'builder' ? 'builder_example' : ex
|
example_name = ex == 'builder' ? 'builder_example' : ex
|
||||||
executable(example_name, '@0@.c'.format(ex),
|
executable(example_name, '@0@.c'.format(ex),
|
||||||
c_args: [
|
c_args: [
|
||||||
|
'-DGDK_DISABLE_DEPRECATED',
|
||||||
|
'-DGTK_DISABLE_DEPRECATED',
|
||||||
'-DGTK_SRCDIR="@0@"'.format(meson.current_source_dir()),
|
'-DGTK_SRCDIR="@0@"'.format(meson.current_source_dir()),
|
||||||
] + common_cflags,
|
] + common_cflags,
|
||||||
dependencies: libgtk_dep)
|
dependencies: libgtk_dep)
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ struct _GdkDisplay
|
|||||||
gsize vk_pipeline_cache_size;
|
gsize vk_pipeline_cache_size;
|
||||||
char *vk_pipeline_cache_etag;
|
char *vk_pipeline_cache_etag;
|
||||||
guint vk_save_pipeline_cache_source;
|
guint vk_save_pipeline_cache_source;
|
||||||
GHashTable *vk_shader_modules;
|
|
||||||
|
|
||||||
guint vulkan_refcount;
|
guint vulkan_refcount;
|
||||||
#endif /* GDK_RENDERING_VULKAN */
|
#endif /* GDK_RENDERING_VULKAN */
|
||||||
|
|||||||
@@ -364,8 +364,6 @@ typedef enum {
|
|||||||
GDK_MEMORY_G16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
GDK_MEMORY_G16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||||
GDK_MEMORY_A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
GDK_MEMORY_A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||||
GDK_MEMORY_A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
GDK_MEMORY_A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||||
GDK_MEMORY_A16_FLOAT GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
|
||||||
GDK_MEMORY_A32_FLOAT GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
|
||||||
|
|
||||||
GDK_MEMORY_N_FORMATS
|
GDK_MEMORY_N_FORMATS
|
||||||
} GdkMemoryFormat;
|
} GdkMemoryFormat;
|
||||||
|
|||||||
@@ -1552,7 +1552,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
|||||||
|
|
||||||
priv->has_sync = gdk_gl_context_check_version (context, "3.2", "3.0") ||
|
priv->has_sync = gdk_gl_context_check_version (context, "3.2", "3.0") ||
|
||||||
epoxy_has_gl_extension ("GL_ARB_sync") ||
|
epoxy_has_gl_extension ("GL_ARB_sync") ||
|
||||||
epoxy_has_gl_extension ("GL_APPLE_sync");
|
epoxy_has_gl_extension ("GK_APPLE_sync");
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ name ## _to_float (float *dest, \
|
|||||||
for (gsize i = 0; i < n; i++) \
|
for (gsize i = 0; i < n; i++) \
|
||||||
{ \
|
{ \
|
||||||
T *src = (T *) (src_data + i * bpp); \
|
T *src = (T *) (src_data + i * bpp); \
|
||||||
if (A >= 0) dest[3] = (float) src[A] / scale; else dest[3] = 1.0; \
|
if (G >= 0) dest[0] = (float) src[G] / scale; else dest[0] = 1.0; \
|
||||||
if (G >= 0) dest[0] = (float) src[G] / scale; else dest[0] = dest[3]; \
|
|
||||||
dest[1] = dest[2] = dest[0]; \
|
dest[1] = dest[2] = dest[0]; \
|
||||||
|
if (A >= 0) dest[3] = (float) src[A] / scale; else dest[3] = 1.0; \
|
||||||
dest += 4; \
|
dest += 4; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@@ -156,37 +156,6 @@ r16g16b16a16_float_from_float (guchar *dest,
|
|||||||
float_to_half (src, (guint16 *) dest, 4 * n);
|
float_to_half (src, (guint16 *) dest, 4 * n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
a16_float_to_float (float *dest,
|
|
||||||
const guchar *src_data,
|
|
||||||
gsize n)
|
|
||||||
{
|
|
||||||
const guint16 *src = (const guint16 *) src_data;
|
|
||||||
for (gsize i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
half_to_float (src, dest, 1);
|
|
||||||
dest[1] = dest[0];
|
|
||||||
dest[2] = dest[0];
|
|
||||||
dest[3] = dest[0];
|
|
||||||
src++;
|
|
||||||
dest += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
a16_float_from_float (guchar *dest_data,
|
|
||||||
const float *src,
|
|
||||||
gsize n)
|
|
||||||
{
|
|
||||||
guint16 *dest = (guint16 *) dest_data;
|
|
||||||
for (gsize i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
float_to_half (&src[3], dest, 1);
|
|
||||||
dest ++;
|
|
||||||
src += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
r32g32b32_float_to_float (float *dest,
|
r32g32b32_float_to_float (float *dest,
|
||||||
const guchar *src_data,
|
const guchar *src_data,
|
||||||
@@ -236,37 +205,6 @@ r32g32b32a32_float_from_float (guchar *dest,
|
|||||||
memcpy (dest, src, sizeof (float) * n * 4);
|
memcpy (dest, src, sizeof (float) * n * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
a32_float_to_float (float *dest,
|
|
||||||
const guchar *src_data,
|
|
||||||
gsize n)
|
|
||||||
{
|
|
||||||
const float *src = (const float *) src_data;
|
|
||||||
for (gsize i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
dest[0] = src[0];
|
|
||||||
dest[1] = src[0];
|
|
||||||
dest[2] = src[0];
|
|
||||||
dest[3] = src[0];
|
|
||||||
src++;
|
|
||||||
dest += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
a32_float_from_float (guchar *dest_data,
|
|
||||||
const float *src,
|
|
||||||
gsize n)
|
|
||||||
{
|
|
||||||
float *dest = (float *) dest_data;
|
|
||||||
for (gsize i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
dest[0] = src[3];
|
|
||||||
dest ++;
|
|
||||||
src += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PREMULTIPLY_FUNC(name, R1, G1, B1, A1, R2, G2, B2, A2) \
|
#define PREMULTIPLY_FUNC(name, R1, G1, B1, A1, R2, G2, B2, A2) \
|
||||||
static void \
|
static void \
|
||||||
name (guchar *dest, \
|
name (guchar *dest, \
|
||||||
@@ -346,7 +284,7 @@ struct _GdkMemoryFormatDescription
|
|||||||
# error "Define the right GL flags here"
|
# error "Define the right GL flags here"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const GdkMemoryFormatDescription memory_formats[] = {
|
static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||||
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
|
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
|
||||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||||
4,
|
4,
|
||||||
@@ -588,50 +526,27 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
|||||||
g16_from_float,
|
g16_from_float,
|
||||||
},
|
},
|
||||||
[GDK_MEMORY_A8] = {
|
[GDK_MEMORY_A8] = {
|
||||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||||
1,
|
1,
|
||||||
G_ALIGNOF (guchar),
|
G_ALIGNOF (guchar),
|
||||||
GDK_MEMORY_U8,
|
GDK_MEMORY_U8,
|
||||||
{ 0, 0, 3, 0 },
|
{ 0, 0, 3, 0 },
|
||||||
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_RED } },
|
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
|
||||||
a8_to_float,
|
a8_to_float,
|
||||||
a8_from_float,
|
a8_from_float,
|
||||||
},
|
},
|
||||||
[GDK_MEMORY_A16] = {
|
[GDK_MEMORY_A16] = {
|
||||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||||
2,
|
2,
|
||||||
G_ALIGNOF (guint16),
|
G_ALIGNOF (guint16),
|
||||||
GDK_MEMORY_U16,
|
GDK_MEMORY_U16,
|
||||||
{ 0, 0, 3, 0 },
|
{ 0, 0, 3, 0 },
|
||||||
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_RED } },
|
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
|
||||||
a16_to_float,
|
a16_to_float,
|
||||||
a16_from_float,
|
a16_from_float,
|
||||||
},
|
|
||||||
[GDK_MEMORY_A16_FLOAT] = {
|
|
||||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
|
||||||
2,
|
|
||||||
G_ALIGNOF (guint16),
|
|
||||||
GDK_MEMORY_FLOAT16,
|
|
||||||
{ 0, 0, 3, 0 },
|
|
||||||
{ GL_R16F, GL_RED, GL_HALF_FLOAT, { GL_RED, GL_RED, GL_RED, GL_RED } },
|
|
||||||
a16_float_to_float,
|
|
||||||
a16_float_from_float,
|
|
||||||
},
|
|
||||||
[GDK_MEMORY_A32_FLOAT] = {
|
|
||||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
|
||||||
4,
|
|
||||||
G_ALIGNOF (float),
|
|
||||||
GDK_MEMORY_FLOAT32,
|
|
||||||
{ 0, 0, 3, 0 },
|
|
||||||
{ GL_R32F, GL_RED, GL_FLOAT, { GL_RED, GL_RED, GL_RED, GL_RED } },
|
|
||||||
a32_float_to_float,
|
|
||||||
a32_float_from_float,
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* if this fails, somebody forgot to add formats above */
|
|
||||||
G_STATIC_ASSERT (G_N_ELEMENTS (memory_formats) == GDK_MEMORY_N_FORMATS);
|
|
||||||
|
|
||||||
gsize
|
gsize
|
||||||
gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
|
gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
|
||||||
{
|
{
|
||||||
@@ -704,33 +619,6 @@ gdk_memory_depth_merge (GdkMemoryDepth depth1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* gdk_memory_depth_get_alpha_format:
|
|
||||||
* @depth: the depth
|
|
||||||
*
|
|
||||||
* Gets the preferred format to use for rendering masks and other
|
|
||||||
* alpha-only content.
|
|
||||||
*
|
|
||||||
* Returns: the format
|
|
||||||
**/
|
|
||||||
GdkMemoryFormat
|
|
||||||
gdk_memory_depth_get_alpha_format (GdkMemoryDepth depth)
|
|
||||||
{
|
|
||||||
switch (depth)
|
|
||||||
{
|
|
||||||
case GDK_MEMORY_U8:
|
|
||||||
return GDK_MEMORY_A8;
|
|
||||||
case GDK_MEMORY_U16:
|
|
||||||
return GDK_MEMORY_A16;
|
|
||||||
case GDK_MEMORY_FLOAT16:
|
|
||||||
return GDK_MEMORY_A16_FLOAT;
|
|
||||||
case GDK_MEMORY_FLOAT32:
|
|
||||||
return GDK_MEMORY_A32_FLOAT;
|
|
||||||
default:
|
|
||||||
g_return_val_if_reached (GDK_MEMORY_A8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gdk_memory_format_gl_format (GdkMemoryFormat format,
|
gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||||
gboolean gles,
|
gboolean gles,
|
||||||
@@ -812,26 +700,6 @@ gdk_memory_convert (guchar *dest_data,
|
|||||||
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
|
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
|
||||||
g_assert (src_format < GDK_MEMORY_N_FORMATS);
|
g_assert (src_format < GDK_MEMORY_N_FORMATS);
|
||||||
|
|
||||||
if (src_format == dest_format)
|
|
||||||
{
|
|
||||||
gsize bytes_per_row = src_desc->bytes_per_pixel * width;
|
|
||||||
|
|
||||||
if (bytes_per_row == src_stride && bytes_per_row == dest_stride)
|
|
||||||
{
|
|
||||||
memcpy (dest_data, src_data, bytes_per_row * height);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
memcpy (dest_data, src_data, bytes_per_row);
|
|
||||||
src_data += src_stride;
|
|
||||||
dest_data += dest_stride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
|
if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
|
||||||
func = r8g8b8a8_to_r8g8b8a8_premultiplied;
|
func = r8g8b8a8_to_r8g8b8a8_premultiplied;
|
||||||
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
|
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat
|
|||||||
GdkMemoryDepth gdk_memory_format_get_depth (GdkMemoryFormat format) G_GNUC_CONST;
|
GdkMemoryDepth gdk_memory_format_get_depth (GdkMemoryFormat format) G_GNUC_CONST;
|
||||||
GdkMemoryDepth gdk_memory_depth_merge (GdkMemoryDepth depth1,
|
GdkMemoryDepth gdk_memory_depth_merge (GdkMemoryDepth depth1,
|
||||||
GdkMemoryDepth depth2) G_GNUC_CONST;
|
GdkMemoryDepth depth2) G_GNUC_CONST;
|
||||||
GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth depth) G_GNUC_CONST;
|
|
||||||
gboolean gdk_memory_format_gl_format (GdkMemoryFormat format,
|
gboolean gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||||
gboolean gles,
|
gboolean gles,
|
||||||
guint gl_major,
|
guint gl_major,
|
||||||
|
|||||||
@@ -151,8 +151,6 @@ gdk_memory_texture_new (int width,
|
|||||||
g_return_val_if_fail (height > 0, NULL);
|
g_return_val_if_fail (height > 0, NULL);
|
||||||
g_return_val_if_fail (bytes != NULL, NULL);
|
g_return_val_if_fail (bytes != NULL, NULL);
|
||||||
g_return_val_if_fail (stride >= width * gdk_memory_format_bytes_per_pixel (format), NULL);
|
g_return_val_if_fail (stride >= width * gdk_memory_format_bytes_per_pixel (format), NULL);
|
||||||
/* needs to be this complex to support subtexture of the bottom right part */
|
|
||||||
g_return_val_if_fail (g_bytes_get_size (bytes) >= stride * (height - 1) + width * gdk_memory_format_bytes_per_pixel (format), NULL);
|
|
||||||
|
|
||||||
bytes = gdk_memory_sanitize (bytes, width, height, format, stride, &stride);
|
bytes = gdk_memory_sanitize (bytes, width, height, format, stride, &stride);
|
||||||
|
|
||||||
|
|||||||
@@ -21,3 +21,23 @@ void gdk_source_set_static_name_by_id (guint tag,
|
|||||||
#ifndef I_
|
#ifndef I_
|
||||||
#define I_(string) g_intern_static_string (string)
|
#define I_(string) g_intern_static_string (string)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !GLIB_CHECK_VERSION (2, 75, 1)
|
||||||
|
static inline gboolean
|
||||||
|
g_set_str (char **str_pointer,
|
||||||
|
const char *new_str)
|
||||||
|
{
|
||||||
|
char *copy;
|
||||||
|
|
||||||
|
if (*str_pointer == new_str ||
|
||||||
|
(*str_pointer && new_str && strcmp (*str_pointer, new_str) == 0))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
copy = g_strdup (new_str);
|
||||||
|
g_free (*str_pointer);
|
||||||
|
*str_pointer = copy;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,7 @@
|
|||||||
* multiple frames, and will be used for a long time.
|
* multiple frames, and will be used for a long time.
|
||||||
*
|
*
|
||||||
* There are various ways to create `GdkTexture` objects from a
|
* There are various ways to create `GdkTexture` objects from a
|
||||||
* [class@GdkPixbuf.Pixbuf], or from bytes stored in memory, a file, or a
|
* [class@GdkPixbuf.Pixbuf], or a Cairo surface, or other pixel data.
|
||||||
* [struct@Gio.Resource].
|
|
||||||
*
|
*
|
||||||
* The ownership of the pixel data is transferred to the `GdkTexture`
|
* The ownership of the pixel data is transferred to the `GdkTexture`
|
||||||
* instance; you can only make a copy of it, via [method@Gdk.Texture.download].
|
* instance; you can only make a copy of it, via [method@Gdk.Texture.download].
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ typedef enum
|
|||||||
* @GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE: whether the bottom edge is resizable
|
* @GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE: whether the bottom edge is resizable
|
||||||
* @GDK_TOPLEVEL_STATE_LEFT_TILED: whether the left edge is tiled
|
* @GDK_TOPLEVEL_STATE_LEFT_TILED: whether the left edge is tiled
|
||||||
* @GDK_TOPLEVEL_STATE_LEFT_RESIZABLE: whether the left edge is resizable
|
* @GDK_TOPLEVEL_STATE_LEFT_RESIZABLE: whether the left edge is resizable
|
||||||
* @GDK_TOPLEVEL_STATE_SUSPENDED: the surface is not visible to the user
|
|
||||||
*
|
*
|
||||||
* Specifies the state of a toplevel surface.
|
* Specifies the state of a toplevel surface.
|
||||||
*
|
*
|
||||||
@@ -112,8 +111,7 @@ typedef enum
|
|||||||
GDK_TOPLEVEL_STATE_BOTTOM_TILED = 1 << 12,
|
GDK_TOPLEVEL_STATE_BOTTOM_TILED = 1 << 12,
|
||||||
GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE = 1 << 13,
|
GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE = 1 << 13,
|
||||||
GDK_TOPLEVEL_STATE_LEFT_TILED = 1 << 14,
|
GDK_TOPLEVEL_STATE_LEFT_TILED = 1 << 14,
|
||||||
GDK_TOPLEVEL_STATE_LEFT_RESIZABLE = 1 << 15,
|
GDK_TOPLEVEL_STATE_LEFT_RESIZABLE = 1 << 15
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED = 1 << 16
|
|
||||||
} GdkToplevelState;
|
} GdkToplevelState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -241,10 +241,6 @@ gdk_vulkan_strerror (VkResult result)
|
|||||||
return "Codec-specific parameters in a requested (VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR)";
|
return "Codec-specific parameters in a requested (VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR)";
|
||||||
case VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR:
|
case VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR:
|
||||||
return "The specified video Std header version is not supported. (VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR)";
|
return "The specified video Std header version is not supported. (VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR)";
|
||||||
#endif
|
|
||||||
#if VK_HEADER_VERSION >= 246
|
|
||||||
case VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT:
|
|
||||||
return "The provided binary shader code is not compatible with this device. (VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT)";
|
|
||||||
#endif
|
#endif
|
||||||
case VK_RESULT_MAX_ENUM:
|
case VK_RESULT_MAX_ENUM:
|
||||||
default:
|
default:
|
||||||
@@ -387,13 +383,6 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
|||||||
|
|
||||||
device = gdk_vulkan_context_get_device (context);
|
device = gdk_vulkan_context_get_device (context);
|
||||||
|
|
||||||
/*
|
|
||||||
* Wait for device to be idle because this function is also called in window resizes.
|
|
||||||
* And if we destroy old swapchain it also destroy the old VkImages, those images could
|
|
||||||
* be in use by a vulkan render.
|
|
||||||
*/
|
|
||||||
vkDeviceWaitIdle (device);
|
|
||||||
|
|
||||||
res = GDK_VK_CHECK (vkGetPhysicalDeviceSurfaceCapabilitiesKHR, gdk_vulkan_context_get_physical_device (context),
|
res = GDK_VK_CHECK (vkGetPhysicalDeviceSurfaceCapabilitiesKHR, gdk_vulkan_context_get_physical_device (context),
|
||||||
priv->surface,
|
priv->surface,
|
||||||
&capabilities);
|
&capabilities);
|
||||||
@@ -1009,7 +998,6 @@ gdk_display_load_pipeline_cache (GdkDisplay *display)
|
|||||||
&result) != VK_SUCCESS)
|
&result) != VK_SUCCESS)
|
||||||
result = VK_NULL_HANDLE;
|
result = VK_NULL_HANDLE;
|
||||||
|
|
||||||
g_object_unref (cache_file);
|
|
||||||
g_free (data);
|
g_free (data);
|
||||||
g_free (display->vk_pipeline_cache_etag);
|
g_free (display->vk_pipeline_cache_etag);
|
||||||
display->vk_pipeline_cache_etag = etag;
|
display->vk_pipeline_cache_etag = etag;
|
||||||
@@ -1055,7 +1043,6 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
|||||||
{
|
{
|
||||||
g_warning_once ("Failed to create pipeline cache directory");
|
g_warning_once ("Failed to create pipeline cache directory");
|
||||||
g_free (path);
|
g_free (path);
|
||||||
g_free (data);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
g_free (path);
|
g_free (path);
|
||||||
@@ -1091,7 +1078,6 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
|||||||
}
|
}
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
g_free (data);
|
|
||||||
|
|
||||||
/* try again */
|
/* try again */
|
||||||
return gdk_vulkan_save_pipeline_cache (display);
|
return gdk_vulkan_save_pipeline_cache (display);
|
||||||
@@ -1100,12 +1086,10 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
|||||||
g_warning ("Failed to save pipeline cache: %s", error->message);
|
g_warning ("Failed to save pipeline cache: %s", error->message);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
g_free (data);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
g_free (data);
|
|
||||||
g_free (display->vk_pipeline_cache_etag);
|
g_free (display->vk_pipeline_cache_etag);
|
||||||
display->vk_pipeline_cache_etag = etag;
|
display->vk_pipeline_cache_etag = etag;
|
||||||
|
|
||||||
@@ -1141,15 +1125,12 @@ gdk_display_create_pipeline_cache (GdkDisplay *display)
|
|||||||
{
|
{
|
||||||
display->vk_pipeline_cache = gdk_display_load_pipeline_cache (display);
|
display->vk_pipeline_cache = gdk_display_load_pipeline_cache (display);
|
||||||
|
|
||||||
if (display->vk_pipeline_cache == VK_NULL_HANDLE)
|
GDK_VK_CHECK (vkCreatePipelineCache, display->vk_device,
|
||||||
{
|
&(VkPipelineCacheCreateInfo) {
|
||||||
GDK_VK_CHECK (vkCreatePipelineCache, display->vk_device,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO,
|
||||||
&(VkPipelineCacheCreateInfo) {
|
},
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO,
|
NULL,
|
||||||
},
|
&display->vk_pipeline_cache);
|
||||||
NULL,
|
|
||||||
&display->vk_pipeline_cache);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipelineCache
|
VkPipelineCache
|
||||||
@@ -1612,8 +1593,6 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
|||||||
|
|
||||||
gdk_display_create_pipeline_cache (display);
|
gdk_display_create_pipeline_cache (display);
|
||||||
|
|
||||||
display->vk_shader_modules = g_hash_table_new (g_str_hash, g_str_equal);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1635,9 +1614,6 @@ gdk_display_ref_vulkan (GdkDisplay *display,
|
|||||||
void
|
void
|
||||||
gdk_display_unref_vulkan (GdkDisplay *display)
|
gdk_display_unref_vulkan (GdkDisplay *display)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
|
||||||
gpointer key, value;
|
|
||||||
|
|
||||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||||
g_return_if_fail (display->vulkan_refcount > 0);
|
g_return_if_fail (display->vulkan_refcount > 0);
|
||||||
|
|
||||||
@@ -1645,24 +1621,13 @@ gdk_display_unref_vulkan (GdkDisplay *display)
|
|||||||
if (display->vulkan_refcount > 0)
|
if (display->vulkan_refcount > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, display->vk_shader_modules);
|
|
||||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
|
||||||
{
|
|
||||||
g_free (key);
|
|
||||||
vkDestroyShaderModule (display->vk_device,
|
|
||||||
value,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
g_hash_table_unref (display->vk_shader_modules);
|
|
||||||
|
|
||||||
if (display->vk_save_pipeline_cache_source)
|
if (display->vk_save_pipeline_cache_source)
|
||||||
{
|
{
|
||||||
g_clear_handle_id (&display->vk_save_pipeline_cache_source, g_source_remove);
|
|
||||||
gdk_vulkan_save_pipeline_cache_cb (display);
|
gdk_vulkan_save_pipeline_cache_cb (display);
|
||||||
g_assert (display->vk_save_pipeline_cache_source == 0);
|
g_assert (display->vk_save_pipeline_cache_source == 0);
|
||||||
}
|
}
|
||||||
vkDestroyPipelineCache (display->vk_device, display->vk_pipeline_cache, NULL);
|
vkDestroyPipelineCache (display->vk_device, display->vk_pipeline_cache, NULL);
|
||||||
display->vk_pipeline_cache = VK_NULL_HANDLE;
|
display->vk_device = VK_NULL_HANDLE;
|
||||||
g_clear_pointer (&display->vk_pipeline_cache_etag, g_free);
|
g_clear_pointer (&display->vk_pipeline_cache_etag, g_free);
|
||||||
display->vk_pipeline_cache_size = 0;
|
display->vk_pipeline_cache_size = 0;
|
||||||
|
|
||||||
@@ -1682,47 +1647,6 @@ gdk_display_unref_vulkan (GdkDisplay *display)
|
|||||||
display->vk_instance = VK_NULL_HANDLE;
|
display->vk_instance = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkShaderModule
|
|
||||||
gdk_display_get_vk_shader_module (GdkDisplay *self,
|
|
||||||
const char *resource_name)
|
|
||||||
{
|
|
||||||
VkShaderModule shader;
|
|
||||||
GError *error = NULL;
|
|
||||||
GBytes *bytes;
|
|
||||||
|
|
||||||
shader = g_hash_table_lookup (self->vk_shader_modules, resource_name);
|
|
||||||
if (shader)
|
|
||||||
return shader;
|
|
||||||
|
|
||||||
bytes = g_resources_lookup_data (resource_name, 0, &error);
|
|
||||||
if (bytes == NULL)
|
|
||||||
{
|
|
||||||
GDK_DEBUG (VULKAN, "Error loading shader data: %s", error->message);
|
|
||||||
g_clear_error (&error);
|
|
||||||
return VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GDK_VK_CHECK (vkCreateShaderModule, self->vk_device,
|
|
||||||
&(VkShaderModuleCreateInfo) {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
|
||||||
.codeSize = g_bytes_get_size (bytes),
|
|
||||||
.pCode = (uint32_t *) g_bytes_get_data (bytes, NULL),
|
|
||||||
},
|
|
||||||
NULL,
|
|
||||||
&shader) == VK_SUCCESS)
|
|
||||||
{
|
|
||||||
g_hash_table_insert (self->vk_shader_modules, g_strdup (resource_name), shader);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shader = VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_bytes_unref (bytes);
|
|
||||||
|
|
||||||
return shader;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* GDK_RENDERING_VULKAN */
|
#else /* GDK_RENDERING_VULKAN */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -73,9 +73,6 @@ gboolean gdk_display_ref_vulkan (GdkDisp
|
|||||||
GError **error);
|
GError **error);
|
||||||
void gdk_display_unref_vulkan (GdkDisplay *display);
|
void gdk_display_unref_vulkan (GdkDisplay *display);
|
||||||
|
|
||||||
VkShaderModule gdk_display_get_vk_shader_module (GdkDisplay *display,
|
|
||||||
const char *resource_name);
|
|
||||||
|
|
||||||
VkPipelineCache gdk_vulkan_context_get_pipeline_cache (GdkVulkanContext *self);
|
VkPipelineCache gdk_vulkan_context_get_pipeline_cache (GdkVulkanContext *self);
|
||||||
void gdk_vulkan_context_pipeline_cache_updated (GdkVulkanContext *self);
|
void gdk_vulkan_context_pipeline_cache_updated (GdkVulkanContext *self);
|
||||||
|
|
||||||
|
|||||||
@@ -387,8 +387,6 @@ gdk_save_png (GdkTexture *texture)
|
|||||||
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
||||||
case GDK_MEMORY_G16A16:
|
case GDK_MEMORY_G16A16:
|
||||||
case GDK_MEMORY_A16:
|
case GDK_MEMORY_A16:
|
||||||
case GDK_MEMORY_A16_FLOAT:
|
|
||||||
case GDK_MEMORY_A32_FLOAT:
|
|
||||||
format = GDK_MEMORY_G16A16;
|
format = GDK_MEMORY_G16A16;
|
||||||
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
|
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||||
depth = 16;
|
depth = 16;
|
||||||
|
|||||||
@@ -259,8 +259,6 @@ static const FormatData format_data[] = {
|
|||||||
[GDK_MEMORY_G16] = { GDK_MEMORY_G16, 16, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
|
[GDK_MEMORY_G16] = { GDK_MEMORY_G16, 16, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
|
||||||
[GDK_MEMORY_A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
[GDK_MEMORY_A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||||
[GDK_MEMORY_A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
[GDK_MEMORY_A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||||
[GDK_MEMORY_A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
|
||||||
[GDK_MEMORY_A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* if this fails, somebody forgot to add formats above */
|
/* if this fails, somebody forgot to add formats above */
|
||||||
|
|||||||
@@ -73,10 +73,7 @@ typedef NSString *CALayerContentsGravity;
|
|||||||
|
|
||||||
-(void)windowDidMiniaturize:(NSNotification *)aNotification
|
-(void)windowDidMiniaturize:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
gdk_synthesize_surface_state (GDK_SURFACE (gdk_surface),
|
gdk_synthesize_surface_state (GDK_SURFACE (gdk_surface), 0, GDK_TOPLEVEL_STATE_MINIMIZED);
|
||||||
0,
|
|
||||||
GDK_TOPLEVEL_STATE_MINIMIZED |
|
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)windowDidDeminiaturize:(NSNotification *)aNotification
|
-(void)windowDidDeminiaturize:(NSNotification *)aNotification
|
||||||
@@ -86,10 +83,7 @@ typedef NSString *CALayerContentsGravity;
|
|||||||
else if (GDK_IS_MACOS_POPUP_SURFACE (gdk_surface))
|
else if (GDK_IS_MACOS_POPUP_SURFACE (gdk_surface))
|
||||||
_gdk_macos_popup_surface_attach_to_parent (GDK_MACOS_POPUP_SURFACE (gdk_surface));
|
_gdk_macos_popup_surface_attach_to_parent (GDK_MACOS_POPUP_SURFACE (gdk_surface));
|
||||||
|
|
||||||
gdk_synthesize_surface_state (GDK_SURFACE (gdk_surface),
|
gdk_synthesize_surface_state (GDK_SURFACE (gdk_surface), GDK_TOPLEVEL_STATE_MINIMIZED, 0);
|
||||||
GDK_TOPLEVEL_STATE_MINIMIZED |
|
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)windowDidBecomeKey:(NSNotification *)aNotification
|
-(void)windowDidBecomeKey:(NSNotification *)aNotification
|
||||||
|
|||||||
@@ -27,7 +27,9 @@
|
|||||||
#include "gdkmacosdisplay.h"
|
#include "gdkmacosdisplay.h"
|
||||||
#include "gdkmacossurface.h"
|
#include "gdkmacossurface.h"
|
||||||
|
|
||||||
#import <epoxy/gl.h>
|
#import <OpenGL/OpenGL.h>
|
||||||
|
#import <OpenGL/gl3.h>
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "gdkconfig.h"
|
#include "gdkconfig.h"
|
||||||
|
|
||||||
|
#include <OpenGL/gl3.h>
|
||||||
#include <OpenGL/CGLIOSurface.h>
|
#include <OpenGL/CGLIOSurface.h>
|
||||||
#include <QuartzCore/QuartzCore.h>
|
#include <QuartzCore/QuartzCore.h>
|
||||||
|
|
||||||
@@ -498,7 +499,7 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
|||||||
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
||||||
gdk_macos_gl_context_allocate (self);
|
gdk_macos_gl_context_allocate (self);
|
||||||
|
|
||||||
GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, depth, region);
|
GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, prefers_high_depth, region);
|
||||||
|
|
||||||
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
||||||
CHECK_GL (NULL, glBindFramebuffer (GL_FRAMEBUFFER, self->fbo));
|
CHECK_GL (NULL, glBindFramebuffer (GL_FRAMEBUFFER, self->fbo));
|
||||||
|
|||||||
@@ -2185,9 +2185,8 @@ set_capability_setting (GdkDisplay *display,
|
|||||||
enum gtk_shell1_capability test)
|
enum gtk_shell1_capability test)
|
||||||
{
|
{
|
||||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||||
int testbit = 1 << (test - 1);
|
|
||||||
|
|
||||||
g_value_set_boolean (value, (display_wayland->shell_capabilities & testbit) == testbit);
|
g_value_set_boolean (value, (display_wayland->shell_capabilities & test) == test);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3064,9 +3064,9 @@ tablet_tool_handle_button (void *data,
|
|||||||
tablet->pointer_info.press_serial = serial;
|
tablet->pointer_info.press_serial = serial;
|
||||||
|
|
||||||
if (button == BTN_STYLUS)
|
if (button == BTN_STYLUS)
|
||||||
n_button = GDK_BUTTON_MIDDLE;
|
|
||||||
else if (button == BTN_STYLUS2)
|
|
||||||
n_button = GDK_BUTTON_SECONDARY;
|
n_button = GDK_BUTTON_SECONDARY;
|
||||||
|
else if (button == BTN_STYLUS2)
|
||||||
|
n_button = GDK_BUTTON_MIDDLE;
|
||||||
else if (button == BTN_STYLUS3)
|
else if (button == BTN_STYLUS3)
|
||||||
n_button = 8; /* Back */
|
n_button = 8; /* Back */
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -620,11 +620,6 @@ xdg_toplevel_configure (void *data,
|
|||||||
pending_state |= (GDK_TOPLEVEL_STATE_TILED |
|
pending_state |= (GDK_TOPLEVEL_STATE_TILED |
|
||||||
GDK_TOPLEVEL_STATE_LEFT_TILED);
|
GDK_TOPLEVEL_STATE_LEFT_TILED);
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_TOPLEVEL_STATE_SUSPENDED
|
|
||||||
case XDG_TOPLEVEL_STATE_SUSPENDED:
|
|
||||||
pending_state |= GDK_TOPLEVEL_STATE_SUSPENDED;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
/* Unknown state */
|
/* Unknown state */
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ static GSourceFuncs event_funcs = {
|
|||||||
|
|
||||||
static GdkSurface *mouse_window = NULL;
|
static GdkSurface *mouse_window = NULL;
|
||||||
static GdkSurface *mouse_window_ignored_leave = NULL;
|
static GdkSurface *mouse_window_ignored_leave = NULL;
|
||||||
|
static int current_x, current_y;
|
||||||
static int current_root_x, current_root_y;
|
static int current_root_x, current_root_y;
|
||||||
|
|
||||||
static UINT got_gdk_events_message;
|
static UINT got_gdk_events_message;
|
||||||
@@ -1521,15 +1522,14 @@ generate_button_event (GdkEventType type,
|
|||||||
GdkEvent *event;
|
GdkEvent *event;
|
||||||
GdkDeviceManagerWin32 *device_manager;
|
GdkDeviceManagerWin32 *device_manager;
|
||||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
||||||
double x, y;
|
|
||||||
|
|
||||||
if (_gdk_input_ignore_core > 0)
|
if (_gdk_input_ignore_core > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
device_manager = GDK_DEVICE_MANAGER_WIN32 (_gdk_device_manager);
|
device_manager = GDK_DEVICE_MANAGER_WIN32 (_gdk_device_manager);
|
||||||
|
|
||||||
x = (double) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||||
y = (double) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||||
|
|
||||||
_gdk_device_virtual_set_active (_gdk_device_manager->core_pointer,
|
_gdk_device_virtual_set_active (_gdk_device_manager->core_pointer,
|
||||||
_gdk_device_manager->system_pointer);
|
_gdk_device_manager->system_pointer);
|
||||||
@@ -1541,10 +1541,10 @@ generate_button_event (GdkEventType type,
|
|||||||
_gdk_win32_get_next_tick (msg->time),
|
_gdk_win32_get_next_tick (msg->time),
|
||||||
build_pointer_event_state (msg),
|
build_pointer_event_state (msg),
|
||||||
button,
|
button,
|
||||||
x,
|
current_x,
|
||||||
y,
|
current_y,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
_gdk_win32_append_event (event);
|
_gdk_win32_append_event (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2350,19 +2350,19 @@ gdk_event_translate (MSG *msg,
|
|||||||
* sends WM_MOUSEMOVE messages after a new window is shown under
|
* sends WM_MOUSEMOVE messages after a new window is shown under
|
||||||
* the mouse, even if the mouse hasn't moved. This disturbs gtk.
|
* the mouse, even if the mouse hasn't moved. This disturbs gtk.
|
||||||
*/
|
*/
|
||||||
if (msg->pt.x == current_root_x &&
|
if (msg->pt.x / impl->surface_scale == current_root_x &&
|
||||||
msg->pt.y == current_root_y)
|
msg->pt.y / impl->surface_scale == current_root_y)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
current_root_x = msg->pt.x;
|
current_root_x = msg->pt.x / impl->surface_scale;
|
||||||
current_root_y = msg->pt.y;
|
current_root_y = msg->pt.y / impl->surface_scale;
|
||||||
|
|
||||||
if (impl->drag_move_resize_context.op != GDK_WIN32_DRAGOP_NONE)
|
if (impl->drag_move_resize_context.op != GDK_WIN32_DRAGOP_NONE)
|
||||||
gdk_win32_surface_do_move_resize_drag (window, msg->pt.x, msg->pt.y);
|
gdk_win32_surface_do_move_resize_drag (window, current_root_x, current_root_y);
|
||||||
else if (_gdk_input_ignore_core == 0)
|
else if (_gdk_input_ignore_core == 0)
|
||||||
{
|
{
|
||||||
double x = (double) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||||
double y = (double) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||||
|
|
||||||
_gdk_device_virtual_set_active (_gdk_device_manager->core_pointer,
|
_gdk_device_virtual_set_active (_gdk_device_manager->core_pointer,
|
||||||
_gdk_device_manager->system_pointer);
|
_gdk_device_manager->system_pointer);
|
||||||
@@ -2372,8 +2372,8 @@ gdk_event_translate (MSG *msg,
|
|||||||
NULL,
|
NULL,
|
||||||
_gdk_win32_get_next_tick (msg->time),
|
_gdk_win32_get_next_tick (msg->time),
|
||||||
build_pointer_event_state (msg),
|
build_pointer_event_state (msg),
|
||||||
x,
|
current_x,
|
||||||
y,
|
current_y,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
_gdk_win32_append_event (event);
|
_gdk_win32_append_event (event);
|
||||||
@@ -2857,10 +2857,7 @@ gdk_event_translate (MSG *msg,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
/* From: https://learn.microsoft.com/en-us/windows/win32/menurc/wm-syscommand?redirectedfrom=MSDN
|
switch (msg->wParam)
|
||||||
* To obtain the correct result when testing the value of wParam,
|
|
||||||
* an application must combine the value 0xFFF0 with the wParam value by using the bitwise AND operator. */
|
|
||||||
switch (msg->wParam & 0xFFF0)
|
|
||||||
{
|
{
|
||||||
case SC_MINIMIZE:
|
case SC_MINIMIZE:
|
||||||
case SC_RESTORE:
|
case SC_RESTORE:
|
||||||
@@ -2967,14 +2964,6 @@ gdk_event_translate (MSG *msg,
|
|||||||
windowpos = (WINDOWPOS *) msg->lParam;
|
windowpos = (WINDOWPOS *) msg->lParam;
|
||||||
windowpos->cx = our_mmi.ptMaxSize.x;
|
windowpos->cx = our_mmi.ptMaxSize.x;
|
||||||
windowpos->cy = our_mmi.ptMaxSize.y;
|
windowpos->cy = our_mmi.ptMaxSize.y;
|
||||||
|
|
||||||
if (!_gdk_win32_surface_lacks_wm_decorations (window) &&
|
|
||||||
!(windowpos->flags & SWP_NOCLIENTSIZE) &&
|
|
||||||
window->width == impl->next_layout.configured_width &&
|
|
||||||
window->height == impl->next_layout.configured_height)
|
|
||||||
{
|
|
||||||
impl->inhibit_configure = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->maximizing = FALSE;
|
impl->maximizing = FALSE;
|
||||||
@@ -3025,11 +3014,9 @@ gdk_event_translate (MSG *msg,
|
|||||||
unset_bits = 0;
|
unset_bits = 0;
|
||||||
|
|
||||||
if (IsIconic (msg->hwnd))
|
if (IsIconic (msg->hwnd))
|
||||||
set_bits |= (GDK_TOPLEVEL_STATE_MINIMIZED |
|
set_bits |= GDK_TOPLEVEL_STATE_MINIMIZED;
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED);
|
|
||||||
else
|
else
|
||||||
unset_bits |= (GDK_TOPLEVEL_STATE_MINIMIZED |
|
unset_bits |= GDK_TOPLEVEL_STATE_MINIMIZED;
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED);
|
|
||||||
|
|
||||||
if (IsZoomed (msg->hwnd))
|
if (IsZoomed (msg->hwnd))
|
||||||
set_bits |= GDK_TOPLEVEL_STATE_MAXIMIZED;
|
set_bits |= GDK_TOPLEVEL_STATE_MAXIMIZED;
|
||||||
|
|||||||
@@ -271,10 +271,9 @@ winpointer_make_event (GdkDeviceWinpointer *device,
|
|||||||
y /= impl->surface_scale;
|
y /= impl->surface_scale;
|
||||||
|
|
||||||
state = 0;
|
state = 0;
|
||||||
/* Note that info->dwKeyStates is not reliable, use GetKeyState() */
|
if (info->dwKeyStates & POINTER_MOD_CTRL)
|
||||||
if (GetKeyState (VK_CONTROL) < 0)
|
|
||||||
state |= GDK_CONTROL_MASK;
|
state |= GDK_CONTROL_MASK;
|
||||||
if (GetKeyState (VK_SHIFT) < 0)
|
if (info->dwKeyStates & POINTER_MOD_SHIFT)
|
||||||
state |= GDK_SHIFT_MASK;
|
state |= GDK_SHIFT_MASK;
|
||||||
if (GetKeyState (VK_MENU) < 0)
|
if (GetKeyState (VK_MENU) < 0)
|
||||||
state |= GDK_ALT_MASK;
|
state |= GDK_ALT_MASK;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/* GDK - The GIMP Drawing Kit
|
/* GDK - The GIMP Drawing Kit
|
||||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||||
* Copyright (C) 1998-2002 Tor Lillqvist
|
* Copyright (C) 1998-2002 Tor Lillqvist
|
||||||
* Copyright (C) 2023 the GTK team
|
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,6 +16,13 @@
|
|||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||||
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||||
|
* files for a list of changes. These files are distributed with
|
||||||
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
@@ -39,6 +45,8 @@
|
|||||||
#include <wintab.h>
|
#include <wintab.h>
|
||||||
#include <imm.h>
|
#include <imm.h>
|
||||||
|
|
||||||
|
static gboolean gdk_synchronize = FALSE;
|
||||||
|
|
||||||
/* Whether GDK initialized COM */
|
/* Whether GDK initialized COM */
|
||||||
static gboolean co_initialized = FALSE;
|
static gboolean co_initialized = FALSE;
|
||||||
|
|
||||||
@@ -48,6 +56,18 @@ static gboolean ole_initialized = FALSE;
|
|||||||
void
|
void
|
||||||
_gdk_win32_surfaceing_init (void)
|
_gdk_win32_surfaceing_init (void)
|
||||||
{
|
{
|
||||||
|
GdkWin32Keymap *win32_keymap;
|
||||||
|
|
||||||
|
win32_keymap = GDK_WIN32_KEYMAP (_gdk_win32_display_get_keymap (_gdk_display));
|
||||||
|
|
||||||
|
if (gdk_synchronize)
|
||||||
|
GdiSetBatchLimit (1);
|
||||||
|
|
||||||
|
_gdk_input_locale = GetKeyboardLayout (0);
|
||||||
|
_gdk_win32_keymap_set_active_layout (win32_keymap, _gdk_input_locale);
|
||||||
|
|
||||||
|
GDK_NOTE (EVENTS, g_print ("input_locale: %p\n", _gdk_input_locale));
|
||||||
|
|
||||||
_gdk_win32_clipdrop_init ();
|
_gdk_win32_clipdrop_init ();
|
||||||
|
|
||||||
gdk_dmanipulation_initialize ();
|
gdk_dmanipulation_initialize ();
|
||||||
|
|||||||
@@ -194,6 +194,12 @@ gdk_surface_win32_finalize (GObject *object)
|
|||||||
surface->hicon_small = NULL;
|
surface->hicon_small = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (surface->cache_surface)
|
||||||
|
{
|
||||||
|
cairo_surface_destroy (surface->cache_surface);
|
||||||
|
surface->cache_surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
_gdk_win32_surface_unregister_dnd (GDK_SURFACE (surface));
|
_gdk_win32_surface_unregister_dnd (GDK_SURFACE (surface));
|
||||||
|
|
||||||
g_assert (surface->transient_owner == NULL);
|
g_assert (surface->transient_owner == NULL);
|
||||||
@@ -1230,11 +1236,18 @@ get_effective_window_decorations (GdkSurface *window,
|
|||||||
|
|
||||||
*decoration |= GDK_DECOR_MINIMIZE;
|
*decoration |= GDK_DECOR_MINIMIZE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else if (impl->hint_flags & GDK_HINT_MAX_SIZE)
|
||||||
|
{
|
||||||
|
*decoration = GDK_DECOR_ALL | GDK_DECOR_MAXIMIZE;
|
||||||
|
*decoration |= GDK_DECOR_MINIMIZE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*decoration = GDK_DECOR_ALL;
|
*decoration = (GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3522,8 +3535,6 @@ setup_drag_move_resize_context (GdkSurface *surface,
|
|||||||
context->button = button;
|
context->button = button;
|
||||||
context->start_root_x = root_x;
|
context->start_root_x = root_x;
|
||||||
context->start_root_y = root_y;
|
context->start_root_y = root_y;
|
||||||
context->current_root_x = root_x;
|
|
||||||
context->current_root_y = root_y;
|
|
||||||
context->timestamp = timestamp;
|
context->timestamp = timestamp;
|
||||||
context->start_rect = rect;
|
context->start_rect = rect;
|
||||||
|
|
||||||
@@ -3639,16 +3650,6 @@ gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
|
|||||||
if (!_gdk_win32_get_window_rect (window, &rect))
|
if (!_gdk_win32_get_window_rect (window, &rect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x /= impl->surface_scale;
|
|
||||||
y /= impl->surface_scale;
|
|
||||||
|
|
||||||
if (context->current_root_x == x &&
|
|
||||||
context->current_root_y == y)
|
|
||||||
return;
|
|
||||||
|
|
||||||
context->current_root_x = x;
|
|
||||||
context->current_root_y = y;
|
|
||||||
|
|
||||||
new_rect = context->start_rect;
|
new_rect = context->start_rect;
|
||||||
diffx = (x - context->start_root_x) * impl->surface_scale;
|
diffx = (x - context->start_root_x) * impl->surface_scale;
|
||||||
diffy = (y - context->start_root_y) * impl->surface_scale;
|
diffy = (y - context->start_root_y) * impl->surface_scale;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/* GDK - The GIMP Drawing Kit
|
/* GDK - The GIMP Drawing Kit
|
||||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||||
* Copyright (C) 2023 the GTK team
|
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
@@ -16,6 +15,13 @@
|
|||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
||||||
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||||
|
* files for a list of changes. These files are distributed with
|
||||||
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "gdk/win32/gdkprivate-win32.h"
|
#include "gdk/win32/gdkprivate-win32.h"
|
||||||
@@ -131,12 +137,6 @@ struct _GdkW32DragMoveResizeContext
|
|||||||
int start_root_x;
|
int start_root_x;
|
||||||
int start_root_y;
|
int start_root_y;
|
||||||
|
|
||||||
/* Last processed cursor position. Values are divided by the window
|
|
||||||
* scale.
|
|
||||||
*/
|
|
||||||
int current_root_x;
|
|
||||||
int current_root_y;
|
|
||||||
|
|
||||||
/* Initial window rectangle (position and size).
|
/* Initial window rectangle (position and size).
|
||||||
* The window is resized/moved relative to this (see start_root_*).
|
* The window is resized/moved relative to this (see start_root_*).
|
||||||
*/
|
*/
|
||||||
@@ -283,7 +283,23 @@ struct _GdkWin32Surface
|
|||||||
*/
|
*/
|
||||||
guint maximizing : 1;
|
guint maximizing : 1;
|
||||||
|
|
||||||
HDC hdc;
|
/* GDK does not keep window contents around, it just draws new
|
||||||
|
* stuff over the window where changes occurred.
|
||||||
|
* cache_surface retains old window contents, because
|
||||||
|
* UpdateLayeredWindow() doesn't do partial redraws.
|
||||||
|
*/
|
||||||
|
cairo_surface_t *cache_surface;
|
||||||
|
|
||||||
|
/* Unlike window-backed surfaces, DIB-backed surface
|
||||||
|
* does not provide a way to query its size,
|
||||||
|
* so we have to remember it ourselves.
|
||||||
|
*/
|
||||||
|
int dib_width;
|
||||||
|
int dib_height;
|
||||||
|
|
||||||
|
HDC hdc;
|
||||||
|
int hdc_count;
|
||||||
|
HBITMAP saved_dc_bitmap; /* Original bitmap for dc */
|
||||||
|
|
||||||
GdkW32DragMoveResizeContext drag_move_resize_context;
|
GdkW32DragMoveResizeContext drag_move_resize_context;
|
||||||
|
|
||||||
|
|||||||
@@ -418,18 +418,12 @@ do_net_wm_state_changes (GdkSurface *surface)
|
|||||||
if (old_state & GDK_TOPLEVEL_STATE_MINIMIZED)
|
if (old_state & GDK_TOPLEVEL_STATE_MINIMIZED)
|
||||||
{
|
{
|
||||||
if (!toplevel->have_hidden)
|
if (!toplevel->have_hidden)
|
||||||
{
|
unset |= GDK_TOPLEVEL_STATE_MINIMIZED;
|
||||||
unset |= (GDK_TOPLEVEL_STATE_MINIMIZED |
|
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (toplevel->have_hidden)
|
if (toplevel->have_hidden)
|
||||||
{
|
set |= GDK_TOPLEVEL_STATE_MINIMIZED;
|
||||||
set |= (GDK_TOPLEVEL_STATE_MINIMIZED |
|
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update edge constraints and tiling */
|
/* Update edge constraints and tiling */
|
||||||
@@ -816,12 +810,9 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
|||||||
* the minimized bit off.
|
* the minimized bit off.
|
||||||
*/
|
*/
|
||||||
if (GDK_SURFACE_IS_MAPPED (surface))
|
if (GDK_SURFACE_IS_MAPPED (surface))
|
||||||
{
|
gdk_synthesize_surface_state (surface,
|
||||||
gdk_synthesize_surface_state (surface,
|
0,
|
||||||
0,
|
GDK_TOPLEVEL_STATE_MINIMIZED);
|
||||||
GDK_TOPLEVEL_STATE_MINIMIZED |
|
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface_impl->toplevel &&
|
if (surface_impl->toplevel &&
|
||||||
@@ -850,12 +841,9 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
|||||||
{
|
{
|
||||||
/* Unset minimized if it was set */
|
/* Unset minimized if it was set */
|
||||||
if (surface->state & GDK_TOPLEVEL_STATE_MINIMIZED)
|
if (surface->state & GDK_TOPLEVEL_STATE_MINIMIZED)
|
||||||
{
|
gdk_synthesize_surface_state (surface,
|
||||||
gdk_synthesize_surface_state (surface,
|
GDK_TOPLEVEL_STATE_MINIMIZED,
|
||||||
GDK_TOPLEVEL_STATE_MINIMIZED |
|
0);
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toplevel)
|
if (toplevel)
|
||||||
gdk_surface_thaw_updates (surface);
|
gdk_surface_thaw_updates (surface);
|
||||||
|
|||||||
@@ -3270,10 +3270,7 @@ gdk_x11_surface_minimize (GdkSurface *surface)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Flip our client side flag, the real work happens on map. */
|
/* Flip our client side flag, the real work happens on map. */
|
||||||
gdk_synthesize_surface_state (surface,
|
gdk_synthesize_surface_state (surface, 0, GDK_TOPLEVEL_STATE_MINIMIZED);
|
||||||
0,
|
|
||||||
GDK_TOPLEVEL_STATE_MINIMIZED |
|
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED);
|
|
||||||
gdk_wmspec_change_state (TRUE, surface,
|
gdk_wmspec_change_state (TRUE, surface,
|
||||||
"_NET_WM_STATE_HIDDEN",
|
"_NET_WM_STATE_HIDDEN",
|
||||||
NULL);
|
NULL);
|
||||||
@@ -3296,10 +3293,7 @@ gdk_x11_surface_unminimize (GdkSurface *surface)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Flip our client side flag, the real work happens on map. */
|
/* Flip our client side flag, the real work happens on map. */
|
||||||
gdk_synthesize_surface_state (surface,
|
gdk_synthesize_surface_state (surface, GDK_TOPLEVEL_STATE_MINIMIZED, 0);
|
||||||
GDK_TOPLEVEL_STATE_MINIMIZED |
|
|
||||||
GDK_TOPLEVEL_STATE_SUSPENDED,
|
|
||||||
0);
|
|
||||||
gdk_wmspec_change_state (FALSE, surface,
|
gdk_wmspec_change_state (FALSE, surface,
|
||||||
"_NET_WM_STATE_HIDDEN",
|
"_NET_WM_STATE_HIDDEN",
|
||||||
NULL);
|
NULL);
|
||||||
|
|||||||