Compare commits
349 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fd8306f340 | |||
| e12b785653 | |||
| fe421e1a7d | |||
| 3bb8419dff | |||
| b5dc516704 | |||
| e34702911b | |||
| 5822782963 | |||
| 02bc5022fa | |||
| b794cdbb0a | |||
| d736d06db8 | |||
| e31fb77c22 | |||
| e8eeb39d98 | |||
| f51c9d4154 | |||
| a0f155e839 | |||
| a4d76439e6 | |||
| 985881ffcc | |||
| b5bcdbc10f | |||
| e00847b0d5 | |||
| 5722f9ab0f | |||
| 86cebc9b43 | |||
| 78638f798b | |||
| 20583c6d98 | |||
| e133c6cb71 | |||
| e187cda5e9 | |||
| d20d7c54d3 | |||
| b7385ffcab | |||
| d406bf96d4 | |||
| 2da7a6d803 | |||
| 65ad492c24 | |||
| 63ddb3f2c7 | |||
| ee91e272a8 | |||
| 7604e2d418 | |||
| 3b0cd0eb8a | |||
| 4884a7c1af | |||
| 321d06117f | |||
| 3ad3a6699a | |||
| e5f0e30843 | |||
| 5a8e2b5995 | |||
| 644070b551 | |||
| 3f54cf9e78 | |||
| a18f018d87 | |||
| 2d10c8844e | |||
| e6daedae0a | |||
| da1a90bcaf | |||
| c1f01eb929 | |||
| 88c63903a5 | |||
| 154ce014a8 | |||
| 4d7c7ec32f | |||
| 7c038b1b33 | |||
| 549ec0d190 | |||
| 823ee6d529 | |||
| b9eb02ebbe | |||
| 4b4ec4472c | |||
| ff66d0d8e5 | |||
| 824776cb02 | |||
| 5f61f40601 | |||
| a5626c489e | |||
| 4f56f53ad7 | |||
| c97f0b660c | |||
| 2969db9993 | |||
| aeb5cb2caa | |||
| 0743cef50d | |||
| 01b75f19a6 | |||
| 532c66df81 | |||
| 793748eadd | |||
| b0317280e7 | |||
| d22a632b54 | |||
| 40915d9a34 | |||
| d7992d0f4e | |||
| fd549e432f | |||
| b07e51bfee | |||
| c0708f23df | |||
| 3be5c09a90 | |||
| 333a5b4307 | |||
| b4195cb408 | |||
| 6c63842e68 | |||
| 12846d821c | |||
| 7bb19b85c2 | |||
| 4531da17e4 | |||
| de9ffc99c2 | |||
| 23907e1d53 | |||
| e9e557a353 | |||
| af71917015 | |||
| babd137e32 | |||
| cdf473ec10 | |||
| 0aa989ae76 | |||
| 2f81a58573 | |||
| 9af5d89f26 | |||
| 868b28b503 | |||
| 03bf85ba07 | |||
| 20f8dd2309 | |||
| b310ba29d0 | |||
| 18db64749f | |||
| 328add40ca | |||
| 922b404091 | |||
| ceb3fecd11 | |||
| f10176e49f | |||
| 9f5e580821 | |||
| bbb7b2987e | |||
| fa0d6127c3 | |||
| bf71b88319 | |||
| 0c6d158373 | |||
| d44edc1f7d | |||
| 676441398a | |||
| b3a66c59ad | |||
| 22eb687264 | |||
| 162614aab4 | |||
| 1d5ba789d5 | |||
| 4e18e5f687 | |||
| 0cf3791c28 | |||
| 145b59b4b1 | |||
| 271adacfad | |||
| 7e917e54a3 | |||
| d12fd1435a | |||
| 5538552ebc | |||
| d9eb667776 | |||
| d13740b2ba | |||
| af8e4ee8e7 | |||
| 568b310eb3 | |||
| 55261f4e3f | |||
| 87cd49371a | |||
| 2e873e3fdc | |||
| 2058ea09a7 | |||
| 46385aff03 | |||
| 2c000c8e61 | |||
| 02f57f9642 | |||
| 3e354a17ef | |||
| 58ca84584a | |||
| d10d34e0ec | |||
| 651f7b4b93 | |||
| 4945b832b2 | |||
| 60969ff951 | |||
| bfad99ad52 | |||
| dee341fc35 | |||
| 9d6811859f | |||
| 8bb3a2001f | |||
| 37149668c0 | |||
| 5a41b74c5c | |||
| 9107074795 | |||
| 89f166b542 | |||
| 88ed04cc37 | |||
| ffc5c214d2 | |||
| 8ede7473de | |||
| e84809c56a | |||
| 2c1839ae5f | |||
| f6e2d0947d | |||
| 516fb89065 | |||
| aa3d30e256 | |||
| ffafe80f5b | |||
| a94f4a4387 | |||
| 00440e32a4 | |||
| 1aa2a7f821 | |||
| b5845514ec | |||
| d4c1b46a9e | |||
| cad8aaadce | |||
| 0fc7c92235 | |||
| eea0cb3a68 | |||
| 8febbcaf6a | |||
| 4118e13596 | |||
| 724a985465 | |||
| 81121ad271 | |||
| cd831b1390 | |||
| 553f516eb7 | |||
| aa1ff574b5 | |||
| 6f9ad538d9 | |||
| fc58ff1e6a | |||
| 14fb4984ce | |||
| 04c85a5b3b | |||
| 17ccbe4843 | |||
| 53e714199a | |||
| 35e36b9fe5 | |||
| 2179580c8e | |||
| 632a84af8c | |||
| 9c57b96f56 | |||
| 7b7027c971 | |||
| 8b1385804e | |||
| d8b99d47ea | |||
| 1d54e4e867 | |||
| 60eff87d08 | |||
| 42d2430498 | |||
| b8c72a0bdb | |||
| deefb64661 | |||
| fe89e710ea | |||
| a240808824 | |||
| 50fdb6a13f | |||
| b6594d1ac9 | |||
| 97dc45f8a5 | |||
| 090f30c559 | |||
| 8bda7442c8 | |||
| e2f89c0c6a | |||
| 6443baadb9 | |||
| 74f4c6f6bd | |||
| 29fbfcb8f5 | |||
| aaedc7b67f | |||
| 95a4b46f8b | |||
| 33f111a47c | |||
| 6ac754cdd1 | |||
| 3ddb104302 | |||
| 2fec112422 | |||
| 40283e7c27 | |||
| 883c871be6 | |||
| ba7141b92e | |||
| 0111b9d507 | |||
| 0048c8baf5 | |||
| 505fefbec7 | |||
| 51da8cb263 | |||
| 83be7e5dbd | |||
| 1223d53a82 | |||
| 7606fcb52e | |||
| b403a1b550 | |||
| c3f46ab5c0 | |||
| 04c5fdaca6 | |||
| dcd54e20d1 | |||
| 1b69f1d7c2 | |||
| 1170ecfd2e | |||
| 56f79fecce | |||
| cfc6462730 | |||
| f785f7177c | |||
| 5377169ef3 | |||
| aed7600425 | |||
| 4f63c1c7ca | |||
| edbc8e4f57 | |||
| 05f2249d08 | |||
| c366b5b8b7 | |||
| ac6d61f6bb | |||
| 8f240275fd | |||
| b8ccda4140 | |||
| 7bdcba189e | |||
| ca17270187 | |||
| c5878e8f6f | |||
| b9ebe8c226 | |||
| 580b5e4a83 | |||
| a8efb784d7 | |||
| ed45a3c2f0 | |||
| 9e4341f730 | |||
| e597f4d6a9 | |||
| d853a8f2f7 | |||
| 8ad8a4febf | |||
| 41ce29767c | |||
| 7511109103 | |||
| 2ff47ed26d | |||
| 662d6787f3 | |||
| 68b7d3e410 | |||
| a360e77a7b | |||
| 31565139ba | |||
| 5d8789680e | |||
| 1a9dfab825 | |||
| bf92f2f7ac | |||
| ad05604b3e | |||
| 7c75611bc2 | |||
| 0cce3520d3 | |||
| 4ba9be5b97 | |||
| 8e17f9c233 | |||
| 40982eabbb | |||
| 751187aa0c | |||
| a737adadf8 | |||
| 82b769ddde | |||
| 8c49cd97a7 | |||
| d63b11e56b | |||
| b65d17dda8 | |||
| 58b6d492b8 | |||
| dcec7a5529 | |||
| 81dfc2776e | |||
| 645309e98b | |||
| ec5c77a552 | |||
| da40ba431d | |||
| 96948576bd | |||
| ccd443796c | |||
| 38ac68790e | |||
| ca4a080c8a | |||
| 281d094b42 | |||
| a33df2d1d6 | |||
| f7c0c7677b | |||
| 6ef76f4a92 | |||
| c8e57d63ec | |||
| 75a5f04352 | |||
| a5d001b2ba | |||
| 0fdc287339 | |||
| 7fbc583b88 | |||
| dd144c2bad | |||
| 86a387f571 | |||
| b5fc484c99 | |||
| bc9060a591 | |||
| ffe50c3b67 | |||
| 3e601691d9 | |||
| b0e764000f | |||
| e7acdec220 | |||
| 9b7640b898 | |||
| 718ceaec45 | |||
| 04f5c8708a | |||
| df45983fcb | |||
| 8e3e3d582f | |||
| 5ac9ba714a | |||
| 58e4fdf911 | |||
| b728cfd3e8 | |||
| 3cdb9c91ca | |||
| d5a2392cc7 | |||
| 44187ca3b5 | |||
| 115c34498e | |||
| 5bbf59b519 | |||
| 4a12717e4d | |||
| 585a1fae4f | |||
| eb537b60f4 | |||
| ece9d2fd92 | |||
| e7a984b337 | |||
| 27c9352df3 | |||
| 969daec353 | |||
| d589566f40 | |||
| 48a8ca8bbe | |||
| 257d961a01 | |||
| 198cf93f0f | |||
| 15be680540 | |||
| 44d49c900d | |||
| 39ff874a11 | |||
| 1a51ea3ea3 | |||
| 7f511f2b33 | |||
| e5ab48ac59 | |||
| 1aa4a196dc | |||
| 102d10016f | |||
| 5f5bf27287 | |||
| d115441a57 | |||
| cbe40f27e1 | |||
| 3bdde54aaf | |||
| 8dbe8c8349 | |||
| b0b6c8ad4b | |||
| 2d01f7786d | |||
| 53317aed55 | |||
| b368c5f10a | |||
| a94b85d375 | |||
| c0b7c3321d | |||
| a2ded8b72a | |||
| 015e3a768f | |||
| a52336bedc | |||
| 1de2e3ce00 | |||
| ea78bcb7c5 | |||
| 234c7fcf28 | |||
| ba81a3a14c | |||
| 71ca53993e | |||
| cddfcf1418 | |||
| cdf5c2af62 | |||
| 6977ea0bd1 | |||
| d9ca1a8636 | |||
| a8d03c9970 | |||
| a820962b2b | |||
| 49abf425a4 | |||
| 872d170fd1 | |||
| 19e55d620f | |||
| 298ba51d31 | |||
| 158784f66b |
@@ -1,3 +1,55 @@
|
||||
Overview of Changes in GTK+ 3.5.1
|
||||
=================================
|
||||
|
||||
* Wayland:
|
||||
- Allow the wayland backend to be used without cairo-gl
|
||||
- Expose GdkWaylandDisplayManager for runtime checks
|
||||
|
||||
* Theming:
|
||||
- Optimizations to style invalidation
|
||||
- Support CSS animatable properties
|
||||
|
||||
* Bugs fixed
|
||||
563688 GtkScale (GtkRange) should jump to clicked position
|
||||
668931 Scrolling down via PageDown/PageUp keys impossible ...
|
||||
669989 gtk_grid_attach(): Documentation doesn't mention mu...
|
||||
670373 modules/printing/cups/gtkprintbackendcups.c won't b...
|
||||
672361 Remove cairo-gl dependency from wayland backend
|
||||
672789 gtk_builder_add_objects_from_file() crashes on GtkU...
|
||||
672993 print dialog overrides default cups number-up settings
|
||||
673259 The gdk/gdkkeysyms-update.pl script and the keysym ...
|
||||
673644 Scroll not working in document overview
|
||||
673650 Evince 3.4: adding new annotation is not possible (...
|
||||
674050 Free image->priv->icon_helper in gtk_image_finalize...
|
||||
674102 Defaults to wayland over x11 backend
|
||||
674118 application-window: Desktop file handling improvements
|
||||
674200 ./configure gives wrong error message if -lXext is ...
|
||||
674286 "Delete confirmation" dialog has wrong padding
|
||||
674326 Use localizations of option names and values contai...
|
||||
674468 Add GTK_STYLE_CLASS_DIM_LABEL
|
||||
674577 Non static variable in GtkStyleProviderPrivate
|
||||
674587 treemodelsort: allow iter_previous() to go past the...
|
||||
674806 icontheme: search first in all themes if the reques...
|
||||
674807 spinbutton: port to GtkIconHelper
|
||||
674808 themingengine: render a frame in gtk_render_handle()
|
||||
674809 themingengine: simplify render_extension() default ...
|
||||
674890 Fix the colord support in GtkPrinterCups when the P...
|
||||
646631 GTK should use XDG base dir spec instead of home
|
||||
|
||||
* Translation updates
|
||||
Bulgarian
|
||||
Crimean Tatar
|
||||
Czech
|
||||
Galician
|
||||
German
|
||||
Hebrew
|
||||
Norwegian bokmål
|
||||
Russian
|
||||
Serbian
|
||||
Simplified Chinese
|
||||
Slovenian
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 3.4.1
|
||||
=================================
|
||||
|
||||
|
||||
@@ -72,13 +72,34 @@ and attach the patch to that bug report.
|
||||
Patches should be in unified diff form. (The -up option to GNU diff.)
|
||||
|
||||
|
||||
Release notes for 3.6
|
||||
=====================
|
||||
|
||||
* Now follows the XDG Base Directory specification for user
|
||||
configuration and data files. In detail,
|
||||
* $XDG_CONFIG_HOME/gtk-3.0/custom-papers is the new location
|
||||
for $HOME/.gtk-custom-papers
|
||||
* $XDG_CONFIG_HOME/gtk-3.0/bookmarks is the new location
|
||||
for $HOME/.gtk-bookmarks
|
||||
* $XDG_DATA_HOME/themes is preferred over $HOME/.themes
|
||||
* $XDG_DATA_HOME/icons is preferred over $HOME/.icons.
|
||||
Existing files from the old location will still be read
|
||||
if the new location does not exist.
|
||||
|
||||
* $HOME/.gtk-3.0 is no longer in the default module load path.
|
||||
If you want to load modules from there, add it to the GTK_PATH
|
||||
environment variable.
|
||||
|
||||
Release notes for 3.4
|
||||
=====================
|
||||
|
||||
* Scroll events have been separated from button events, and smooth
|
||||
scrolling has been added with a separate event mask. Widgets now
|
||||
need to have either GDK_SCROLL_MASK or GDK_SMOOTH_SCROLL_MASK in
|
||||
their event mask to receive scroll events.
|
||||
their event mask to receive scroll events. In addition, the
|
||||
GdkScrollDirection enumeration has gained a new member,
|
||||
GDK_SCROLL_SMOOTH, so switch statements will have to be amended
|
||||
to cover this case.
|
||||
|
||||
* GTK+ now uses <Primary> instead of <Control> in keyboard accelerators,
|
||||
for improved cross-platform handling. This should not affect
|
||||
|
||||
+41
-48
@@ -9,9 +9,9 @@
|
||||
# set GTK_BINARY_AGE and GTK_INTERFACE_AGE to 0.
|
||||
|
||||
m4_define([gtk_major_version], [3])
|
||||
m4_define([gtk_minor_version], [4])
|
||||
m4_define([gtk_micro_version], [1])
|
||||
m4_define([gtk_interface_age], [1])
|
||||
m4_define([gtk_minor_version], [5])
|
||||
m4_define([gtk_micro_version], [3])
|
||||
m4_define([gtk_interface_age], [0])
|
||||
m4_define([gtk_binary_age],
|
||||
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
|
||||
m4_define([gtk_version],
|
||||
@@ -39,7 +39,7 @@ AC_CONFIG_AUX_DIR([build-aux])
|
||||
m4_define([gtk_binary_version], [3.0.0])
|
||||
|
||||
# required versions of other packages
|
||||
m4_define([glib_required_version], [2.32.0])
|
||||
m4_define([glib_required_version], [2.33.1])
|
||||
m4_define([pango_required_version], [1.30.0])
|
||||
m4_define([atk_required_version], [2.2.0])
|
||||
m4_define([cairo_required_version], [1.10.0])
|
||||
@@ -316,6 +316,12 @@ AC_ARG_ENABLE(quartz-relocation,
|
||||
[enable bundle-based relocation functions])],
|
||||
[quartz_relocation=yes])
|
||||
|
||||
AC_ARG_ENABLE(wayland-cairo-gl,
|
||||
AS_HELP_STRING([--enable-wayland-cairo-gl],
|
||||
[enable the use of Cairo GL in the Wayland backend]),
|
||||
[enable_wayland_cairo_gl=yes])
|
||||
|
||||
|
||||
cairo_backends=
|
||||
backend_immodules=
|
||||
have_gio_unix=no
|
||||
@@ -379,13 +385,22 @@ else
|
||||
fi
|
||||
|
||||
if test "x$enable_wayland_backend" == "xyes"; then
|
||||
# Wayland uses cairo-gl
|
||||
cairo_backends="$cairo_backends cairo-gl"
|
||||
if test "x$enable_wayland_cairo_gl" == "xyes"; then
|
||||
# Wayland can use cairo-gl
|
||||
cairo_backends="$cairo_backends cairo-gl"
|
||||
AC_DEFINE(GDK_WAYLAND_USE_EGL, [1], [Whether to use EGL in Wayland backend])
|
||||
else
|
||||
# For the cairo image backend
|
||||
cairo_backends="$cairo_backends cairo"
|
||||
fi
|
||||
GDK_BACKENDS="$GDK_BACKENDS wayland"
|
||||
have_gio_unix=yes
|
||||
GDK_WINDOWING="$GDK_WINDOWING
|
||||
#define GDK_WINDOWING_WAYLAND"
|
||||
WAYLAND_PACKAGES="wayland-client xkbcommon wayland-egl egl"
|
||||
WAYLAND_PACKAGES="wayland-client xkbcommon "
|
||||
if test "x$enable_wayland_cairo_gl" == "xyes"; then
|
||||
WAYLAND_PACKAGES="$WAYLAND_PACKAGES wayland-egl egl"
|
||||
fi
|
||||
AM_CONDITIONAL(USE_WAYLAND, true)
|
||||
else
|
||||
AM_CONDITIONAL(USE_WAYLAND, false)
|
||||
@@ -407,7 +422,7 @@ else
|
||||
if test "x$enable_debug" = "xno"; then
|
||||
GTK_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
|
||||
else
|
||||
GTK_DEBUG_FLAGS="-DG_DISABLE_CAST_CHECKS"
|
||||
GTK_DEBUG_FLAGS="-DG_ENABLE_DEBUG -DG_DISABLE_CAST_CHECKS"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -734,17 +749,9 @@ AC_CHECK_FUNCS(mallinfo)
|
||||
AC_CHECK_FUNCS(getresuid)
|
||||
AC_TYPE_UID_T
|
||||
|
||||
# Check for round()
|
||||
AC_CHECK_LIB(m,round,have_round=yes,have_round=no)
|
||||
if test $have_round = yes; then
|
||||
AC_DEFINE(HAVE_ROUND, 1, [Define to 1 if round() is available])
|
||||
fi
|
||||
|
||||
# Check for rint()
|
||||
AC_CHECK_LIB(m,rint,have_rint=yes,have_rint=no)
|
||||
if test $have_rint = yes; then
|
||||
AC_DEFINE(HAVE_RINT, 1, [Define to 1 if rint() is available])
|
||||
fi
|
||||
# Check for round(), rint(), isnan(), isinf() and nearbyint()
|
||||
AC_CHECK_LIB(m,round,,)
|
||||
AC_CHECK_FUNCS(round rint isnan isinf nearbyint)
|
||||
|
||||
# Checks for gdkspawn
|
||||
AC_CHECK_HEADERS(crt_externs.h)
|
||||
@@ -961,9 +968,9 @@ if test "x$enable_x11_backend" = xyes; then
|
||||
# Xext is optional, the chances a system has *none* of these things is so
|
||||
# small that we just unconditionally require it.
|
||||
AC_CHECK_FUNC(XOpenDisplay, :,
|
||||
AC_MSG_ERROR([*** libX11 not found. Check 'config.log' for more details.]))
|
||||
AC_MSG_ERROR([*** libX11 and libXext not found. Check 'config.log' for more details.]))
|
||||
AC_CHECK_FUNC(XextFindDisplay, :,
|
||||
AC_MSG_ERROR([*** libXext not found. Check 'config.log' for more details.]))
|
||||
AC_MSG_ERROR([*** libX11 and libXext not found. Check 'config.log' for more details.]))
|
||||
|
||||
# Check for xReply
|
||||
|
||||
@@ -1240,8 +1247,9 @@ if test "x$enable_x11_backend" = xyes; then
|
||||
GDK_PRIVATE_PACKAGES="$GDK_PRIVATE_PACKAGES pangoft2"
|
||||
fi
|
||||
|
||||
GDK_DEP_LIBS="$GDK_EXTRA_LIBS `$PKG_CONFIG --libs $GDK_PACKAGES $GDK_PRIVATE_PACKAGES` $MATH_LIB"
|
||||
GDK_DEP_CFLAGS="`$PKG_CONFIG --cflags $GDK_PACKAGES $GDK_PRIVATE_PACKAGES` $GDK_EXTRA_CFLAGS"
|
||||
PKG_CHECK_MODULES(GDK_DEP, $GDK_PACKAGES $GDK_PRIVATE_PACKAGES)
|
||||
GDK_DEP_LIBS="$GDK_EXTRA_LIBS $GDK_DEP_LIBS $MATH_LIB"
|
||||
GDK_DEP_CFLAGS="$GDK_DEP_CFLAGS $GDK_EXTRA_CFLAGS"
|
||||
#
|
||||
# If we aren't writing explicit dependencies, then don't put the extra libraries we need
|
||||
# into the pkg-config files
|
||||
@@ -1263,29 +1271,7 @@ AC_SUBST(GDK_DEP_CFLAGS)
|
||||
########################################
|
||||
|
||||
ATK_PACKAGES=atk
|
||||
AC_MSG_CHECKING(ATK flags)
|
||||
if $PKG_CONFIG --exists $ATK_PACKAGES ; then
|
||||
ATK_CFLAGS=`$PKG_CONFIG --cflags $ATK_PACKAGES`
|
||||
ATK_LIBS=`$PKG_CONFIG --libs $ATK_PACKAGES`
|
||||
|
||||
AC_MSG_RESULT($ATK_CFLAGS $ATK_LIBS)
|
||||
else
|
||||
AC_MSG_ERROR([
|
||||
*** Accessibility Toolkit not found. Accessibility Toolkit is required
|
||||
*** to build GTK+.
|
||||
])
|
||||
fi
|
||||
|
||||
if $PKG_CONFIG --uninstalled $ATK_PACKAGES; then
|
||||
:
|
||||
else
|
||||
gtk_save_LIBS="$LIBS"
|
||||
LIBS="$ATK_LIBS $LIBS"
|
||||
AC_TRY_LINK_FUNC(atk_object_get_type, : , AC_MSG_ERROR([
|
||||
*** Cannot link to Accessibility Toolkit. Accessibility Toolkit is required
|
||||
*** to build GTK+]))
|
||||
LIBS="$gtk_save_LIBS"
|
||||
fi
|
||||
PKG_CHECK_MODULES(ATK, $ATK_PACKAGES)
|
||||
|
||||
GTK_PACKAGES="atk cairo cairo-gobject gdk-pixbuf-2.0 gio-2.0"
|
||||
GTK_PRIVATE_PACKAGES=""
|
||||
@@ -1298,8 +1284,9 @@ fi
|
||||
GTK_EXTRA_LIBS=
|
||||
|
||||
GTK_EXTRA_CFLAGS=
|
||||
GTK_DEP_LIBS="$GDK_EXTRA_LIBS $GTK_DEP_LIBS_FOR_X `$PKG_CONFIG --libs $PANGO_PACKAGES $GTK_PACKAGES_FOR_X $GTK_PACKAGES $GTK_PRIVATE_PACKAGES` $GTK_EXTRA_LIBS $MATH_LIB"
|
||||
GTK_DEP_CFLAGS="`$PKG_CONFIG --cflags $GDK_PACKAGES $GTK_PACKAGES $GTK_PRIVATE_PACKAGES` $GDK_EXTRA_CFLAGS $GTK_EXTRA_CFLAGS"
|
||||
PKG_CHECK_MODULES(GTK_DEP, $PANGO_PACKAGES $GTK_PACKAGES_FOR_X $GTK_PACKAGES $GTK_PRIVATE_PACKAGES)
|
||||
GTK_DEP_LIBS="$GDK_EXTRA_LIBS $GTK_DEP_LIBS_FOR_X $GTK_DEP_LIBS $GTK_EXTRA_LIBS $MATH_LIB"
|
||||
GTK_DEP_CFLAGS="$GTK_DEP_CFLAGS $GDK_EXTRA_CFLAGS $GTK_EXTRA_CFLAGS"
|
||||
|
||||
if test x"$os_win32" = xyes; then
|
||||
GTK_EXTRA_CFLAGS="$msnative_struct"
|
||||
@@ -1394,6 +1381,12 @@ else
|
||||
$CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -lt 2; then
|
||||
AC_MSG_ERROR([CUPS >= 1.2 not found])
|
||||
fi
|
||||
if test $CUPS_API_MAJOR -gt 1 -o \
|
||||
$CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 6; then
|
||||
AC_DEFINE(HAVE_CUPS_API_1_6, 1,
|
||||
[Define to 1 if CUPS 1.6 API is available])
|
||||
|
||||
fi
|
||||
|
||||
AC_SUBST(CUPS_API_MAJOR)
|
||||
AC_SUBST(CUPS_API_MINOR)
|
||||
|
||||
@@ -427,6 +427,12 @@ on_name_vanished (GDBusConnection *connection,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#define APP_EXTENSION ".exe"
|
||||
#else
|
||||
#define APP_EXTENSION
|
||||
#endif
|
||||
|
||||
GtkWidget *
|
||||
do_application (GtkWidget *toplevel)
|
||||
{
|
||||
@@ -445,8 +451,8 @@ do_application (GtkWidget *toplevel)
|
||||
const gchar *command;
|
||||
GError *error = NULL;
|
||||
|
||||
if (g_file_test ("./gtk3-demo-application", G_FILE_TEST_IS_EXECUTABLE))
|
||||
command = "./gtk3-demo-application";
|
||||
if (g_file_test ("./gtk3-demo-application" APP_EXTENSION, G_FILE_TEST_IS_EXECUTABLE))
|
||||
command = "./gtk3-demo-application" APP_EXTENSION;
|
||||
else
|
||||
command = "gtk3-demo-application";
|
||||
|
||||
|
||||
@@ -522,6 +522,7 @@ do_toolpalette (GtkWidget *do_widget)
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (palette_scroller), 6);
|
||||
gtk_widget_set_hexpand (palette_scroller, TRUE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (palette_scroller), palette);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), palette_scroller);
|
||||
|
||||
@@ -22,7 +22,7 @@ gtk3_widget_factory_LDADD = \
|
||||
$(top_builddir)/gtk/libgtk-3.la \
|
||||
$(GTK_DEP_LIBS)
|
||||
|
||||
widget_factory_resources.c: widget-factory.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies $(srcdir)/widget-factory.gresource.xml)
|
||||
widget_factory_resources.c: widget-factory.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/widget-factory.gresource.xml)
|
||||
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $<
|
||||
|
||||
EXTRA_DIST += \
|
||||
|
||||
@@ -658,6 +658,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="row_homogeneous">True</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="checkbutton1">
|
||||
<property name="label" translatable="yes">checkbutton</property>
|
||||
@@ -908,6 +909,58 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner" id="spinner1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner" id="spinner2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner" id="spinner3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner" id="spinner4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="sensitive">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
||||
@@ -65,6 +65,10 @@
|
||||
<title>Index of new symbols in 3.4</title>
|
||||
<xi:include href="xml/api-index-3.4.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
<index id="api-index-3-6" role="3.6">
|
||||
<title>Index of new symbols in 3.6</title>
|
||||
<xi:include href="xml/api-index-3.6.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
|
||||
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
|
||||
|
||||
|
||||
@@ -991,6 +991,8 @@ gdk_x11_grab_server
|
||||
gdk_x11_ungrab_server
|
||||
gdk_x11_cursor_get_xcursor
|
||||
gdk_x11_cursor_get_xdisplay
|
||||
gdk_x11_keymap_get_group_for_state
|
||||
gdk_x11_keymap_key_is_modifier
|
||||
gdk_x11_visual_get_xvisual
|
||||
gdk_x11_atom_to_xatom
|
||||
gdk_x11_atom_to_xatom_for_display
|
||||
|
||||
@@ -526,6 +526,7 @@ GtkBuilderConnectFunc
|
||||
GtkBuilderError
|
||||
gtk_builder_new
|
||||
gtk_builder_add_from_file
|
||||
gtk_builder_add_from_resource
|
||||
gtk_builder_add_from_string
|
||||
gtk_builder_add_objects_from_file
|
||||
gtk_builder_add_objects_from_string
|
||||
@@ -5029,7 +5030,6 @@ GtkWidgetClass
|
||||
GtkCallback
|
||||
GtkRequisition
|
||||
GtkAllocation
|
||||
GtkSelectionData
|
||||
GtkWidgetAuxInfo
|
||||
GtkWidgetHelpType
|
||||
gtk_widget_new
|
||||
@@ -5678,6 +5678,7 @@ GTK_STYLE_CLASS_LEFT
|
||||
GTK_STYLE_CLASS_RIGHT
|
||||
GTK_STYLE_CLASS_LINKED
|
||||
GTK_STYLE_CLASS_ARROW
|
||||
GTK_STYLE_CLASS_OSD
|
||||
GTK_STYLE_REGION_COLUMN
|
||||
GTK_STYLE_REGION_COLUMN_HEADER
|
||||
GTK_STYLE_REGION_ROW
|
||||
@@ -5999,6 +6000,7 @@ GtkRcContext
|
||||
<SECTION>
|
||||
<FILE>gtkselection</FILE>
|
||||
<TITLE>Selections</TITLE>
|
||||
GtkSelectionData
|
||||
GtkTargetEntry
|
||||
GtkTargetList
|
||||
GtkTargetPair
|
||||
@@ -7018,6 +7020,7 @@ gtk_application_new
|
||||
gtk_application_add_window
|
||||
gtk_application_remove_window
|
||||
gtk_application_get_windows
|
||||
gtk_application_get_window_by_id
|
||||
|
||||
<SUBSECTION>
|
||||
GtkApplicationInhibitFlags
|
||||
@@ -7051,6 +7054,7 @@ GtkApplicationWindow
|
||||
gtk_application_window_new
|
||||
gtk_application_window_set_show_menubar
|
||||
gtk_application_window_get_show_menubar
|
||||
gtk_application_window_get_id
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GtkApplicationWindowClass
|
||||
|
||||
@@ -31,18 +31,18 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<row><entry>EggSMClient::quit-requested</entry><entry>instead of calling will_quit (FALSE,...) in response to this signal, install an inhibitor</entry></row>
|
||||
<row><entry>EggSMClient::quit</entry><entry>the #GtkApplication::quit signal</entry></row>
|
||||
<row><entry>EggSMClient::quit-cancelled</entry><entry></entry></row>
|
||||
<row><entry>EggSMClient::quit</entry><entry>the #GApplication::shutdown signal</entry></row>
|
||||
<row><entry>EggSMClient::quit-cancelled</entry><entry>-</entry></row>
|
||||
<row><entry>egg_sm_client_will_quit</entry><entry>instead of calling will_quit (FALSE,...), install an inhibitor</entry></row>
|
||||
<row><entry>egg_sm_client_end_session</entry><entry>gtk_application_end_session()</entry></row>
|
||||
<row><entry>egg_sm_client_end_session</entry><entry>-</entry></row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>
|
||||
At this point, GtkApplication has no special support for state saving.
|
||||
Applications can use GSettings or GKeyFile and save as much state as
|
||||
they see fit in response to #GtkApplication::quit or whenever they
|
||||
consider appropriate.
|
||||
At this point, GtkApplication has no special support for state saving
|
||||
and restarting. Applications can use GSettings or GKeyFile and save as
|
||||
much state as they see fit in response to #GApplication::shutdown or
|
||||
whenever they consider appropriate.
|
||||
</para>
|
||||
</chapter>
|
||||
|
||||
@@ -58,8 +58,8 @@ warning that occurs.
|
||||
<para>
|
||||
A list of <link linkend="GTK-Debug-Options">debug options</link>
|
||||
to turn on in addition to those specified in the <envar>GTK_DEBUG</envar>
|
||||
environment variable. This option is only available if GTK+ has been
|
||||
configured with <option>--enable-debug=yes</option>.
|
||||
environment variable. This option is not available if GTK+ has been
|
||||
configured with <option>--enable-debug=no</option>.
|
||||
</para>
|
||||
</formalpara>
|
||||
|
||||
@@ -134,7 +134,7 @@ additional environment variables.
|
||||
<title><envar>GTK_DEBUG</envar></title>
|
||||
|
||||
<para>
|
||||
If GTK+ has been configured with <option>--enable-debug=yes</option>,
|
||||
Unless GTK+ has been configured with <option>--enable-debug=no</option>,
|
||||
this variable can be set to a list of debug options, which cause GTK+
|
||||
to print out different types of debugging information.
|
||||
<variablelist>
|
||||
@@ -186,6 +186,14 @@ additional environment variables.
|
||||
<term>builder</term>
|
||||
<listitem><para>GtkBuilder support</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>size-request</term>
|
||||
<listitem><para>Size requests</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>no-css-cache</term>
|
||||
<listitem><para>Bypass caching for CSS style properties.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
The special value <literal>all</literal> can be used to turn on all
|
||||
|
||||
+3
-1
@@ -306,7 +306,9 @@ endif
|
||||
lib_LTLIBRARIES = libgdk-3.la
|
||||
|
||||
MAINTAINERCLEANFILES = $(gdk_built_sources) stamp-gdkenumtypes.h
|
||||
EXTRA_DIST += $(gdk_built_sources)
|
||||
EXTRA_DIST += \
|
||||
$(gdk_built_sources) \
|
||||
fallback-c89.c
|
||||
|
||||
install-exec-hook:
|
||||
if DISABLE_EXPLICIT_DEPS
|
||||
|
||||
@@ -40,15 +40,15 @@ static void gdk_broadway_device_warp (GdkDevice *device,
|
||||
GdkScreen *screen,
|
||||
gint x,
|
||||
gint y);
|
||||
static gboolean gdk_broadway_device_query_state (GdkDevice *device,
|
||||
GdkWindow *window,
|
||||
GdkWindow **root_window,
|
||||
GdkWindow **child_window,
|
||||
gint *root_x,
|
||||
gint *root_y,
|
||||
gint *win_x,
|
||||
gint *win_y,
|
||||
GdkModifierType *mask);
|
||||
static void gdk_broadway_device_query_state (GdkDevice *device,
|
||||
GdkWindow *window,
|
||||
GdkWindow **root_window,
|
||||
GdkWindow **child_window,
|
||||
gint *root_x,
|
||||
gint *root_y,
|
||||
gint *win_x,
|
||||
gint *win_y,
|
||||
GdkModifierType *mask);
|
||||
static GdkGrabStatus gdk_broadway_device_grab (GdkDevice *device,
|
||||
GdkWindow *window,
|
||||
gboolean owner_events,
|
||||
@@ -140,7 +140,7 @@ gdk_broadway_device_warp (GdkDevice *device,
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
gdk_broadway_device_query_state (GdkDevice *device,
|
||||
GdkWindow *window,
|
||||
GdkWindow **root_window,
|
||||
@@ -159,7 +159,7 @@ gdk_broadway_device_query_state (GdkDevice *device,
|
||||
gint device_root_x, device_root_y;
|
||||
|
||||
if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
|
||||
return FALSE;
|
||||
return;
|
||||
|
||||
display = gdk_device_get_display (device);
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||
@@ -196,7 +196,7 @@ gdk_broadway_device_query_state (GdkDevice *device,
|
||||
else
|
||||
*child_window = toplevel; /* No native children */
|
||||
}
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fallback when unconnected */
|
||||
@@ -229,7 +229,7 @@ gdk_broadway_device_query_state (GdkDevice *device,
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Chun-wei Fan <fanc999@yahoo.com.tw>
|
||||
*
|
||||
* Author: Chun-wei Fan <fanc999@yahoo.com.tw>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#ifndef HAVE_ISNAN
|
||||
/* it seems of the supported compilers only
|
||||
* MSVC does not have isnan(), but it does
|
||||
* have _isnan() which does the same as isnan()
|
||||
*/
|
||||
static inline gboolean
|
||||
isnan (double x)
|
||||
{
|
||||
return _isnan (x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ISINF
|
||||
/* Unfortunately MSVC does not have finite()
|
||||
* but it does have _finite() which is the same
|
||||
* as finite() except when x is a NaN
|
||||
*/
|
||||
static inline gboolean
|
||||
isinf (double x)
|
||||
{
|
||||
return (!_finite (x) && !_isnan (x));
|
||||
}
|
||||
#endif
|
||||
@@ -561,6 +561,8 @@ gdk_x11_get_xatom_name
|
||||
gdk_x11_get_xatom_name_for_display
|
||||
gdk_x11_grab_server
|
||||
gdk_x11_keymap_get_type
|
||||
gdk_x11_keymap_get_group_for_state
|
||||
gdk_x11_keymap_key_is_modifier
|
||||
gdk_x11_lookup_xdisplay
|
||||
gdk_x11_register_standard_event_type
|
||||
gdk_x11_screen_get_monitor_output
|
||||
|
||||
+1
-2
@@ -970,8 +970,7 @@ switch_to_pointer_grab (GdkDisplay *display,
|
||||
* synthesized when needed.
|
||||
*/
|
||||
if (source_device &&
|
||||
(gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN ||
|
||||
gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHPAD))
|
||||
(gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN))
|
||||
info->need_touch_press_enter = TRUE;
|
||||
|
||||
pointer_window = NULL;
|
||||
|
||||
@@ -244,16 +244,16 @@ gdk_display_manager_get (void)
|
||||
manager = g_object_new (gdk_win32_display_manager_get_type (), NULL);
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (backend == NULL || strcmp (backend, "wayland") == 0)
|
||||
manager = g_object_new (gdk_wayland_display_manager_get_type (), NULL);
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (backend == NULL || strcmp (backend, "x11") == 0)
|
||||
manager = g_object_new (gdk_x11_display_manager_get_type (), NULL);
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (backend == NULL || strcmp (backend, "wayland") == 0)
|
||||
manager = g_object_new (gdk_wayland_display_manager_get_type (), NULL);
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
if (backend == NULL || strcmp (backend, "broadway") == 0)
|
||||
manager = g_object_new (gdk_broadway_display_manager_get_type (), NULL);
|
||||
|
||||
+18
-1
@@ -225,8 +225,10 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
|
||||
* @GDK_2BUTTON_PRESS: a mouse button has been double-clicked (clicked twice
|
||||
* within a short period of time). Note that each click also generates a
|
||||
* %GDK_BUTTON_PRESS event.
|
||||
* @GDK_DOUBLE_BUTTON_PRESS: alias for %GDK_2BUTTON_PRESS, added in 3.6.
|
||||
* @GDK_3BUTTON_PRESS: a mouse button has been clicked 3 times in a short period
|
||||
* of time. Note that each click also generates a %GDK_BUTTON_PRESS event.
|
||||
* @GDK_TRIPLE_BUTTON_PRESS: alias for %GDK_3BUTTON_PRESS, added in 3.6.
|
||||
* @GDK_BUTTON_RELEASE: a mouse button has been released.
|
||||
* @GDK_KEY_PRESS: a key has been pressed.
|
||||
* @GDK_KEY_RELEASE: a key has been released.
|
||||
@@ -280,6 +282,13 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
|
||||
* Do not confuse these events with the signals that GTK+ widgets emit.
|
||||
* Although many of these events result in corresponding signals being emitted,
|
||||
* the events are often transformed or filtered along the way.
|
||||
*
|
||||
* In some language bindings, the values %GDK_2BUTTON_PRESS and
|
||||
* %GDK_3BUTTON_PRESS would translate into something syntactically
|
||||
* invalid (eg <literal>Gdk.EventType.2ButtonPress</literal>, where a
|
||||
* symbol is not allowed to start with a number). In that case, the
|
||||
* aliases %GDK_DOUBLE_BUTTON_PRESS and %GDK_TRIPLE_BUTTON_PRESS can
|
||||
* be used instead.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -290,7 +299,9 @@ typedef enum
|
||||
GDK_MOTION_NOTIFY = 3,
|
||||
GDK_BUTTON_PRESS = 4,
|
||||
GDK_2BUTTON_PRESS = 5,
|
||||
GDK_DOUBLE_BUTTON_PRESS = GDK_2BUTTON_PRESS,
|
||||
GDK_3BUTTON_PRESS = 6,
|
||||
GDK_TRIPLE_BUTTON_PRESS = GDK_3BUTTON_PRESS,
|
||||
GDK_BUTTON_RELEASE = 7,
|
||||
GDK_KEY_PRESS = 8,
|
||||
GDK_KEY_RELEASE = 9,
|
||||
@@ -736,7 +747,8 @@ struct _GdkEventTouch
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See #GdkModifierType.
|
||||
* @direction: the direction to scroll to (one of %GDK_SCROLL_UP,
|
||||
* %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT and %GDK_SCROLL_RIGHT).
|
||||
* %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT, %GDK_SCROLL_RIGHT or
|
||||
* %GDK_SCROLL_SMOOTH).
|
||||
* @device: the device where the event originated.
|
||||
* @x_root: the x coordinate of the pointer relative to the root of the
|
||||
* screen.
|
||||
@@ -746,6 +758,11 @@ struct _GdkEventTouch
|
||||
* Generated from button presses for the buttons 4 to 7. Wheel mice are
|
||||
* usually configured to generate button press events for buttons 4 and 5
|
||||
* when the wheel is turned.
|
||||
*
|
||||
* Some GDK backends can also generate 'smooth' scroll events, which
|
||||
* can be recognized by the %GDK_SCROLL_SMOOTH scroll direction. For
|
||||
* these, the scroll deltas can be obtained with
|
||||
* gdk_event_get_scroll_deltas().
|
||||
*/
|
||||
struct _GdkEventScroll
|
||||
{
|
||||
|
||||
+108
-14
@@ -286,6 +286,7 @@
|
||||
#define GDK_dead_U 0xfe89
|
||||
#define GDK_dead_small_schwa 0xfe8a
|
||||
#define GDK_dead_capital_schwa 0xfe8b
|
||||
#define GDK_dead_greek 0xfe8c
|
||||
#define GDK_First_Virtual_Screen 0xfed0
|
||||
#define GDK_Prev_Virtual_Screen 0xfed1
|
||||
#define GDK_Next_Virtual_Screen 0xfed2
|
||||
@@ -332,6 +333,12 @@
|
||||
#define GDK_Pointer_Accelerate 0xfefa
|
||||
#define GDK_Pointer_DfltBtnNext 0xfefb
|
||||
#define GDK_Pointer_DfltBtnPrev 0xfefc
|
||||
#define GDK_ch 0xfea0
|
||||
#define GDK_Ch 0xfea1
|
||||
#define GDK_CH 0xfea2
|
||||
#define GDK_c_h 0xfea3
|
||||
#define GDK_C_h 0xfea4
|
||||
#define GDK_C_H 0xfea5
|
||||
#define GDK_3270_Duplicate 0xfd01
|
||||
#define GDK_3270_FieldMark 0xfd02
|
||||
#define GDK_3270_Right2 0xfd03
|
||||
@@ -611,9 +618,9 @@
|
||||
#define GDK_nacute 0x1f1
|
||||
#define GDK_ncaron 0x1f2
|
||||
#define GDK_odoubleacute 0x1f5
|
||||
#define GDK_udoubleacute 0x1fb
|
||||
#define GDK_rcaron 0x1f8
|
||||
#define GDK_uring 0x1f9
|
||||
#define GDK_udoubleacute 0x1fb
|
||||
#define GDK_tcedilla 0x1fe
|
||||
#define GDK_abovedot 0x1ff
|
||||
#define GDK_Hstroke 0x2a1
|
||||
@@ -674,32 +681,32 @@
|
||||
#define GDK_uogonek 0x3f9
|
||||
#define GDK_utilde 0x3fd
|
||||
#define GDK_umacron 0x3fe
|
||||
#define GDK_Wcircumflex 0x1000174
|
||||
#define GDK_wcircumflex 0x1000175
|
||||
#define GDK_Ycircumflex 0x1000176
|
||||
#define GDK_ycircumflex 0x1000177
|
||||
#define GDK_Babovedot 0x1001e02
|
||||
#define GDK_babovedot 0x1001e03
|
||||
#define GDK_Dabovedot 0x1001e0a
|
||||
#define GDK_Wgrave 0x1001e80
|
||||
#define GDK_Wacute 0x1001e82
|
||||
#define GDK_dabovedot 0x1001e0b
|
||||
#define GDK_Ygrave 0x1001ef2
|
||||
#define GDK_Fabovedot 0x1001e1e
|
||||
#define GDK_fabovedot 0x1001e1f
|
||||
#define GDK_Mabovedot 0x1001e40
|
||||
#define GDK_mabovedot 0x1001e41
|
||||
#define GDK_Pabovedot 0x1001e56
|
||||
#define GDK_wgrave 0x1001e81
|
||||
#define GDK_pabovedot 0x1001e57
|
||||
#define GDK_wacute 0x1001e83
|
||||
#define GDK_Sabovedot 0x1001e60
|
||||
#define GDK_ygrave 0x1001ef3
|
||||
#define GDK_sabovedot 0x1001e61
|
||||
#define GDK_Tabovedot 0x1001e6a
|
||||
#define GDK_tabovedot 0x1001e6b
|
||||
#define GDK_Wgrave 0x1001e80
|
||||
#define GDK_wgrave 0x1001e81
|
||||
#define GDK_Wacute 0x1001e82
|
||||
#define GDK_wacute 0x1001e83
|
||||
#define GDK_Wdiaeresis 0x1001e84
|
||||
#define GDK_wdiaeresis 0x1001e85
|
||||
#define GDK_sabovedot 0x1001e61
|
||||
#define GDK_Wcircumflex 0x1000174
|
||||
#define GDK_Tabovedot 0x1001e6a
|
||||
#define GDK_Ycircumflex 0x1000176
|
||||
#define GDK_wcircumflex 0x1000175
|
||||
#define GDK_tabovedot 0x1001e6b
|
||||
#define GDK_ycircumflex 0x1000177
|
||||
#define GDK_Ygrave 0x1001ef2
|
||||
#define GDK_ygrave 0x1001ef3
|
||||
#define GDK_OE 0x13bc
|
||||
#define GDK_oe 0x13bd
|
||||
#define GDK_Ydiaeresis 0x13be
|
||||
@@ -1194,6 +1201,7 @@
|
||||
#define GDK_leftdoublequotemark 0xad2
|
||||
#define GDK_rightdoublequotemark 0xad3
|
||||
#define GDK_prescription 0xad4
|
||||
#define GDK_permille 0xad5
|
||||
#define GDK_minutes 0xad6
|
||||
#define GDK_seconds 0xad7
|
||||
#define GDK_latincross 0xad9
|
||||
@@ -1627,6 +1635,8 @@
|
||||
#define GDK_obarred 0x1000275
|
||||
#define GDK_SCHWA 0x100018f
|
||||
#define GDK_schwa 0x1000259
|
||||
#define GDK_EZH 0x10001b7
|
||||
#define GDK_ezh 0x1000292
|
||||
#define GDK_Lbelowdot 0x1001e36
|
||||
#define GDK_lbelowdot 0x1001e37
|
||||
#define GDK_Abelowdot 0x1001ea0
|
||||
@@ -2032,6 +2042,86 @@
|
||||
#define GDK_braille_dots_1345678 0x10028fd
|
||||
#define GDK_braille_dots_2345678 0x10028fe
|
||||
#define GDK_braille_dots_12345678 0x10028ff
|
||||
#define GDK_Sinh_ng 0x1000d82
|
||||
#define GDK_Sinh_h2 0x1000d83
|
||||
#define GDK_Sinh_a 0x1000d85
|
||||
#define GDK_Sinh_aa 0x1000d86
|
||||
#define GDK_Sinh_ae 0x1000d87
|
||||
#define GDK_Sinh_aee 0x1000d88
|
||||
#define GDK_Sinh_i 0x1000d89
|
||||
#define GDK_Sinh_ii 0x1000d8a
|
||||
#define GDK_Sinh_u 0x1000d8b
|
||||
#define GDK_Sinh_uu 0x1000d8c
|
||||
#define GDK_Sinh_ri 0x1000d8d
|
||||
#define GDK_Sinh_rii 0x1000d8e
|
||||
#define GDK_Sinh_lu 0x1000d8f
|
||||
#define GDK_Sinh_luu 0x1000d90
|
||||
#define GDK_Sinh_e 0x1000d91
|
||||
#define GDK_Sinh_ee 0x1000d92
|
||||
#define GDK_Sinh_ai 0x1000d93
|
||||
#define GDK_Sinh_o 0x1000d94
|
||||
#define GDK_Sinh_oo 0x1000d95
|
||||
#define GDK_Sinh_au 0x1000d96
|
||||
#define GDK_Sinh_ka 0x1000d9a
|
||||
#define GDK_Sinh_kha 0x1000d9b
|
||||
#define GDK_Sinh_ga 0x1000d9c
|
||||
#define GDK_Sinh_gha 0x1000d9d
|
||||
#define GDK_Sinh_ng2 0x1000d9e
|
||||
#define GDK_Sinh_nga 0x1000d9f
|
||||
#define GDK_Sinh_ca 0x1000da0
|
||||
#define GDK_Sinh_cha 0x1000da1
|
||||
#define GDK_Sinh_ja 0x1000da2
|
||||
#define GDK_Sinh_jha 0x1000da3
|
||||
#define GDK_Sinh_nya 0x1000da4
|
||||
#define GDK_Sinh_jnya 0x1000da5
|
||||
#define GDK_Sinh_nja 0x1000da6
|
||||
#define GDK_Sinh_tta 0x1000da7
|
||||
#define GDK_Sinh_ttha 0x1000da8
|
||||
#define GDK_Sinh_dda 0x1000da9
|
||||
#define GDK_Sinh_ddha 0x1000daa
|
||||
#define GDK_Sinh_nna 0x1000dab
|
||||
#define GDK_Sinh_ndda 0x1000dac
|
||||
#define GDK_Sinh_tha 0x1000dad
|
||||
#define GDK_Sinh_thha 0x1000dae
|
||||
#define GDK_Sinh_dha 0x1000daf
|
||||
#define GDK_Sinh_dhha 0x1000db0
|
||||
#define GDK_Sinh_na 0x1000db1
|
||||
#define GDK_Sinh_ndha 0x1000db3
|
||||
#define GDK_Sinh_pa 0x1000db4
|
||||
#define GDK_Sinh_pha 0x1000db5
|
||||
#define GDK_Sinh_ba 0x1000db6
|
||||
#define GDK_Sinh_bha 0x1000db7
|
||||
#define GDK_Sinh_ma 0x1000db8
|
||||
#define GDK_Sinh_mba 0x1000db9
|
||||
#define GDK_Sinh_ya 0x1000dba
|
||||
#define GDK_Sinh_ra 0x1000dbb
|
||||
#define GDK_Sinh_la 0x1000dbd
|
||||
#define GDK_Sinh_va 0x1000dc0
|
||||
#define GDK_Sinh_sha 0x1000dc1
|
||||
#define GDK_Sinh_ssha 0x1000dc2
|
||||
#define GDK_Sinh_sa 0x1000dc3
|
||||
#define GDK_Sinh_ha 0x1000dc4
|
||||
#define GDK_Sinh_lla 0x1000dc5
|
||||
#define GDK_Sinh_fa 0x1000dc6
|
||||
#define GDK_Sinh_al 0x1000dca
|
||||
#define GDK_Sinh_aa2 0x1000dcf
|
||||
#define GDK_Sinh_ae2 0x1000dd0
|
||||
#define GDK_Sinh_aee2 0x1000dd1
|
||||
#define GDK_Sinh_i2 0x1000dd2
|
||||
#define GDK_Sinh_ii2 0x1000dd3
|
||||
#define GDK_Sinh_u2 0x1000dd4
|
||||
#define GDK_Sinh_uu2 0x1000dd6
|
||||
#define GDK_Sinh_ru2 0x1000dd8
|
||||
#define GDK_Sinh_e2 0x1000dd9
|
||||
#define GDK_Sinh_ee2 0x1000dda
|
||||
#define GDK_Sinh_ai2 0x1000ddb
|
||||
#define GDK_Sinh_o2 0x1000ddc
|
||||
#define GDK_Sinh_oo2 0x1000ddd
|
||||
#define GDK_Sinh_au2 0x1000dde
|
||||
#define GDK_Sinh_lu2 0x1000ddf
|
||||
#define GDK_Sinh_ruu2 0x1000df2
|
||||
#define GDK_Sinh_luu2 0x1000df3
|
||||
#define GDK_Sinh_kunddaliya 0x1000df4
|
||||
#define GDK_ModeLock 0x1008ff01
|
||||
#define GDK_MonBrightnessUp 0x1008ff02
|
||||
#define GDK_MonBrightnessDown 0x1008ff03
|
||||
@@ -2186,6 +2276,8 @@
|
||||
#define GDK_Suspend 0x1008ffa7
|
||||
#define GDK_Hibernate 0x1008ffa8
|
||||
#define GDK_TouchpadToggle 0x1008ffa9
|
||||
#define GDK_TouchpadOn 0x1008ffb0
|
||||
#define GDK_TouchpadOff 0x1008ffb1
|
||||
#define GDK_Switch_VT_1 0x1008fe01
|
||||
#define GDK_Switch_VT_2 0x1008fe02
|
||||
#define GDK_Switch_VT_3 0x1008fe03
|
||||
@@ -2202,5 +2294,7 @@
|
||||
#define GDK_ClearGrab 0x1008fe21
|
||||
#define GDK_Next_VMode 0x1008fe22
|
||||
#define GDK_Prev_VMode 0x1008fe23
|
||||
#define GDK_LogWindowTree 0x1008fe24
|
||||
#define GDK_LogGrabInfo 0x1008fe25
|
||||
|
||||
#endif /* __GDK_KEYSYMS_COMPAT_H__ */
|
||||
|
||||
+18
-18
@@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# Updates http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms.h from upstream (X.org 7.x),
|
||||
# from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
|
||||
# Updates http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h from upstream (X.org 7.x),
|
||||
# from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
||||
#
|
||||
# Author : Simos Xenitellis <simos at gnome dot org>.
|
||||
# Authos : Bastien Nocera <hadess@hadess.net>
|
||||
# Version : 1.2
|
||||
#
|
||||
# Input : http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
|
||||
# Input : http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h
|
||||
# Output : http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms.h
|
||||
# Input : http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
||||
# Input : http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
|
||||
# Output : http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h
|
||||
#
|
||||
# Notes : It downloads keysymdef.h from the Internet, if not found locally,
|
||||
# Notes : and creates an updated gdkkeysyms.h
|
||||
@@ -23,31 +23,31 @@ my @keysymelements;
|
||||
if ( ! -f "keysymdef.h" )
|
||||
{
|
||||
print "Trying to download keysymdef.h from\n";
|
||||
print "http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\n";
|
||||
die "Unable to download keysymdef.h from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\n"
|
||||
unless system("wget -c -O keysymdef.h \"http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\"") == 0;
|
||||
print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n";
|
||||
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n"
|
||||
unless system("wget -c -O keysymdef.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\"") == 0;
|
||||
print " done.\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "We are using existing keysymdef.h found in this directory.\n";
|
||||
print "It is assumed that you took care and it is a recent version\n";
|
||||
print "as found at http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=keysymdef.h\n\n";
|
||||
print "as found at http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n\n";
|
||||
}
|
||||
|
||||
if ( ! -f "XF86keysym.h" )
|
||||
{
|
||||
print "Trying to download XF86keysym.h from\n";
|
||||
print "http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h\n";
|
||||
die "Unable to download keysymdef.h from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h\n"
|
||||
unless system("wget -c -O XF86keysym.h \"http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h\"") == 0;
|
||||
print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n";
|
||||
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n"
|
||||
unless system("wget -c -O XF86keysym.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\"") == 0;
|
||||
print " done.\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "We are using existing XF86keysym.h found in this directory.\n";
|
||||
print "It is assumed that you took care and it is a recent version\n";
|
||||
print "as found at http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=XF86keysym.h\n\n";
|
||||
print "as found at http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n\n";
|
||||
}
|
||||
|
||||
if ( -f "gdkkeysyms.h" )
|
||||
@@ -57,7 +57,7 @@ if ( -f "gdkkeysyms.h" )
|
||||
die "Exiting...\n\n";
|
||||
}
|
||||
|
||||
# Source: http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=keysymdef.h
|
||||
# Source: http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
||||
die "Could not open file keysymdef.h: $!\n" unless open(IN_KEYSYMDEF, "<:utf8", "keysymdef.h");
|
||||
|
||||
# Output: gtk+/gdk/gdkkeysyms.h
|
||||
@@ -93,11 +93,11 @@ print OUT_GDKKEYSYMS_COMPAT $LICENSE_HEADER;
|
||||
print OUT_GDKKEYSYMS<<EOF;
|
||||
|
||||
/*
|
||||
* File auto-generated from script http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms-update.pl
|
||||
* File auto-generated from script http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms-update.pl
|
||||
* using the input file
|
||||
* http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
|
||||
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
||||
* and
|
||||
* http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h
|
||||
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -154,7 +154,7 @@ close IN_KEYSYMDEF;
|
||||
|
||||
#$gdksyms{"0"} = "0000";
|
||||
|
||||
# Source: http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=XF86keysym.h
|
||||
# Source: http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
|
||||
die "Could not open file XF86keysym.h: $!\n" unless open(IN_XF86KEYSYM, "<:utf8", "XF86keysym.h");
|
||||
|
||||
while (<IN_XF86KEYSYM>)
|
||||
|
||||
+29
-17
@@ -18,11 +18,11 @@
|
||||
|
||||
|
||||
/*
|
||||
* File auto-generated from script http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms-update.pl
|
||||
* File auto-generated from script http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms-update.pl
|
||||
* using the input file
|
||||
* http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
|
||||
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
||||
* and
|
||||
* http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h
|
||||
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -295,6 +295,7 @@
|
||||
#define GDK_KEY_dead_U 0xfe89
|
||||
#define GDK_KEY_dead_small_schwa 0xfe8a
|
||||
#define GDK_KEY_dead_capital_schwa 0xfe8b
|
||||
#define GDK_KEY_dead_greek 0xfe8c
|
||||
#define GDK_KEY_First_Virtual_Screen 0xfed0
|
||||
#define GDK_KEY_Prev_Virtual_Screen 0xfed1
|
||||
#define GDK_KEY_Next_Virtual_Screen 0xfed2
|
||||
@@ -341,6 +342,12 @@
|
||||
#define GDK_KEY_Pointer_Accelerate 0xfefa
|
||||
#define GDK_KEY_Pointer_DfltBtnNext 0xfefb
|
||||
#define GDK_KEY_Pointer_DfltBtnPrev 0xfefc
|
||||
#define GDK_KEY_ch 0xfea0
|
||||
#define GDK_KEY_Ch 0xfea1
|
||||
#define GDK_KEY_CH 0xfea2
|
||||
#define GDK_KEY_c_h 0xfea3
|
||||
#define GDK_KEY_C_h 0xfea4
|
||||
#define GDK_KEY_C_H 0xfea5
|
||||
#define GDK_KEY_3270_Duplicate 0xfd01
|
||||
#define GDK_KEY_3270_FieldMark 0xfd02
|
||||
#define GDK_KEY_3270_Right2 0xfd03
|
||||
@@ -620,9 +627,9 @@
|
||||
#define GDK_KEY_nacute 0x1f1
|
||||
#define GDK_KEY_ncaron 0x1f2
|
||||
#define GDK_KEY_odoubleacute 0x1f5
|
||||
#define GDK_KEY_udoubleacute 0x1fb
|
||||
#define GDK_KEY_rcaron 0x1f8
|
||||
#define GDK_KEY_uring 0x1f9
|
||||
#define GDK_KEY_udoubleacute 0x1fb
|
||||
#define GDK_KEY_tcedilla 0x1fe
|
||||
#define GDK_KEY_abovedot 0x1ff
|
||||
#define GDK_KEY_Hstroke 0x2a1
|
||||
@@ -683,32 +690,32 @@
|
||||
#define GDK_KEY_uogonek 0x3f9
|
||||
#define GDK_KEY_utilde 0x3fd
|
||||
#define GDK_KEY_umacron 0x3fe
|
||||
#define GDK_KEY_Wcircumflex 0x1000174
|
||||
#define GDK_KEY_wcircumflex 0x1000175
|
||||
#define GDK_KEY_Ycircumflex 0x1000176
|
||||
#define GDK_KEY_ycircumflex 0x1000177
|
||||
#define GDK_KEY_Babovedot 0x1001e02
|
||||
#define GDK_KEY_babovedot 0x1001e03
|
||||
#define GDK_KEY_Dabovedot 0x1001e0a
|
||||
#define GDK_KEY_Wgrave 0x1001e80
|
||||
#define GDK_KEY_Wacute 0x1001e82
|
||||
#define GDK_KEY_dabovedot 0x1001e0b
|
||||
#define GDK_KEY_Ygrave 0x1001ef2
|
||||
#define GDK_KEY_Fabovedot 0x1001e1e
|
||||
#define GDK_KEY_fabovedot 0x1001e1f
|
||||
#define GDK_KEY_Mabovedot 0x1001e40
|
||||
#define GDK_KEY_mabovedot 0x1001e41
|
||||
#define GDK_KEY_Pabovedot 0x1001e56
|
||||
#define GDK_KEY_wgrave 0x1001e81
|
||||
#define GDK_KEY_pabovedot 0x1001e57
|
||||
#define GDK_KEY_wacute 0x1001e83
|
||||
#define GDK_KEY_Sabovedot 0x1001e60
|
||||
#define GDK_KEY_ygrave 0x1001ef3
|
||||
#define GDK_KEY_sabovedot 0x1001e61
|
||||
#define GDK_KEY_Tabovedot 0x1001e6a
|
||||
#define GDK_KEY_tabovedot 0x1001e6b
|
||||
#define GDK_KEY_Wgrave 0x1001e80
|
||||
#define GDK_KEY_wgrave 0x1001e81
|
||||
#define GDK_KEY_Wacute 0x1001e82
|
||||
#define GDK_KEY_wacute 0x1001e83
|
||||
#define GDK_KEY_Wdiaeresis 0x1001e84
|
||||
#define GDK_KEY_wdiaeresis 0x1001e85
|
||||
#define GDK_KEY_sabovedot 0x1001e61
|
||||
#define GDK_KEY_Wcircumflex 0x1000174
|
||||
#define GDK_KEY_Tabovedot 0x1001e6a
|
||||
#define GDK_KEY_Ycircumflex 0x1000176
|
||||
#define GDK_KEY_wcircumflex 0x1000175
|
||||
#define GDK_KEY_tabovedot 0x1001e6b
|
||||
#define GDK_KEY_ycircumflex 0x1000177
|
||||
#define GDK_KEY_Ygrave 0x1001ef2
|
||||
#define GDK_KEY_ygrave 0x1001ef3
|
||||
#define GDK_KEY_OE 0x13bc
|
||||
#define GDK_KEY_oe 0x13bd
|
||||
#define GDK_KEY_Ydiaeresis 0x13be
|
||||
@@ -1203,6 +1210,7 @@
|
||||
#define GDK_KEY_leftdoublequotemark 0xad2
|
||||
#define GDK_KEY_rightdoublequotemark 0xad3
|
||||
#define GDK_KEY_prescription 0xad4
|
||||
#define GDK_KEY_permille 0xad5
|
||||
#define GDK_KEY_minutes 0xad6
|
||||
#define GDK_KEY_seconds 0xad7
|
||||
#define GDK_KEY_latincross 0xad9
|
||||
@@ -1636,6 +1644,8 @@
|
||||
#define GDK_KEY_obarred 0x1000275
|
||||
#define GDK_KEY_SCHWA 0x100018f
|
||||
#define GDK_KEY_schwa 0x1000259
|
||||
#define GDK_KEY_EZH 0x10001b7
|
||||
#define GDK_KEY_ezh 0x1000292
|
||||
#define GDK_KEY_Lbelowdot 0x1001e36
|
||||
#define GDK_KEY_lbelowdot 0x1001e37
|
||||
#define GDK_KEY_Abelowdot 0x1001ea0
|
||||
@@ -2293,5 +2303,7 @@
|
||||
#define GDK_KEY_ClearGrab 0x1008fe21
|
||||
#define GDK_KEY_Next_VMode 0x1008fe22
|
||||
#define GDK_KEY_Prev_VMode 0x1008fe23
|
||||
#define GDK_KEY_LogWindowTree 0x1008fe24
|
||||
#define GDK_KEY_LogGrabInfo 0x1008fe25
|
||||
|
||||
#endif /* __GDK_KEYSYMS_H__ */
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "fallback-c89.c"
|
||||
|
||||
/**
|
||||
* SECTION:rgba_colors
|
||||
* @Short_description: RGBA colors
|
||||
|
||||
@@ -80,6 +80,16 @@
|
||||
*/
|
||||
#define GDK_VERSION_3_4 (G_ENCODE_VERSION (3, 4))
|
||||
|
||||
/**
|
||||
* GDK_VERSION_3_6:
|
||||
*
|
||||
* A macro that evaluates to the 3.6 version of GDK, in a format
|
||||
* that can be used by the C pre-processor.
|
||||
*
|
||||
* Since: 3.6
|
||||
*/
|
||||
#define GDK_VERSION_3_6 (G_ENCODE_VERSION (3, 6))
|
||||
|
||||
|
||||
/* evaluates to the current stable version; for development cycles,
|
||||
* this means the next stable target
|
||||
@@ -105,7 +115,7 @@
|
||||
* The definition should be one of the predefined GDK version
|
||||
* macros: %GDK_VERSION_3_0, %GDK_VERSION_3_2,...
|
||||
*
|
||||
* This macro defines the lower bound for the GLib API to use.
|
||||
* This macro defines the lower bound for the GDK API to use.
|
||||
*
|
||||
* If a function has been deprecated in a newer version of GDK,
|
||||
* it is possible to use this symbol to avoid the compiler warnings
|
||||
@@ -114,7 +124,7 @@
|
||||
* Since: 3.4
|
||||
*/
|
||||
#ifndef GDK_VERSION_MIN_REQUIRED
|
||||
# define GDK_VERSION_MIN_REQUIRED (GDK_VERSION_PREV_STABLE)
|
||||
# define GDK_VERSION_MIN_REQUIRED (GDK_VERSION_CUR_STABLE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -193,4 +203,18 @@
|
||||
# define GDK_AVAILABLE_IN_3_4
|
||||
#endif
|
||||
|
||||
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_6
|
||||
# define GDK_DEPRECATED_IN_3_6 GDK_DEPRECATED
|
||||
# define GDK_DEPRECATED_IN_3_6_FOR(f) GDK_DEPRECATED_FOR(f)
|
||||
#else
|
||||
# define GDK_DEPRECATED_IN_3_6
|
||||
# define GDK_DEPRECATED_IN_3_6_FOR(f)
|
||||
#endif
|
||||
|
||||
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_3_6
|
||||
# define GDK_AVAILABLE_IN_3_6 GDK_UNAVAILABLE(3, 6)
|
||||
#else
|
||||
# define GDK_AVAILABLE_IN_3_6
|
||||
#endif
|
||||
|
||||
#endif /* __GDK_VERSION_MACROS_H__ */
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define GDK_TYPE_WAYLAND_CURSOR (_gdk_wayland_cursor_get_type ())
|
||||
#define GDK_WAYLAND_CURSOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_CURSOR, GdkWaylandCursor))
|
||||
@@ -163,7 +164,7 @@ set_pixbuf (GdkWaylandCursor *cursor, GdkPixbuf *pixbuf)
|
||||
}
|
||||
|
||||
static GdkCursor *
|
||||
create_cursor(GdkDisplayWayland *display, GdkPixbuf *pixbuf, int x, int y)
|
||||
create_cursor(GdkWaylandDisplay *display, GdkPixbuf *pixbuf, int x, int y)
|
||||
{
|
||||
GdkWaylandCursor *cursor;
|
||||
int stride, fd;
|
||||
@@ -193,28 +194,34 @@ create_cursor(GdkDisplayWayland *display, GdkPixbuf *pixbuf, int x, int y)
|
||||
cursor->size = stride * cursor->height;
|
||||
|
||||
fd = g_file_open_tmp("wayland-shm-XXXXXX", &filename, &error);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "g_file_open_tmp failed: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
if (fd < 0)
|
||||
{
|
||||
g_critical (G_STRLOC ": Error opening temporary file for buffer: %s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unlink (filename);
|
||||
g_free (filename);
|
||||
|
||||
if (ftruncate(fd, cursor->size) < 0) {
|
||||
fprintf(stderr, "ftruncate failed: %m\n");
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
if (ftruncate(fd, cursor->size) < 0)
|
||||
{
|
||||
g_critical (G_STRLOC ": Error truncating file for buffer: %s",
|
||||
g_strerror (errno));
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor->map = mmap(NULL, cursor->size,
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (cursor->map == MAP_FAILED) {
|
||||
fprintf(stderr, "mmap failed: %m\n");
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (cursor->map == MAP_FAILED)
|
||||
{
|
||||
g_critical (G_STRLOC ": Error mmap'ing file for buffer: %s",
|
||||
g_strerror (errno));
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pixbuf)
|
||||
set_pixbuf (cursor, pixbuf);
|
||||
@@ -251,7 +258,7 @@ GdkCursor *
|
||||
_gdk_wayland_display_get_cursor_for_type (GdkDisplay *display,
|
||||
GdkCursorType cursor_type)
|
||||
{
|
||||
GdkDisplayWayland *wayland_display;
|
||||
GdkWaylandDisplay *wayland_display;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GError *error = NULL;
|
||||
int i;
|
||||
@@ -269,7 +276,7 @@ _gdk_wayland_display_get_cursor_for_type (GdkDisplay *display,
|
||||
i = 0;
|
||||
}
|
||||
|
||||
wayland_display = GDK_DISPLAY_WAYLAND (display);
|
||||
wayland_display = GDK_WAYLAND_DISPLAY (display);
|
||||
if (!wayland_display->cursors)
|
||||
wayland_display->cursors =
|
||||
g_new0 (GdkCursor *, G_N_ELEMENTS(cursor_definitions));
|
||||
|
||||
@@ -350,7 +350,7 @@ input_handle_motion(void *data, struct wl_input_device *input_device,
|
||||
int32_t x, int32_t y, int32_t sx, int32_t sy)
|
||||
{
|
||||
GdkWaylandDevice *device = data;
|
||||
GdkDisplayWayland *display = GDK_DISPLAY_WAYLAND (device->display);
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display);
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_NOTHING);
|
||||
@@ -386,7 +386,7 @@ input_handle_button(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
GdkWaylandDevice *device = data;
|
||||
GdkDisplayWayland *display = GDK_DISPLAY_WAYLAND (device->display);
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display);
|
||||
GdkEvent *event;
|
||||
uint32_t modifier;
|
||||
int gdk_button;
|
||||
@@ -911,14 +911,14 @@ _gdk_wayland_device_manager_add_device (GdkDeviceManager *device_manager,
|
||||
struct wl_input_device *wl_device)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
GdkDeviceManagerCore *device_manager_core =
|
||||
GDK_DEVICE_MANAGER_CORE(device_manager);
|
||||
GdkWaylandDevice *device;
|
||||
|
||||
device = g_new0 (GdkWaylandDevice, 1);
|
||||
display = gdk_device_manager_get_display (device_manager);
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
device->display = display;
|
||||
device->pointer = g_object_new (GDK_TYPE_DEVICE_CORE,
|
||||
@@ -1258,7 +1258,7 @@ gdk_wayland_device_offer_selection_content (GdkDevice
|
||||
gpointer userdata)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
GdkWaylandSelectionOffer *offer;
|
||||
GdkWaylandDevice *device;
|
||||
gint i;
|
||||
@@ -1267,7 +1267,7 @@ gdk_wayland_device_offer_selection_content (GdkDevice
|
||||
device = GDK_DEVICE_CORE (gdk_device)->device;
|
||||
|
||||
display = device->display;
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
offer = g_new0 (GdkWaylandSelectionOffer, 1);
|
||||
offer->cb = cb;
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
#include <wayland-egl.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -36,17 +38,17 @@
|
||||
#include "gdkkeysprivate.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
|
||||
G_DEFINE_TYPE (GdkDisplayWayland, _gdk_display_wayland, GDK_TYPE_DISPLAY)
|
||||
G_DEFINE_TYPE (GdkWaylandDisplay, _gdk_wayland_display, GDK_TYPE_DISPLAY)
|
||||
|
||||
static void
|
||||
gdk_input_init (GdkDisplay *display)
|
||||
{
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
GdkDeviceManager *device_manager;
|
||||
GdkDevice *device;
|
||||
GList *list, *l;
|
||||
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
device_manager = gdk_display_get_device_manager (display);
|
||||
|
||||
/* For backwards compatibility, just add
|
||||
@@ -118,7 +120,7 @@ static void
|
||||
gdk_display_handle_global(struct wl_display *display, uint32_t id,
|
||||
const char *interface, uint32_t version, void *data)
|
||||
{
|
||||
GdkDisplayWayland *display_wayland = data;
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
GdkDisplay *gdk_display = GDK_DISPLAY_OBJECT (data);
|
||||
struct wl_input_device *input;
|
||||
|
||||
@@ -145,18 +147,19 @@ gdk_display_handle_global(struct wl_display *display, uint32_t id,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
static gboolean
|
||||
gdk_display_init_egl(GdkDisplay *display)
|
||||
{
|
||||
GdkDisplayWayland *display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
EGLint major, minor, i;
|
||||
void *p;
|
||||
|
||||
static const struct { const char *f; unsigned int offset; }
|
||||
extension_functions[] = {
|
||||
{ "glEGLImageTargetTexture2DOES", offsetof(GdkDisplayWayland, image_target_texture_2d) },
|
||||
{ "eglCreateImageKHR", offsetof(GdkDisplayWayland, create_image) },
|
||||
{ "eglDestroyImageKHR", offsetof(GdkDisplayWayland, destroy_image) }
|
||||
{ "glEGLImageTargetTexture2DOES", offsetof(GdkWaylandDisplay, image_target_texture_2d) },
|
||||
{ "eglCreateImageKHR", offsetof(GdkWaylandDisplay, create_image) },
|
||||
{ "eglDestroyImageKHR", offsetof(GdkWaylandDisplay, destroy_image) }
|
||||
};
|
||||
|
||||
display_wayland->egl_display =
|
||||
@@ -200,20 +203,21 @@ gdk_display_init_egl(GdkDisplay *display)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
GdkDisplay *
|
||||
_gdk_wayland_display_open (const gchar *display_name)
|
||||
{
|
||||
struct wl_display *wl_display;
|
||||
GdkDisplay *display;
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
|
||||
wl_display = wl_display_connect(display_name);
|
||||
if (!wl_display)
|
||||
return NULL;
|
||||
|
||||
display = g_object_new (GDK_TYPE_DISPLAY_WAYLAND, NULL);
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display = g_object_new (GDK_TYPE_WAYLAND_DISPLAY, NULL);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
display_wayland->wl_display = wl_display;
|
||||
|
||||
@@ -225,7 +229,12 @@ _gdk_wayland_display_open (const gchar *display_name)
|
||||
wl_display_add_global_listener(display_wayland->wl_display,
|
||||
gdk_display_handle_global, display_wayland);
|
||||
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
gdk_display_init_egl(display);
|
||||
#else
|
||||
wl_display_iterate(wl_display, WL_DISPLAY_READABLE);
|
||||
wl_display_roundtrip(wl_display);
|
||||
#endif
|
||||
|
||||
display_wayland->event_source =
|
||||
_gdk_wayland_display_event_source_new (display);
|
||||
@@ -241,7 +250,7 @@ _gdk_wayland_display_open (const gchar *display_name)
|
||||
static void
|
||||
gdk_wayland_display_dispose (GObject *object)
|
||||
{
|
||||
GdkDisplayWayland *display_wayland = GDK_DISPLAY_WAYLAND (object);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (object);
|
||||
|
||||
_gdk_wayland_display_manager_remove_display (gdk_display_manager_get (),
|
||||
GDK_DISPLAY (display_wayland));
|
||||
@@ -257,15 +266,17 @@ gdk_wayland_display_dispose (GObject *object)
|
||||
display_wayland->event_source = NULL;
|
||||
}
|
||||
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
eglTerminate(display_wayland->egl_display);
|
||||
#endif
|
||||
|
||||
G_OBJECT_CLASS (_gdk_display_wayland_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (_gdk_wayland_display_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_display_finalize (GObject *object)
|
||||
{
|
||||
GdkDisplayWayland *display_wayland = GDK_DISPLAY_WAYLAND (object);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (object);
|
||||
|
||||
/* Keymap */
|
||||
if (display_wayland->keymap)
|
||||
@@ -278,7 +289,7 @@ gdk_wayland_display_finalize (GObject *object)
|
||||
|
||||
g_free (display_wayland->startup_notification_id);
|
||||
|
||||
G_OBJECT_CLASS (_gdk_display_wayland_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (_gdk_wayland_display_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
@@ -300,7 +311,7 @@ gdk_wayland_display_get_screen (GdkDisplay *display,
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||
g_return_val_if_fail (screen_num == 0, NULL);
|
||||
|
||||
return GDK_DISPLAY_WAYLAND (display)->screen;
|
||||
return GDK_WAYLAND_DISPLAY (display)->screen;
|
||||
}
|
||||
|
||||
static GdkScreen *
|
||||
@@ -308,7 +319,7 @@ gdk_wayland_display_get_default_screen (GdkDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||
|
||||
return GDK_DISPLAY_WAYLAND (display)->screen;
|
||||
return GDK_WAYLAND_DISPLAY (display)->screen;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -320,11 +331,11 @@ gdk_wayland_display_beep (GdkDisplay *display)
|
||||
static void
|
||||
gdk_wayland_display_sync (GdkDisplay *display)
|
||||
{
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
wl_display_roundtrip(display_wayland->wl_display);
|
||||
}
|
||||
@@ -336,7 +347,7 @@ gdk_wayland_display_flush (GdkDisplay *display)
|
||||
|
||||
if (!display->closed)
|
||||
_gdk_wayland_display_flush (display,
|
||||
GDK_DISPLAY_WAYLAND (display)->event_source);
|
||||
GDK_WAYLAND_DISPLAY (display)->event_source);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -406,7 +417,7 @@ gdk_wayland_display_list_devices (GdkDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||
|
||||
return GDK_DISPLAY_WAYLAND (display)->input_devices;
|
||||
return GDK_WAYLAND_DISPLAY (display)->input_devices;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -520,10 +531,10 @@ gdk_wayland_display_event_data_free (GdkDisplay *display,
|
||||
static GdkKeymap *
|
||||
gdk_wayland_display_get_keymap (GdkDisplay *display)
|
||||
{
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
if (!display_wayland->keymap)
|
||||
display_wayland->keymap = _gdk_wayland_keymap_new (display);
|
||||
@@ -544,7 +555,7 @@ gdk_wayland_display_pop_error_trap (GdkDisplay *display,
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_display_wayland_class_init (GdkDisplayWaylandClass * class)
|
||||
_gdk_wayland_display_class_init (GdkWaylandDisplayClass * class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
|
||||
@@ -599,7 +610,7 @@ _gdk_display_wayland_class_init (GdkDisplayWaylandClass * class)
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_display_wayland_init (GdkDisplayWayland *display)
|
||||
_gdk_wayland_display_init (GdkWaylandDisplay *display)
|
||||
{
|
||||
_gdk_wayland_display_manager_add_display (gdk_display_manager_get (),
|
||||
GDK_DISPLAY (display));
|
||||
|
||||
@@ -19,17 +19,22 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_DISPLAY_WAYLAND__
|
||||
#define __GDK_DISPLAY_WAYLAND__
|
||||
#ifndef __GDK_WAYLAND_DISPLAY__
|
||||
#define __GDK_WAYLAND_DISPLAY__
|
||||
|
||||
#include <config.h>
|
||||
#include <stdint.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
#include <wayland-egl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#include <cairo-gl.h>
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdkkeys.h>
|
||||
#include <gdk/gdkwindow.h>
|
||||
@@ -40,17 +45,17 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GdkDisplayWayland GdkDisplayWayland;
|
||||
typedef struct _GdkDisplayWaylandClass GdkDisplayWaylandClass;
|
||||
typedef struct _GdkWaylandDisplay GdkWaylandDisplay;
|
||||
typedef struct _GdkWaylandDisplayClass GdkWaylandDisplayClass;
|
||||
|
||||
#define GDK_TYPE_DISPLAY_WAYLAND (_gdk_display_wayland_get_type())
|
||||
#define GDK_DISPLAY_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_WAYLAND, GdkDisplayWayland))
|
||||
#define GDK_DISPLAY_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_WAYLAND, GdkDisplayWaylandClass))
|
||||
#define GDK_IS_DISPLAY_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY_WAYLAND))
|
||||
#define GDK_IS_DISPLAY_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY_WAYLAND))
|
||||
#define GDK_DISPLAY_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY_WAYLAND, GdkDisplayWaylandClass))
|
||||
#define GDK_TYPE_WAYLAND_DISPLAY (_gdk_wayland_display_get_type())
|
||||
#define GDK_WAYLAND_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplay))
|
||||
#define GDK_WAYLAND_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplayClass))
|
||||
#define GDK_IS_WAYLAND_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DISPLAY))
|
||||
#define GDK_IS_WAYLAND_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DISPLAY))
|
||||
#define GDK_WAYLAND_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplayClass))
|
||||
|
||||
struct _GdkDisplayWayland
|
||||
struct _GdkWaylandDisplay
|
||||
{
|
||||
GdkDisplay parent_instance;
|
||||
GdkScreen *screen;
|
||||
@@ -76,24 +81,29 @@ struct _GdkDisplayWayland
|
||||
struct wl_input_device *input_device;
|
||||
struct wl_data_device_manager *data_device_manager;
|
||||
GSource *event_source;
|
||||
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
EGLDisplay egl_display;
|
||||
EGLContext egl_context;
|
||||
cairo_device_t *cairo_device;
|
||||
#endif
|
||||
|
||||
GdkCursor **cursors;
|
||||
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
|
||||
PFNEGLCREATEIMAGEKHRPROC create_image;
|
||||
PFNEGLDESTROYIMAGEKHRPROC destroy_image;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct _GdkDisplayWaylandClass
|
||||
struct _GdkWaylandDisplayClass
|
||||
{
|
||||
GdkDisplayClass parent_class;
|
||||
};
|
||||
|
||||
GType _gdk_display_wayland_get_type (void);
|
||||
GType _gdk_wayland_display_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_DISPLAY_WAYLAND__ */
|
||||
#endif /* __GDK_WAYLAND_DISPLAY__ */
|
||||
|
||||
@@ -24,21 +24,11 @@
|
||||
#include "gdkdisplaymanagerprivate.h"
|
||||
#include "gdkdisplay-wayland.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
|
||||
#include "gdkwayland.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
#include <X11/extensions/XKBcommon.h>
|
||||
|
||||
typedef struct _GdkWaylandDisplayManager GdkWaylandDisplayManager;
|
||||
typedef struct _GdkWaylandDisplayManagerClass GdkWaylandDisplayManagerClass;
|
||||
|
||||
#define GDK_TYPE_WAYLAND_DISPLAY_MANAGER (gdk_wayland_display_manager_get_type())
|
||||
#define GDK_WAYLAND_DISPLAY_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManager))
|
||||
#define GDK_WAYLAND_DISPLAY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManagerClass))
|
||||
#define GDK_IS_WAYLAND_DISPLAY_MANAGER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DISPLAY_MANAGER))
|
||||
#define GDK_IS_WAYLAND_DISPLAY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DISPLAY_MANAGER))
|
||||
#define GDK_WAYLAND_DISPLAY_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManagerClass))
|
||||
|
||||
struct _GdkWaylandDisplayManager
|
||||
{
|
||||
GdkDisplayManager parent;
|
||||
|
||||
@@ -33,7 +33,7 @@ static gboolean
|
||||
gdk_event_source_prepare(GSource *base, gint *timeout)
|
||||
{
|
||||
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
|
||||
GdkDisplayWayland *display = (GdkDisplayWayland *) source->display;
|
||||
GdkWaylandDisplay *display = (GdkWaylandDisplay *) source->display;
|
||||
|
||||
*timeout = -1;
|
||||
|
||||
@@ -122,7 +122,7 @@ _gdk_wayland_display_event_source_new (GdkDisplay *display)
|
||||
{
|
||||
GSource *source;
|
||||
GdkWaylandEventSource *wl_source;
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
char *name;
|
||||
|
||||
source = g_source_new (&wl_glib_source_funcs,
|
||||
@@ -132,7 +132,7 @@ _gdk_wayland_display_event_source_new (GdkDisplay *display)
|
||||
g_free (name);
|
||||
wl_source = (GdkWaylandEventSource *) source;
|
||||
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
wl_source->display = display;
|
||||
wl_source->pfd.fd = wl_display_get_fd(display_wayland->wl_display,
|
||||
gdk_event_source_update, source);
|
||||
@@ -154,17 +154,17 @@ _gdk_wayland_display_flush (GdkDisplay *display, GSource *source)
|
||||
GdkWaylandEventSource *wayland_source = (GdkWaylandEventSource *) source;
|
||||
|
||||
while (wayland_source->mask & WL_DISPLAY_WRITABLE)
|
||||
wl_display_iterate(GDK_DISPLAY_WAYLAND (display)->wl_display,
|
||||
wl_display_iterate(GDK_WAYLAND_DISPLAY (display)->wl_display,
|
||||
WL_DISPLAY_WRITABLE);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_wayland_display_queue_events (GdkDisplay *display)
|
||||
{
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
GdkWaylandEventSource *source;
|
||||
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
source = (GdkWaylandEventSource *) display_wayland->event_source;
|
||||
|
||||
if (source->pfd.revents)
|
||||
|
||||
@@ -28,19 +28,19 @@
|
||||
#include "gdkwayland.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
|
||||
typedef struct _GdkScreenWayland GdkScreenWayland;
|
||||
typedef struct _GdkScreenWaylandClass GdkScreenWaylandClass;
|
||||
typedef struct _GdkWaylandScreen GdkWaylandScreen;
|
||||
typedef struct _GdkWaylandScreenClass GdkWaylandScreenClass;
|
||||
|
||||
#define GDK_TYPE_SCREEN_WAYLAND (_gdk_screen_wayland_get_type ())
|
||||
#define GDK_SCREEN_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_SCREEN_WAYLAND, GdkScreenWayland))
|
||||
#define GDK_SCREEN_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_SCREEN_WAYLAND, GdkScreenWaylandClass))
|
||||
#define GDK_IS_SCREEN_WAYLAND(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_SCREEN_WAYLAND))
|
||||
#define GDK_IS_SCREEN_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_SCREEN_WAYLAND))
|
||||
#define GDK_SCREEN_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SCREEN_WAYLAND, GdkScreenWaylandClass))
|
||||
#define GDK_TYPE_WAYLAND_SCREEN (_gdk_wayland_screen_get_type ())
|
||||
#define GDK_WAYLAND_SCREEN(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_SCREEN, GdkWaylandScreen))
|
||||
#define GDK_WAYLAND_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_SCREEN, GdkWaylandScreenClass))
|
||||
#define GDK_IS_WAYLAND_SCREEN(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_SCREEN))
|
||||
#define GDK_IS_WAYLAND_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_SCREEN))
|
||||
#define GDK_WAYLAND_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_SCREEN, GdkWaylandScreenClass))
|
||||
|
||||
typedef struct _GdkWaylandMonitor GdkWaylandMonitor;
|
||||
|
||||
struct _GdkScreenWayland
|
||||
struct _GdkWaylandScreen
|
||||
{
|
||||
GdkScreen parent_instance;
|
||||
|
||||
@@ -59,11 +59,11 @@ struct _GdkScreenWayland
|
||||
gint primary_monitor;
|
||||
};
|
||||
|
||||
struct _GdkScreenWaylandClass
|
||||
struct _GdkWaylandScreenClass
|
||||
{
|
||||
GdkScreenClass parent_class;
|
||||
|
||||
void (* window_manager_changed) (GdkScreenWayland *screen_wayland);
|
||||
void (* window_manager_changed) (GdkWaylandScreen *screen_wayland);
|
||||
};
|
||||
|
||||
struct _GdkWaylandMonitor
|
||||
@@ -75,7 +75,7 @@ struct _GdkWaylandMonitor
|
||||
char * manufacturer;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GdkScreenWayland, _gdk_screen_wayland, GDK_TYPE_SCREEN)
|
||||
G_DEFINE_TYPE (GdkWaylandScreen, _gdk_wayland_screen, GDK_TYPE_SCREEN)
|
||||
|
||||
static void
|
||||
init_monitor_geometry (GdkWaylandMonitor *monitor,
|
||||
@@ -110,7 +110,7 @@ free_monitors (GdkWaylandMonitor *monitors,
|
||||
static void
|
||||
deinit_multihead (GdkScreen *screen)
|
||||
{
|
||||
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
|
||||
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
|
||||
|
||||
free_monitors (screen_wayland->monitors, screen_wayland->n_monitors);
|
||||
|
||||
@@ -121,7 +121,7 @@ deinit_multihead (GdkScreen *screen)
|
||||
static void
|
||||
init_multihead (GdkScreen *screen)
|
||||
{
|
||||
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
|
||||
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
|
||||
|
||||
/* No multihead support of any kind for this screen */
|
||||
screen_wayland->n_monitors = 1;
|
||||
@@ -135,18 +135,18 @@ init_multihead (GdkScreen *screen)
|
||||
static void
|
||||
gdk_wayland_screen_dispose (GObject *object)
|
||||
{
|
||||
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (object);
|
||||
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (object);
|
||||
|
||||
if (screen_wayland->root_window)
|
||||
_gdk_window_destroy (screen_wayland->root_window, TRUE);
|
||||
|
||||
G_OBJECT_CLASS (_gdk_screen_wayland_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (_gdk_wayland_screen_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_screen_finalize (GObject *object)
|
||||
{
|
||||
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (object);
|
||||
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (object);
|
||||
|
||||
if (screen_wayland->root_window)
|
||||
g_object_unref (screen_wayland->root_window);
|
||||
@@ -155,37 +155,37 @@ gdk_wayland_screen_finalize (GObject *object)
|
||||
|
||||
deinit_multihead (GDK_SCREEN (object));
|
||||
|
||||
G_OBJECT_CLASS (_gdk_screen_wayland_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (_gdk_wayland_screen_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static GdkDisplay *
|
||||
gdk_wayland_screen_get_display (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->display;
|
||||
return GDK_WAYLAND_SCREEN (screen)->display;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_wayland_screen_get_width (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->width;
|
||||
return GDK_WAYLAND_SCREEN (screen)->width;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_wayland_screen_get_height (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->height;
|
||||
return GDK_WAYLAND_SCREEN (screen)->height;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_wayland_screen_get_width_mm (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->width_mm;
|
||||
return GDK_WAYLAND_SCREEN (screen)->width_mm;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_wayland_screen_get_height_mm (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->height_mm;
|
||||
return GDK_WAYLAND_SCREEN (screen)->height_mm;
|
||||
}
|
||||
|
||||
static gint
|
||||
@@ -197,26 +197,26 @@ gdk_wayland_screen_get_number (GdkScreen *screen)
|
||||
static GdkWindow *
|
||||
gdk_wayland_screen_get_root_window (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->root_window;
|
||||
return GDK_WAYLAND_SCREEN (screen)->root_window;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_wayland_screen_get_n_monitors (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->n_monitors;
|
||||
return GDK_WAYLAND_SCREEN (screen)->n_monitors;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_wayland_screen_get_primary_monitor (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->primary_monitor;
|
||||
return GDK_WAYLAND_SCREEN (screen)->primary_monitor;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_wayland_screen_get_monitor_width_mm (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
|
||||
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
|
||||
|
||||
return screen_wayland->monitors[monitor_num].width_mm;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ static gint
|
||||
gdk_wayland_screen_get_monitor_height_mm (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
|
||||
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
|
||||
|
||||
return screen_wayland->monitors[monitor_num].height_mm;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ static gchar *
|
||||
gdk_wayland_screen_get_monitor_plug_name (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
|
||||
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
|
||||
|
||||
return g_strdup (screen_wayland->monitors[monitor_num].output_name);
|
||||
}
|
||||
@@ -244,7 +244,7 @@ gdk_wayland_screen_get_monitor_geometry (GdkScreen *screen,
|
||||
gint monitor_num,
|
||||
GdkRectangle *dest)
|
||||
{
|
||||
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
|
||||
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
|
||||
|
||||
if (dest)
|
||||
*dest = screen_wayland->monitors[monitor_num].geometry;
|
||||
@@ -253,13 +253,13 @@ gdk_wayland_screen_get_monitor_geometry (GdkScreen *screen,
|
||||
static GdkVisual *
|
||||
gdk_wayland_screen_get_system_visual (GdkScreen * screen)
|
||||
{
|
||||
return (GdkVisual *) GDK_SCREEN_WAYLAND (screen)->visual;
|
||||
return (GdkVisual *) GDK_WAYLAND_SCREEN (screen)->visual;
|
||||
}
|
||||
|
||||
static GdkVisual *
|
||||
gdk_wayland_screen_get_rgba_visual (GdkScreen *screen)
|
||||
{
|
||||
return (GdkVisual *) GDK_SCREEN_WAYLAND (screen)->visual;
|
||||
return (GdkVisual *) GDK_WAYLAND_SCREEN (screen)->visual;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -340,21 +340,21 @@ gdk_wayland_screen_visual_get_best_type (GdkScreen *screen)
|
||||
static GdkVisual*
|
||||
gdk_wayland_screen_visual_get_best (GdkScreen *screen)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->visual;
|
||||
return GDK_WAYLAND_SCREEN (screen)->visual;
|
||||
}
|
||||
|
||||
static GdkVisual*
|
||||
gdk_wayland_screen_visual_get_best_with_depth (GdkScreen *screen,
|
||||
gint depth)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->visual;
|
||||
return GDK_WAYLAND_SCREEN (screen)->visual;
|
||||
}
|
||||
|
||||
static GdkVisual*
|
||||
gdk_wayland_screen_visual_get_best_with_type (GdkScreen *screen,
|
||||
GdkVisualType visual_type)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->visual;
|
||||
return GDK_WAYLAND_SCREEN (screen)->visual;
|
||||
}
|
||||
|
||||
static GdkVisual*
|
||||
@@ -362,7 +362,7 @@ gdk_wayland_screen_visual_get_best_with_both (GdkScreen *screen,
|
||||
gint depth,
|
||||
GdkVisualType visual_type)
|
||||
{
|
||||
return GDK_SCREEN_WAYLAND (screen)->visual;
|
||||
return GDK_WAYLAND_SCREEN (screen)->visual;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -391,10 +391,10 @@ static GList *
|
||||
gdk_wayland_screen_list_visuals (GdkScreen *screen)
|
||||
{
|
||||
GList *list;
|
||||
GdkScreenWayland *screen_wayland;
|
||||
GdkWaylandScreen *screen_wayland;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
||||
screen_wayland = GDK_SCREEN_WAYLAND (screen);
|
||||
screen_wayland = GDK_WAYLAND_SCREEN (screen);
|
||||
|
||||
list = g_list_append (NULL, screen_wayland->visual);
|
||||
|
||||
@@ -421,11 +421,11 @@ GdkScreen *
|
||||
_gdk_wayland_screen_new (GdkDisplay *display)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GdkScreenWayland *screen_wayland;
|
||||
GdkWaylandScreen *screen_wayland;
|
||||
|
||||
screen = g_object_new (GDK_TYPE_SCREEN_WAYLAND, NULL);
|
||||
screen = g_object_new (GDK_TYPE_WAYLAND_SCREEN, NULL);
|
||||
|
||||
screen_wayland = GDK_SCREEN_WAYLAND (screen);
|
||||
screen_wayland = GDK_WAYLAND_SCREEN (screen);
|
||||
screen_wayland->display = display;
|
||||
screen_wayland->width = 8192;
|
||||
screen_wayland->height = 8192;
|
||||
@@ -443,7 +443,7 @@ _gdk_wayland_screen_new (GdkDisplay *display)
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_screen_wayland_class_init (GdkScreenWaylandClass *klass)
|
||||
_gdk_wayland_screen_class_init (GdkWaylandScreenClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkScreenClass *screen_class = GDK_SCREEN_CLASS (klass);
|
||||
@@ -485,6 +485,6 @@ _gdk_screen_wayland_class_init (GdkScreenWaylandClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_screen_wayland_init (GdkScreenWayland *screen_wayland)
|
||||
_gdk_wayland_screen_init (GdkWaylandScreen *screen_wayland)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,6 +29,16 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GdkWaylandDisplayManager GdkWaylandDisplayManager;
|
||||
typedef struct _GdkWaylandDisplayManagerClass GdkWaylandDisplayManagerClass;
|
||||
|
||||
#define GDK_TYPE_WAYLAND_DISPLAY_MANAGER (gdk_wayland_display_manager_get_type())
|
||||
#define GDK_WAYLAND_DISPLAY_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManager))
|
||||
#define GDK_WAYLAND_DISPLAY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManagerClass))
|
||||
#define GDK_IS_WAYLAND_DISPLAY_MANAGER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DISPLAY_MANAGER))
|
||||
#define GDK_IS_WAYLAND_DISPLAY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DISPLAY_MANAGER))
|
||||
#define GDK_WAYLAND_DISPLAY_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DISPLAY_MANAGER, GdkWaylandDisplayManagerClass))
|
||||
|
||||
GType gdk_wayland_display_manager_get_type (void);
|
||||
|
||||
#if defined (GTK_COMPILATION) || defined (GDK_COMPILATION)
|
||||
|
||||
+206
-62
@@ -33,6 +33,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <wayland-egl.h>
|
||||
|
||||
@@ -113,7 +115,6 @@ struct _GdkWindowImplWayland
|
||||
*/
|
||||
cairo_surface_t *server_surface;
|
||||
|
||||
GLuint texture;
|
||||
uint32_t resize_edges;
|
||||
|
||||
int focus_count;
|
||||
@@ -301,11 +302,16 @@ _gdk_wayland_display_create_window_impl (GdkDisplay *display,
|
||||
static const cairo_user_data_key_t gdk_wayland_cairo_key;
|
||||
|
||||
typedef struct _GdkWaylandCairoSurfaceData {
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
EGLImageKHR image;
|
||||
GLuint texture;
|
||||
struct wl_egl_pixmap *pixmap;
|
||||
#else
|
||||
gpointer buf;
|
||||
size_t buf_length;
|
||||
#endif
|
||||
struct wl_buffer *buffer;
|
||||
GdkDisplayWayland *display;
|
||||
GdkWaylandDisplay *display;
|
||||
int32_t width, height;
|
||||
} GdkWaylandCairoSurfaceData;
|
||||
|
||||
@@ -352,9 +358,6 @@ gdk_wayland_window_attach_image (GdkWindow *window)
|
||||
/* Get a Wayland buffer from this new surface */
|
||||
data = cairo_surface_get_user_data (impl->cairo_surface,
|
||||
&gdk_wayland_cairo_key);
|
||||
if (!data->buffer)
|
||||
data->buffer =
|
||||
wl_egl_pixmap_create_buffer(data->pixmap);
|
||||
|
||||
if (impl->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT)
|
||||
dx = server_width - data->width;
|
||||
@@ -370,23 +373,7 @@ gdk_wayland_window_attach_image (GdkWindow *window)
|
||||
wl_surface_attach (impl->surface, data->buffer, dx, dy);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_window_impl_wayland_finalize (GObject *object)
|
||||
{
|
||||
GdkWindowImplWayland *impl;
|
||||
|
||||
g_return_if_fail (GDK_IS_WINDOW_IMPL_WAYLAND (object));
|
||||
|
||||
impl = GDK_WINDOW_IMPL_WAYLAND (object);
|
||||
|
||||
if (impl->cursor)
|
||||
g_object_unref (impl->cursor);
|
||||
if (impl->server_surface)
|
||||
cairo_surface_destroy (impl->server_surface);
|
||||
|
||||
G_OBJECT_CLASS (_gdk_window_impl_wayland_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
#ifdef GDK_WAYLAND_USE_EGL
|
||||
static void
|
||||
gdk_wayland_cairo_surface_destroy (void *p)
|
||||
{
|
||||
@@ -402,11 +389,12 @@ gdk_wayland_cairo_surface_destroy (void *p)
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_wayland_create_cairo_surface (GdkDisplayWayland *display,
|
||||
gdk_wayland_create_cairo_surface (GdkWaylandDisplay *display,
|
||||
int width, int height)
|
||||
{
|
||||
GdkWaylandCairoSurfaceData *data;
|
||||
cairo_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
data = g_new (GdkWaylandCairoSurfaceData, 1);
|
||||
data->display = display;
|
||||
@@ -431,11 +419,122 @@ gdk_wayland_create_cairo_surface (GdkDisplayWayland *display,
|
||||
cairo_surface_set_user_data (surface, &gdk_wayland_cairo_key,
|
||||
data, gdk_wayland_cairo_surface_destroy);
|
||||
|
||||
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
|
||||
fprintf (stderr, "create gl surface failed\n");
|
||||
status = cairo_surface_status (surface);
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
g_critical (G_STRLOC ": Unable to create Cairo GL surface: %s",
|
||||
cairo_status_to_string (status));
|
||||
|
||||
}
|
||||
|
||||
if (!data->buffer)
|
||||
data->buffer =
|
||||
wl_egl_pixmap_create_buffer(data->pixmap);
|
||||
|
||||
return surface;
|
||||
}
|
||||
#else
|
||||
static struct wl_buffer *
|
||||
create_shm_buffer (struct wl_shm *shm,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t format,
|
||||
size_t *buf_length,
|
||||
void **data_out)
|
||||
{
|
||||
char filename[] = "/tmp/wayland-shm-XXXXXX";
|
||||
struct wl_buffer *buffer;
|
||||
int fd, size, stride;
|
||||
void *data;
|
||||
|
||||
fd = mkstemp (filename);
|
||||
if (fd < 0) {
|
||||
g_critical (G_STRLOC ": Unable to create temporary file (%s): %s",
|
||||
filename, g_strerror (errno));
|
||||
return NULL;
|
||||
}
|
||||
stride = width * 4;
|
||||
size = stride * height;
|
||||
if (ftruncate (fd, size) < 0) {
|
||||
g_critical (G_STRLOC ": Truncating temporary file failed: %s",
|
||||
g_strerror (errno));
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
unlink (filename);
|
||||
|
||||
if (data == MAP_FAILED) {
|
||||
g_critical (G_STRLOC ": mmap'ping temporary file failed: %s",
|
||||
g_strerror (errno));
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer = wl_shm_create_buffer (shm, fd,
|
||||
width, height,
|
||||
stride, format);
|
||||
|
||||
close (fd);
|
||||
|
||||
*data_out = data;
|
||||
*buf_length = size;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_cairo_surface_destroy (void *p)
|
||||
{
|
||||
GdkWaylandCairoSurfaceData *data = p;
|
||||
|
||||
if (data->buffer)
|
||||
wl_buffer_destroy (data->buffer);
|
||||
|
||||
munmap (data->buf, data->buf_length);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_wayland_create_cairo_surface (GdkWaylandDisplay *display,
|
||||
int width, int height)
|
||||
{
|
||||
GdkWaylandCairoSurfaceData *data;
|
||||
cairo_surface_t *surface = NULL;
|
||||
cairo_status_t status;
|
||||
|
||||
data = g_new (GdkWaylandCairoSurfaceData, 1);
|
||||
data->display = display;
|
||||
data->buffer = NULL;
|
||||
data->width = width;
|
||||
data->height = height;
|
||||
|
||||
data->buffer = create_shm_buffer (display->shm,
|
||||
width,
|
||||
height,
|
||||
WL_SHM_FORMAT_ARGB8888,
|
||||
&data->buf_length,
|
||||
&data->buf);
|
||||
|
||||
surface = cairo_image_surface_create_for_data (data->buf,
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
width,
|
||||
height,
|
||||
width * 4);
|
||||
|
||||
cairo_surface_set_user_data (surface, &gdk_wayland_cairo_key,
|
||||
data, gdk_wayland_cairo_surface_destroy);
|
||||
|
||||
status = cairo_surface_status (surface);
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
g_critical (G_STRLOC ": Unable to create Cairo image surface: %s",
|
||||
cairo_status_to_string (status));
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* On this first call this creates a double reference - the first reference
|
||||
* is held by the GdkWindowImplWayland struct - since unlike other backends
|
||||
@@ -446,8 +545,8 @@ static cairo_surface_t *
|
||||
gdk_wayland_window_ref_cairo_surface (GdkWindow *window)
|
||||
{
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
GdkDisplayWayland *display_wayland =
|
||||
GDK_DISPLAY_WAYLAND (gdk_window_get_display (impl->wrapper));
|
||||
GdkWaylandDisplay *display_wayland =
|
||||
GDK_WAYLAND_DISPLAY (gdk_window_get_display (impl->wrapper));
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (impl->wrapper))
|
||||
return NULL;
|
||||
@@ -465,6 +564,24 @@ gdk_wayland_window_ref_cairo_surface (GdkWindow *window)
|
||||
return impl->cairo_surface;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdk_window_impl_wayland_finalize (GObject *object)
|
||||
{
|
||||
GdkWindowImplWayland *impl;
|
||||
|
||||
g_return_if_fail (GDK_IS_WINDOW_IMPL_WAYLAND (object));
|
||||
|
||||
impl = GDK_WINDOW_IMPL_WAYLAND (object);
|
||||
|
||||
if (impl->cursor)
|
||||
g_object_unref (impl->cursor);
|
||||
if (impl->server_surface)
|
||||
cairo_surface_destroy (impl->server_surface);
|
||||
|
||||
G_OBJECT_CLASS (_gdk_window_impl_wayland_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_window_configure (GdkWindow *window,
|
||||
int width, int height, int edges)
|
||||
@@ -577,12 +694,12 @@ static void
|
||||
gdk_wayland_window_show (GdkWindow *window, gboolean already_mapped)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkDisplayWayland *display_wayland;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
GdkEvent *event;
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
display_wayland = GDK_DISPLAY_WAYLAND (display);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
if (impl->user_time != 0 &&
|
||||
display_wayland->user_time != 0 &&
|
||||
@@ -691,14 +808,17 @@ gdk_window_wayland_restack_toplevel (GdkWindow *window,
|
||||
|
||||
static void
|
||||
gdk_window_wayland_move_resize (GdkWindow *window,
|
||||
gboolean with_move,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
gboolean with_move,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
window->x = x;
|
||||
window->y = y;
|
||||
if (with_move)
|
||||
{
|
||||
window->x = x;
|
||||
window->y = y;
|
||||
}
|
||||
|
||||
/* If this function is called with width and height = -1 then that means
|
||||
* just move the window - don't update its size
|
||||
@@ -754,6 +874,32 @@ gdk_window_wayland_get_geometry (GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_wayland_window_offset (GdkWindow *window,
|
||||
gint *x_out,
|
||||
gint *y_out)
|
||||
{
|
||||
GdkWindowImplWayland *impl, *parent_impl;
|
||||
GdkWindow *parent_window;
|
||||
gint x_offset = 0, y_offset = 0;
|
||||
|
||||
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
|
||||
parent_window = impl->transient_for;
|
||||
while (parent_window)
|
||||
{
|
||||
parent_impl = GDK_WINDOW_IMPL_WAYLAND (parent_window->impl);
|
||||
|
||||
x_offset += window->x;
|
||||
y_offset += window->y;
|
||||
|
||||
parent_window = parent_impl->transient_for;
|
||||
}
|
||||
|
||||
*x_out = x_offset;
|
||||
*y_out = y_offset;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_window_wayland_get_root_coords (GdkWindow *window,
|
||||
gint x,
|
||||
@@ -761,11 +907,12 @@ gdk_window_wayland_get_root_coords (GdkWindow *window,
|
||||
gint *root_x,
|
||||
gint *root_y)
|
||||
{
|
||||
/* We can't do this. */
|
||||
if (root_x)
|
||||
*root_x = 0;
|
||||
if (root_y)
|
||||
*root_y = 0;
|
||||
gint x_offset, y_offset;
|
||||
|
||||
_gdk_wayland_window_offset (window, &x_offset, &y_offset);
|
||||
|
||||
*root_x = x_offset + x;
|
||||
*root_y = y_offset + y;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -833,21 +980,7 @@ gdk_wayland_window_translate (GdkWindow *window,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
|
||||
surface = gdk_wayland_window_ref_cairo_surface (window->impl_window);
|
||||
cr = cairo_create (surface);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
gdk_cairo_region (cr, area);
|
||||
cairo_clip (cr);
|
||||
cairo_set_source_surface (cr, cairo_get_target (cr), dx, dy);
|
||||
cairo_push_group (cr);
|
||||
cairo_paint (cr);
|
||||
cairo_pop_group_to_source (cr);
|
||||
cairo_paint (cr);
|
||||
cairo_destroy (cr);
|
||||
_gdk_window_invalidate_for_expose (window, area);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -866,9 +999,6 @@ gdk_wayland_window_destroy (GdkWindow *window,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
if (impl->texture)
|
||||
glDeleteTextures(1, &impl->texture);
|
||||
|
||||
if (!recursing && !foreign_destroy)
|
||||
{
|
||||
if (GDK_WINDOW_IMPL_WAYLAND (window->impl)->surface)
|
||||
@@ -1362,10 +1492,13 @@ gdk_wayland_window_destroy_notify (GdkWindow *window)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_window_process_updates_recurse (GdkWindow *window,
|
||||
cairo_region_t *region)
|
||||
gdk_wayland_window_process_updates_recurse (GdkWindow *window,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
#ifndef GDK_WAYLAND_USE_EGL
|
||||
GdkWaylandCairoSurfaceData *data = NULL;
|
||||
#endif
|
||||
cairo_rectangle_int_t rect;
|
||||
int i, n;
|
||||
|
||||
@@ -1374,12 +1507,23 @@ gdk_wayland_window_process_updates_recurse (GdkWindow *window,
|
||||
if (impl->cairo_surface)
|
||||
gdk_wayland_window_attach_image (window);
|
||||
|
||||
#ifndef GDK_WAYLAND_USE_EGL
|
||||
if (impl->server_surface)
|
||||
data = cairo_surface_get_user_data (impl->server_surface,
|
||||
&gdk_wayland_cairo_key);
|
||||
#endif
|
||||
|
||||
n = cairo_region_num_rectangles(region);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
#ifndef GDK_WAYLAND_USE_EGL
|
||||
if (data && data->buffer)
|
||||
wl_buffer_damage (data->buffer,
|
||||
rect.x, rect.y, rect.width, rect.height);
|
||||
#endif
|
||||
wl_surface_damage (impl->surface,
|
||||
rect.x, rect.y, rect.width, rect.height);
|
||||
rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
|
||||
_gdk_window_process_updates_recurse (window, region);
|
||||
|
||||
@@ -145,7 +145,7 @@ translate_key_event (GdkDisplay *display,
|
||||
gdk_event_set_device (event, device_manager->core_keyboard);
|
||||
|
||||
event->key.state = (GdkModifierType) xevent->xkey.state;
|
||||
event->key.group = _gdk_x11_get_group_for_state (display, xevent->xkey.state);
|
||||
event->key.group = gdk_x11_keymap_get_group_for_state (keymap, xevent->xkey.state);
|
||||
event->key.hardware_keycode = xevent->xkey.keycode;
|
||||
|
||||
event->key.keyval = GDK_KEY_VoidSymbol;
|
||||
@@ -161,7 +161,7 @@ translate_key_event (GdkDisplay *display,
|
||||
_gdk_x11_keymap_add_virt_mods (keymap, &state);
|
||||
event->key.state |= state;
|
||||
|
||||
event->key.is_modifier = _gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
|
||||
event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
|
||||
|
||||
_gdk_x11_event_translate_keyboard_string (&event->key);
|
||||
|
||||
|
||||
@@ -1062,7 +1062,7 @@ scroll_valuators_changed (GdkX11DeviceXI2 *device,
|
||||
gdouble *dx,
|
||||
gdouble *dy)
|
||||
{
|
||||
gdouble has_scroll_valuators = FALSE;
|
||||
gboolean has_scroll_valuators = FALSE;
|
||||
GdkScrollDirection direction;
|
||||
guint n_axes, i, n_val;
|
||||
gdouble *vals;
|
||||
@@ -1160,10 +1160,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
|
||||
event->key.time = xev->time;
|
||||
event->key.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
event->key.group = _gdk_x11_get_group_for_state (display, event->key.state);
|
||||
event->key.group = xev->group.effective;
|
||||
|
||||
event->key.hardware_keycode = xev->detail;
|
||||
event->key.is_modifier = _gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
|
||||
event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
|
||||
|
||||
device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->deviceid));
|
||||
@@ -1305,20 +1305,37 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
case XI_Motion:
|
||||
{
|
||||
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
|
||||
GdkDevice *source_device;
|
||||
GdkDevice *source_device, *device;
|
||||
gdouble delta_x, delta_y;
|
||||
|
||||
source_device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->sourceid));
|
||||
device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->deviceid));
|
||||
|
||||
if (scroll_valuators_changed (GDK_X11_DEVICE_XI2 (source_device),
|
||||
/* When scrolling, X might send events twice here; once with both the
|
||||
* device and the source device set to the physical device, and once
|
||||
* with the device set to the master device.
|
||||
* Since we are only interested in the latter, and
|
||||
* scroll_valuators_changed() updates the valuator cache for the
|
||||
* source device, we need to explicitly ignore the first event in
|
||||
* order to get the correct delta for the second.
|
||||
*/
|
||||
if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE &&
|
||||
scroll_valuators_changed (GDK_X11_DEVICE_XI2 (source_device),
|
||||
&xev->valuators, &delta_x, &delta_y))
|
||||
{
|
||||
event->scroll.type = GDK_SCROLL;
|
||||
event->scroll.direction = GDK_SCROLL_SMOOTH;
|
||||
|
||||
GDK_NOTE(EVENTS,
|
||||
g_message ("smooth scroll:\twindow %ld\n\tdeltas: %f %f",
|
||||
g_message ("smooth scroll: %s\n\tdevice: %u\n\tsource device: %u\n\twindow %ld\n\tdeltas: %f %f",
|
||||
#ifdef XINPUT_2_2
|
||||
(xev->flags & XIPointerEmulated) ? "emulated" : "",
|
||||
#else
|
||||
"",
|
||||
#endif
|
||||
xev->deviceid, xev->sourceid,
|
||||
xev->event, delta_x, delta_y));
|
||||
|
||||
|
||||
@@ -1331,9 +1348,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
event->scroll.delta_x = delta_x;
|
||||
event->scroll.delta_y = delta_y;
|
||||
|
||||
event->scroll.device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->deviceid));
|
||||
|
||||
event->scroll.device = device;
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
@@ -1348,9 +1363,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
event->motion.x_root = (gdouble) xev->root_x;
|
||||
event->motion.y_root = (gdouble) xev->root_y;
|
||||
|
||||
event->motion.device = g_hash_table_lookup (device_manager->id_table,
|
||||
GINT_TO_POINTER (xev->deviceid));
|
||||
|
||||
event->motion.device = device;
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
event->motion.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
|
||||
+42
-5
@@ -1429,11 +1429,30 @@ _gdk_x11_display_manager_keyval_convert_case (GdkDisplayManager *manager,
|
||||
*upper = xupper;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_x11_keymap_get_group_for_state:
|
||||
* @keymap: a #GdkX11Keymap
|
||||
* @state: raw state returned from X
|
||||
*
|
||||
* Extracts the group from the state field sent in an X Key event.
|
||||
* This is only needed for code processing raw X events, since #GdkEventKey
|
||||
* directly includes an is_modifier field.
|
||||
*
|
||||
* Returns: the index of the active keyboard group for the event
|
||||
*
|
||||
* Since: 3.6
|
||||
*/
|
||||
gint
|
||||
_gdk_x11_get_group_for_state (GdkDisplay *display,
|
||||
GdkModifierType state)
|
||||
gdk_x11_keymap_get_group_for_state (GdkKeymap *keymap,
|
||||
guint state)
|
||||
{
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
|
||||
GdkDisplay *display;
|
||||
GdkX11Display *display_x11;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_X11_KEYMAP (keymap), 0);
|
||||
|
||||
display = keymap->display;
|
||||
display_x11 = GDK_X11_DISPLAY (display);
|
||||
|
||||
#ifdef HAVE_XKB
|
||||
if (display_x11->use_xkb)
|
||||
@@ -1498,13 +1517,31 @@ gdk_x11_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_x11_keymap_key_is_modifier:
|
||||
* @keymap: a #GdkX11Keymap
|
||||
* @keycode: the hardware keycode from a key event
|
||||
*
|
||||
* Determines whether a particular key code represents a key that
|
||||
* is a modifier. That is, it's a key that normally just affects
|
||||
* the keyboard state and the behavior of other keys rather than
|
||||
* producing a direct effect itself. This is only needed for code
|
||||
* processing raw X events, since #GdkEventKey directly includes
|
||||
* an is_modifier field.
|
||||
*
|
||||
* Returns: %TRUE if the hardware keycode is a modifier key
|
||||
*
|
||||
* Since: 3.6
|
||||
*/
|
||||
gboolean
|
||||
_gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
|
||||
guint keycode)
|
||||
gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
|
||||
guint keycode)
|
||||
{
|
||||
GdkX11Keymap *keymap_x11 = GDK_X11_KEYMAP (keymap);
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_X11_KEYMAP (keymap), FALSE);
|
||||
|
||||
update_keyrange (keymap_x11);
|
||||
if (keycode < keymap_x11->min_keycode ||
|
||||
keycode > keymap_x11->max_keycode)
|
||||
|
||||
@@ -155,12 +155,8 @@ gboolean _gdk_x11_moveresize_configure_done (GdkDisplay *display,
|
||||
void _gdk_x11_keymap_state_changed (GdkDisplay *display,
|
||||
XEvent *event);
|
||||
void _gdk_x11_keymap_keys_changed (GdkDisplay *display);
|
||||
gint _gdk_x11_get_group_for_state (GdkDisplay *display,
|
||||
GdkModifierType state);
|
||||
void _gdk_x11_keymap_add_virt_mods (GdkKeymap *keymap,
|
||||
GdkModifierType *modifiers);
|
||||
gboolean _gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
|
||||
guint keycode);
|
||||
|
||||
void _gdk_x11_windowing_init (void);
|
||||
|
||||
|
||||
@@ -81,7 +81,9 @@ static const char gdk_settings_names[] =
|
||||
"Gtk/AutoMnemonics\0" "gtk-auto-mnemonics\0"
|
||||
"Gtk/VisibleFocus\0" "gtk-visible-focus\0"
|
||||
"Gtk/ShellShowsAppMenu\0" "gtk-shell-shows-app-menu\0"
|
||||
"Gtk/ShellShowsMenubar\0" "gtk-shell-shows-menubar\0";
|
||||
"Gtk/ShellShowsMenubar\0" "gtk-shell-shows-menubar\0"
|
||||
"Gtk/EnablePrimaryPaste\0" "gtk-enable-primary-paste\0";
|
||||
|
||||
|
||||
|
||||
static const struct
|
||||
@@ -137,5 +139,6 @@ static const struct
|
||||
{ 1730, 1748 },
|
||||
{ 1767, 1784 },
|
||||
{ 1802, 1824 },
|
||||
{ 1849, 1871 }
|
||||
{ 1849, 1871 },
|
||||
{ 1895, 1918 }
|
||||
};
|
||||
|
||||
@@ -42,6 +42,13 @@ typedef struct _GdkX11KeymapClass GdkX11KeymapClass;
|
||||
|
||||
GType gdk_x11_keymap_get_type (void);
|
||||
|
||||
GDK_AVAILABLE_IN_3_6
|
||||
gint gdk_x11_keymap_get_group_for_state (GdkKeymap *keymap,
|
||||
guint state);
|
||||
|
||||
GDK_AVAILABLE_IN_3_6
|
||||
gboolean gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
|
||||
guint keycode);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_X11_KEYMAP_H__ */
|
||||
|
||||
+75
-19
@@ -267,6 +267,7 @@ gtk_public_h_sources = \
|
||||
gtklayout.h \
|
||||
gtklinkbutton.h \
|
||||
gtkliststore.h \
|
||||
gtklistview.h \
|
||||
gtklockbutton.h \
|
||||
gtkmain.h \
|
||||
gtkmenu.h \
|
||||
@@ -405,7 +406,6 @@ gtk_private_h_sources = \
|
||||
gtkaccelgroupprivate.h \
|
||||
gtkaccelmapprivate.h \
|
||||
gtkallocatedbitmaskprivate.h \
|
||||
gtkanimationdescription.h \
|
||||
gtkappchooserprivate.h \
|
||||
gtkappchoosermodule.h \
|
||||
gtkappchooseronline.h \
|
||||
@@ -423,21 +423,43 @@ gtk_private_h_sources = \
|
||||
gtkcolorscaleprivate.h \
|
||||
gtkcolorchooserprivate.h \
|
||||
gtkcontainerprivate.h \
|
||||
gtkcssanimatedvaluesprivate.h \
|
||||
gtkcssarrayvalueprivate.h \
|
||||
gtkcssbgsizevalueprivate.h \
|
||||
gtkcssbordervalueprivate.h \
|
||||
gtkcsscomputedvaluesprivate.h \
|
||||
gtkcsscornervalueprivate.h \
|
||||
gtkcsscustompropertyprivate.h \
|
||||
gtkcsseasevalueprivate.h \
|
||||
gtkcssenginevalueprivate.h \
|
||||
gtkcssenumvalueprivate.h \
|
||||
gtkcssimagecrossfadeprivate.h \
|
||||
gtkcssimagegradientprivate.h \
|
||||
gtkcssimagelinearprivate.h \
|
||||
gtkcssimageprivate.h \
|
||||
gtkcssimageurlprivate.h \
|
||||
gtkcssimagevalueprivate.h \
|
||||
gtkcssimagewin32private.h \
|
||||
gtkcssinheritvalueprivate.h \
|
||||
gtkcssinitialvalueprivate.h \
|
||||
gtkcsslookupprivate.h \
|
||||
gtkcssmatcherprivate.h \
|
||||
gtkcssnumbervalueprivate.h \
|
||||
gtkcssparserprivate.h \
|
||||
gtkcsspositionvalueprivate.h \
|
||||
gtkcssproviderprivate.h \
|
||||
gtkcssrepeatvalueprivate.h \
|
||||
gtkcssrgbavalueprivate.h \
|
||||
gtkcsssectionprivate.h \
|
||||
gtkcssselectorprivate.h \
|
||||
gtkcssshadowsvalueprivate.h \
|
||||
gtkcssshadowvalueprivate.h \
|
||||
gtkcssshorthandpropertyprivate.h \
|
||||
gtkcssstringvalueprivate.h \
|
||||
gtkcssstylefuncsprivate.h \
|
||||
gtkcssstylepropertyprivate.h \
|
||||
gtkcsstransitionprivate.h \
|
||||
gtkcsstypedvalueprivate.h \
|
||||
gtkcssvalueprivate.h \
|
||||
gtkcustompaperunixdialog.h \
|
||||
gtkentryprivate.h \
|
||||
@@ -487,9 +509,10 @@ gtk_private_h_sources = \
|
||||
gtksearchenginesimple.h \
|
||||
gtkselectionprivate.h \
|
||||
gtksettingsprivate.h \
|
||||
gtkshadowprivate.h \
|
||||
gtksizegroup-private.h \
|
||||
gtksocketprivate.h \
|
||||
gtkstyleanimationprivate.h \
|
||||
gtkstylecascadeprivate.h \
|
||||
gtkstylecontextprivate.h \
|
||||
gtkstylepropertiesprivate.h \
|
||||
gtkstylepropertyprivate.h \
|
||||
@@ -506,7 +529,6 @@ gtk_private_h_sources = \
|
||||
gtktextutil.h \
|
||||
gtkthemingbackgroundprivate.h \
|
||||
gtkthemingengineprivate.h \
|
||||
gtktimeline.h \
|
||||
gtktoolpaletteprivate.h \
|
||||
gtktreedatalist.h \
|
||||
gtktreeprivate.h \
|
||||
@@ -572,7 +594,6 @@ gtk_base_c_sources = \
|
||||
gtkappchooseronline.c \
|
||||
gtkapplication.c \
|
||||
gtkapplicationwindow.c \
|
||||
gtkanimationdescription.c \
|
||||
gtkarrow.c \
|
||||
gtkaspectframe.c \
|
||||
gtkassistant.c \
|
||||
@@ -618,23 +639,45 @@ gtk_base_c_sources = \
|
||||
gtkcombobox.c \
|
||||
gtkcomboboxtext.c \
|
||||
gtkcontainer.c \
|
||||
gtkcssanimatedvalues.c \
|
||||
gtkcssarrayvalue.c \
|
||||
gtkcssbgsizevalue.c \
|
||||
gtkcssbordervalue.c \
|
||||
gtkcsscomputedvalues.c \
|
||||
gtkcsscornervalue.c \
|
||||
gtkcsscustomproperty.c \
|
||||
gtkcsseasevalue.c \
|
||||
gtkcssenumvalue.c \
|
||||
gtkcssenginevalue.c \
|
||||
gtkcssimage.c \
|
||||
gtkcssimagecrossfade.c \
|
||||
gtkcssimagegradient.c \
|
||||
gtkcssimagelinear.c \
|
||||
gtkcssimageurl.c \
|
||||
gtkcssimagevalue.c \
|
||||
gtkcssimagewin32.c \
|
||||
gtkcssinheritvalue.c \
|
||||
gtkcssinitialvalue.c \
|
||||
gtkcsslookup.c \
|
||||
gtkcssmatcher.c \
|
||||
gtkcssnumbervalue.c \
|
||||
gtkcssparser.c \
|
||||
gtkcsspositionvalue.c \
|
||||
gtkcssprovider.c \
|
||||
gtkcssrepeatvalue.c \
|
||||
gtkcssrgbavalue.c \
|
||||
gtkcsssection.c \
|
||||
gtkcssselector.c \
|
||||
gtkcssstringvalue.c \
|
||||
gtkcssshadowsvalue.c \
|
||||
gtkcssshadowvalue.c \
|
||||
gtkcssshorthandproperty.c \
|
||||
gtkcssshorthandpropertyimpl.c \
|
||||
gtkcssstylefuncs.c \
|
||||
gtkcssstyleproperty.c \
|
||||
gtkcssstylepropertyimpl.c \
|
||||
gtkcsstransition.c \
|
||||
gtkcsstypedvalue.c \
|
||||
gtkcssvalue.c \
|
||||
gtkcsstypes.c \
|
||||
gtkdialog.c \
|
||||
@@ -684,6 +727,7 @@ gtk_base_c_sources = \
|
||||
gtklayout.c \
|
||||
gtklinkbutton.c \
|
||||
gtkliststore.c \
|
||||
gtklistview.c \
|
||||
gtklockbutton.c \
|
||||
gtkmain.c \
|
||||
gtkmarshalers.c \
|
||||
@@ -748,13 +792,14 @@ gtk_base_c_sources = \
|
||||
gtksettings.c \
|
||||
gtksizegroup.c \
|
||||
gtksizerequest.c \
|
||||
gtkshadow.c \
|
||||
gtkshow.c \
|
||||
gtkspinbutton.c \
|
||||
gtkspinner.c \
|
||||
gtkstatusbar.c \
|
||||
gtkstatusicon.c \
|
||||
gtkstock.c \
|
||||
gtkstyleanimation.c \
|
||||
gtkstylecascade.c \
|
||||
gtkstylecontext.c \
|
||||
gtkstyleproperties.c \
|
||||
gtkstyleproperty.c \
|
||||
@@ -781,7 +826,6 @@ gtk_base_c_sources = \
|
||||
gtktextview.c \
|
||||
gtkthemingbackground.c \
|
||||
gtkthemingengine.c \
|
||||
gtktimeline.c \
|
||||
gtktoggleaction.c \
|
||||
gtktogglebutton.c \
|
||||
gtktoggletoolbutton.c \
|
||||
@@ -865,34 +909,46 @@ gtk_use_win32_c_sources = \
|
||||
gtk_use_quartz_c_sources = \
|
||||
gtksearchenginequartz.c \
|
||||
gtkmountoperation-stub.c \
|
||||
gtkquartz-menu.h \
|
||||
gtkquartz-menu.c \
|
||||
gtkmodelmenu-quartz.c \
|
||||
gtkquartz.c
|
||||
gtk_use_stub_c_sources = \
|
||||
gtkmountoperation-stub.c
|
||||
gtk_all_c_sources += $(gtk_use_x11_c_sources) $(gtk_use_win32_c_sources) $(gtk_use_quartz_c_sources) $(gtk_use_stub_c_sources)
|
||||
if USE_X11
|
||||
gtk_private_h_sources += \
|
||||
gtk_use_x11_private_h_sources = \
|
||||
gtkxembed.h \
|
||||
gtktrayicon.h \
|
||||
xembed.h
|
||||
if USE_X11
|
||||
gtk_c_sources += $(gtk_use_x11_c_sources)
|
||||
else
|
||||
if USE_WIN32
|
||||
gtk_private_h_sources += \
|
||||
gtk_private_h_sources += $(gtk_use_x11_private_h_sources)
|
||||
endif
|
||||
|
||||
gtk_use_win32_private_h_sources = \
|
||||
gtkwin32embed.h \
|
||||
gtkwin32embedwidget.h
|
||||
if USE_WIN32
|
||||
gtk_c_sources += $(gtk_use_win32_c_sources)
|
||||
else
|
||||
if USE_QUARTZ
|
||||
gtk_private_h_sources += \
|
||||
gtk_private_h_sources += $(gtk_use_win32_private_h_sources)
|
||||
endif
|
||||
|
||||
gtk_use_quartz_private_h_sources = \
|
||||
gtksearchenginequartz.h \
|
||||
gtkmenuquartz.h \
|
||||
gtkmodelmenu-quartz.h \
|
||||
gtkquartz.h
|
||||
if USE_QUARTZ
|
||||
gtk_c_sources += $(gtk_use_quartz_c_sources)
|
||||
libgtk_3_la_CFLAGS = "-xobjective-c"
|
||||
gtk_private_h_sources += $(gtk_use_quartz_private_h_sources)
|
||||
endif
|
||||
|
||||
else
|
||||
gtk_all_private_h_sources = \
|
||||
$(gtk_use_x11_private_h_sources) \
|
||||
$(gtk_use_win32_private_h_sources) \
|
||||
$(gtk_use_quartz_private_h_sources)
|
||||
|
||||
if !USE_X11
|
||||
if !USE_WIN32
|
||||
if !USE_QUARTZ
|
||||
gtk_c_sources += $(gtk_use_stub_c_sources)
|
||||
endif
|
||||
endif
|
||||
@@ -976,7 +1032,7 @@ MAINTAINERCLEANFILES = \
|
||||
stock-icons/icon-theme.cache
|
||||
|
||||
EXTRA_HEADERS =
|
||||
EXTRA_DIST += $(gtk_private_h_sources) $(gtk_extra_sources)
|
||||
EXTRA_DIST += $(gtk_all_private_h_sources) $(gtk_extra_sources)
|
||||
EXTRA_DIST += $(gtk_built_sources)
|
||||
EXTRA_DIST += $(STOCK_ICONS)
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ get_pixbuf_box (GtkIconView *icon_view,
|
||||
_gtk_icon_view_set_cell_data (icon_view, item);
|
||||
gtk_cell_area_foreach_alloc (icon_view->priv->cell_area, context,
|
||||
GTK_WIDGET (icon_view),
|
||||
(GdkRectangle *)item, (GdkRectangle *)item,
|
||||
&item->cell_area, &item->cell_area,
|
||||
(GtkCellAllocCallback)get_pixbuf_foreach, &data);
|
||||
|
||||
return data.pixbuf_found;
|
||||
|
||||
@@ -610,7 +610,9 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
|
||||
*
|
||||
* Creates a new #GtkFontSelection.
|
||||
*
|
||||
* Return value: a n ew #GtkFontSelection
|
||||
* Return value: a new #GtkFontSelection
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserWidget instead
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_selection_new (void)
|
||||
|
||||
+12
-1
@@ -53,4 +53,15 @@ rint (double x)
|
||||
return ceil (x - 0.5);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_NEARBYINT
|
||||
/* Workaround for nearbyint() for non-GCC/non-C99 compilers */
|
||||
/* This is quite similar to rint() in most respects */
|
||||
|
||||
static inline double
|
||||
nearbyint (double x)
|
||||
{
|
||||
return floor (x + 0.5);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -36,10 +36,6 @@ GtkTreeView.view.expander:selected:hover {
|
||||
color: @text_color;
|
||||
}
|
||||
|
||||
.expander:active {
|
||||
transition: 200ms linear;
|
||||
}
|
||||
|
||||
*:insensitive {
|
||||
border-color: shade (@bg_color, 0.7);
|
||||
background-color: shade (@bg_color, 0.9);
|
||||
@@ -295,10 +291,6 @@ GtkLabel:selected:focused {
|
||||
background-color: @selected_bg_color;
|
||||
}
|
||||
|
||||
.spinner:active {
|
||||
transition: 750ms linear loop;
|
||||
}
|
||||
|
||||
.info {
|
||||
background-color: @info_bg_color;
|
||||
color: @info_fg_color;
|
||||
|
||||
@@ -77,10 +77,6 @@ GtkFrame {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.spinner:active {
|
||||
transition: 750ms linear loop;
|
||||
}
|
||||
|
||||
.notebook > GtkScrolledWindow.frame {
|
||||
border-style: none;
|
||||
}
|
||||
@@ -837,4 +833,4 @@ GtkStatusbar > GtkFrame {
|
||||
background-color: transparent;
|
||||
background-image: -gtk-win32-theme-part(status, 3 1);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
#include <gtk/gtklayout.h>
|
||||
#include <gtk/gtklinkbutton.h>
|
||||
#include <gtk/gtkliststore.h>
|
||||
#include <gtk/gtklistview.h>
|
||||
#include <gtk/gtklockbutton.h>
|
||||
#include <gtk/gtkmain.h>
|
||||
#include <gtk/gtkmenu.h>
|
||||
|
||||
@@ -231,6 +231,7 @@ gtk_application_get_app_menu
|
||||
gtk_application_get_menubar
|
||||
gtk_application_get_type
|
||||
gtk_application_get_windows
|
||||
gtk_application_get_window_by_id
|
||||
gtk_application_inhibit
|
||||
gtk_application_inhibit_flags_get_type
|
||||
gtk_application_is_inhibited
|
||||
@@ -242,6 +243,7 @@ gtk_application_set_menubar
|
||||
gtk_application_uninhibit
|
||||
gtk_application_window_get_show_menubar
|
||||
gtk_application_window_get_type
|
||||
gtk_application_window_get_id
|
||||
gtk_application_window_new
|
||||
gtk_application_window_set_show_menubar
|
||||
gtk_arrow_get_type
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkanimationdescription.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
struct GtkAnimationDescription
|
||||
{
|
||||
GtkTimelineProgressType progress_type;
|
||||
gdouble duration;
|
||||
guint loop : 1;
|
||||
guint ref_count;
|
||||
};
|
||||
|
||||
GtkAnimationDescription *
|
||||
_gtk_animation_description_new (gdouble duration,
|
||||
GtkTimelineProgressType progress_type,
|
||||
gboolean loop)
|
||||
{
|
||||
GtkAnimationDescription *desc;
|
||||
|
||||
desc = g_slice_new (GtkAnimationDescription);
|
||||
desc->duration = duration;
|
||||
desc->progress_type = progress_type;
|
||||
desc->loop = loop;
|
||||
desc->ref_count = 1;
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
gdouble
|
||||
_gtk_animation_description_get_duration (GtkAnimationDescription *desc)
|
||||
{
|
||||
return desc->duration;
|
||||
}
|
||||
|
||||
GtkTimelineProgressType
|
||||
_gtk_animation_description_get_progress_type (GtkAnimationDescription *desc)
|
||||
{
|
||||
return desc->progress_type;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_animation_description_get_loop (GtkAnimationDescription *desc)
|
||||
{
|
||||
return (desc->loop != 0);
|
||||
}
|
||||
|
||||
GtkAnimationDescription *
|
||||
_gtk_animation_description_ref (GtkAnimationDescription *desc)
|
||||
{
|
||||
desc->ref_count++;
|
||||
return desc;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_animation_description_unref (GtkAnimationDescription *desc)
|
||||
{
|
||||
desc->ref_count--;
|
||||
|
||||
if (desc->ref_count == 0)
|
||||
g_slice_free (GtkAnimationDescription, desc);
|
||||
}
|
||||
|
||||
GtkAnimationDescription *
|
||||
_gtk_animation_description_from_string (const gchar *str)
|
||||
{
|
||||
gchar timing_function[16] = { 0, };
|
||||
gchar duration_unit[3] = { 0, };
|
||||
gchar loop_str[5] = { 0, };
|
||||
GtkTimelineProgressType progress_type;
|
||||
guint duration = 0;
|
||||
gboolean loop;
|
||||
|
||||
if (sscanf (str, "%d%2s %15s %5s", &duration, duration_unit, timing_function, loop_str) == 4)
|
||||
loop = TRUE;
|
||||
else if (sscanf (str, "%d%2s %15s", &duration, duration_unit, timing_function) == 3)
|
||||
loop = FALSE;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
if (strcmp (duration_unit, "s") == 0)
|
||||
duration *= 1000;
|
||||
else if (strcmp (duration_unit, "ms") != 0)
|
||||
{
|
||||
g_warning ("Unknown duration unit: %s\n", duration_unit);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp (timing_function, "linear") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_LINEAR;
|
||||
else if (strcmp (timing_function, "ease") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_EASE;
|
||||
else if (strcmp (timing_function, "ease-in") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_EASE_IN;
|
||||
else if (strcmp (timing_function, "ease-out") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_EASE_OUT;
|
||||
else if (strcmp (timing_function, "ease-in-out") == 0)
|
||||
progress_type = GTK_TIMELINE_PROGRESS_EASE_IN_OUT;
|
||||
else
|
||||
{
|
||||
g_warning ("Unknown timing function: %s\n", timing_function);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _gtk_animation_description_new ((gdouble) duration, progress_type, loop);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_animation_description_print (GtkAnimationDescription *desc,
|
||||
GString *str)
|
||||
{
|
||||
int duration;
|
||||
|
||||
g_return_if_fail (desc != NULL);
|
||||
g_return_if_fail (str != NULL);
|
||||
|
||||
duration = desc->duration;
|
||||
if (duration % 1000 == 0)
|
||||
g_string_append_printf (str, "%ds", (int) desc->duration / 1000);
|
||||
else
|
||||
g_string_append_printf (str, "%dms", (int) desc->duration);
|
||||
|
||||
switch (desc->progress_type)
|
||||
{
|
||||
case GTK_TIMELINE_PROGRESS_LINEAR:
|
||||
g_string_append (str, " linear");
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE:
|
||||
g_string_append (str, " ease");
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_IN:
|
||||
g_string_append (str, " ease-in");
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_OUT:
|
||||
g_string_append (str, " ease-out");
|
||||
break;
|
||||
case GTK_TIMELINE_PROGRESS_EASE_IN_OUT:
|
||||
g_string_append (str, " ease-in-out");
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (desc->loop)
|
||||
g_string_append (str, " loop");
|
||||
}
|
||||
|
||||
GType
|
||||
_gtk_animation_description_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (!type))
|
||||
type = g_boxed_type_register_static (I_("GtkAnimationDescription"),
|
||||
(GBoxedCopyFunc) _gtk_animation_description_ref,
|
||||
(GBoxedFreeFunc) _gtk_animation_description_unref);
|
||||
|
||||
return type;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_ANIMATION_DESCRIPTION_H__
|
||||
#define __GTK_ANIMATION_DESCRIPTION_H__
|
||||
|
||||
#include "gtktimeline.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Dummy typedefs */
|
||||
typedef struct GtkAnimationDescription GtkAnimationDescription;
|
||||
|
||||
#define GTK_TYPE_ANIMATION_DESCRIPTION (_gtk_animation_description_get_type ())
|
||||
|
||||
GType _gtk_animation_description_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkAnimationDescription * _gtk_animation_description_new (gdouble duration,
|
||||
GtkTimelineProgressType progress_type,
|
||||
gboolean loop);
|
||||
|
||||
gdouble _gtk_animation_description_get_duration (GtkAnimationDescription *desc);
|
||||
GtkTimelineProgressType _gtk_animation_description_get_progress_type (GtkAnimationDescription *desc);
|
||||
gboolean _gtk_animation_description_get_loop (GtkAnimationDescription *desc);
|
||||
|
||||
GtkAnimationDescription * _gtk_animation_description_ref (GtkAnimationDescription *desc);
|
||||
void _gtk_animation_description_unref (GtkAnimationDescription *desc);
|
||||
|
||||
GtkAnimationDescription * _gtk_animation_description_from_string (const gchar *str);
|
||||
void _gtk_animation_description_print (GtkAnimationDescription *desc,
|
||||
GString *string);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ANIMATION_DESCRIPTION_H__ */
|
||||
+55
-40
@@ -37,7 +37,7 @@
|
||||
#include "gtkintl.h"
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include "gtkquartz-menu.h"
|
||||
#include "gtkmodelmenu-quartz.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#include "gtkmessagedialog.h"
|
||||
@@ -149,7 +149,7 @@ struct _GtkApplicationPrivate
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GDBusConnection *session_bus;
|
||||
const gchar *application_id;
|
||||
gchar *object_path;
|
||||
const gchar *object_path;
|
||||
|
||||
gchar *app_menu_path;
|
||||
guint app_menu_id;
|
||||
@@ -185,6 +185,9 @@ gtk_application_x11_publish_menu (GtkApplication *application,
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (application->priv->session_bus == NULL)
|
||||
return;
|
||||
|
||||
/* unexport any existing menu */
|
||||
if (*id)
|
||||
{
|
||||
@@ -252,8 +255,8 @@ gtk_application_window_added_x11 (GtkApplication *application,
|
||||
guint window_id;
|
||||
|
||||
window_id = application->priv->next_id++;
|
||||
window_path = g_strdup_printf ("%s/window/%d", application->priv->object_path, window_id);
|
||||
success = gtk_application_window_publish (app_window, application->priv->session_bus, window_path);
|
||||
window_path = g_strdup_printf ("%s/window/%u", application->priv->object_path, window_id);
|
||||
success = gtk_application_window_publish (app_window, application->priv->session_bus, window_path, window_id);
|
||||
g_free (window_path);
|
||||
}
|
||||
while (!success);
|
||||
@@ -271,34 +274,13 @@ gtk_application_window_removed_x11 (GtkApplication *application,
|
||||
gtk_application_window_unpublish (GTK_APPLICATION_WINDOW (window));
|
||||
}
|
||||
|
||||
static gchar *
|
||||
object_path_from_appid (const gchar *appid)
|
||||
{
|
||||
gchar *appid_path, *iter;
|
||||
|
||||
appid_path = g_strconcat ("/", appid, NULL);
|
||||
for (iter = appid_path; *iter; iter++)
|
||||
{
|
||||
if (*iter == '.')
|
||||
*iter = '/';
|
||||
|
||||
if (*iter == '-')
|
||||
*iter = '_';
|
||||
}
|
||||
|
||||
return appid_path;
|
||||
}
|
||||
|
||||
static void gtk_application_startup_session_dbus (GtkApplication *app);
|
||||
|
||||
static void
|
||||
gtk_application_startup_x11 (GtkApplication *application)
|
||||
{
|
||||
const gchar *application_id;
|
||||
|
||||
application_id = g_application_get_application_id (G_APPLICATION (application));
|
||||
application->priv->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
||||
application->priv->object_path = object_path_from_appid (application_id);
|
||||
application->priv->session_bus = g_application_get_dbus_connection (G_APPLICATION (application));
|
||||
application->priv->object_path = g_application_get_dbus_object_path (G_APPLICATION (application));
|
||||
|
||||
gtk_application_startup_session_dbus (GTK_APPLICATION (application));
|
||||
}
|
||||
@@ -306,9 +288,8 @@ gtk_application_startup_x11 (GtkApplication *application)
|
||||
static void
|
||||
gtk_application_shutdown_x11 (GtkApplication *application)
|
||||
{
|
||||
g_free (application->priv->object_path);
|
||||
application->priv->session_bus = NULL;
|
||||
application->priv->object_path = NULL;
|
||||
g_clear_object (&application->priv->session_bus);
|
||||
|
||||
g_clear_object (&application->priv->sm_proxy);
|
||||
g_clear_object (&application->priv->client_proxy);
|
||||
@@ -316,12 +297,6 @@ gtk_application_shutdown_x11 (GtkApplication *application)
|
||||
g_free (application->priv->client_path);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gtk_application_get_dbus_object_path (GtkApplication *application)
|
||||
{
|
||||
return application->priv->object_path;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gtk_application_get_app_menu_object_path (GtkApplication *application)
|
||||
{
|
||||
@@ -526,6 +501,10 @@ gtk_application_init (GtkApplication *application)
|
||||
application->priv = G_TYPE_INSTANCE_GET_PRIVATE (application,
|
||||
GTK_TYPE_APPLICATION,
|
||||
GtkApplicationPrivate);
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
application->priv->next_id = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -820,7 +799,7 @@ gtk_application_new (const gchar *application_id,
|
||||
* @application: a #GtkApplication
|
||||
* @window: a #GtkWindow
|
||||
*
|
||||
* Adds a window from @application.
|
||||
* Adds a window to @application.
|
||||
*
|
||||
* This call is equivalent to setting the #GtkWindow:application
|
||||
* property of @window to @application.
|
||||
@@ -898,6 +877,34 @@ gtk_application_get_windows (GtkApplication *application)
|
||||
return application->priv->windows;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_get_window_by_id:
|
||||
* @application: a #GtkApplication
|
||||
* @id: an identifier number
|
||||
*
|
||||
* Returns: (transfer none): the #GtkApplicationWindow with ID @id, or
|
||||
* %NULL if there is no window with this ID
|
||||
*
|
||||
* Since: 3.6
|
||||
*/
|
||||
GtkWindow *
|
||||
gtk_application_get_window_by_id (GtkApplication *application,
|
||||
guint id)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
|
||||
|
||||
for (l = application->priv->windows; l != NULL; l = l->next)
|
||||
{
|
||||
if (GTK_IS_APPLICATION_WINDOW (l->data) &&
|
||||
gtk_application_window_get_id (GTK_APPLICATION_WINDOW (l->data)) == id)
|
||||
return l->data;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_add_accelerator:
|
||||
* @application: a #GtkApplication
|
||||
@@ -999,6 +1006,10 @@ gtk_application_remove_accelerator (GtkApplication *application,
|
||||
*
|
||||
* Sets or unsets the application menu for @application.
|
||||
*
|
||||
* This can only be done in the primary instance of the application,
|
||||
* after it has been registered. #GApplication:startup is a good place
|
||||
* to call this.
|
||||
*
|
||||
* The application menu is a single menu containing items that typically
|
||||
* impact the application as a whole, rather than acting on a specific
|
||||
* window or document. For example, you would expect to see
|
||||
@@ -1008,8 +1019,6 @@ gtk_application_remove_accelerator (GtkApplication *application,
|
||||
* If supported, the application menu will be rendered by the desktop
|
||||
* environment.
|
||||
*
|
||||
* You might call this method in your #GApplication:startup signal handler.
|
||||
*
|
||||
* Use the base #GActionMap interface to add actions, to respond to the user
|
||||
* selecting these menu items.
|
||||
*
|
||||
@@ -1020,6 +1029,8 @@ gtk_application_set_app_menu (GtkApplication *application,
|
||||
GMenuModel *app_menu)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_APPLICATION (application));
|
||||
g_return_if_fail (g_application_get_is_registered (G_APPLICATION (application)));
|
||||
g_return_if_fail (!g_application_get_is_remote (G_APPLICATION (application)));
|
||||
|
||||
if (app_menu != application->priv->app_menu)
|
||||
{
|
||||
@@ -1069,6 +1080,10 @@ gtk_application_get_app_menu (GtkApplication *application)
|
||||
*
|
||||
* This is a menubar in the traditional sense.
|
||||
*
|
||||
* This can only be done in the primary instance of the application,
|
||||
* after it has been registered. #GApplication:startup is a good place
|
||||
* to call this.
|
||||
*
|
||||
* Depending on the desktop environment, this may appear at the top of
|
||||
* each window, or at the top of the screen. In some environments, if
|
||||
* both the application menu and the menubar are set, the application
|
||||
@@ -1077,8 +1092,6 @@ gtk_application_get_app_menu (GtkApplication *application)
|
||||
* example, the application menu may be rendered by the desktop shell
|
||||
* while the menubar (if set) remains in each individual window.
|
||||
*
|
||||
* You might call this method in your #GApplication:startup signal handler.
|
||||
*
|
||||
* Use the base #GActionMap interface to add actions, to respond to the user
|
||||
* selecting these menu items.
|
||||
*
|
||||
@@ -1089,6 +1102,8 @@ gtk_application_set_menubar (GtkApplication *application,
|
||||
GMenuModel *menubar)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_APPLICATION (application));
|
||||
g_return_if_fail (g_application_get_is_registered (G_APPLICATION (application)));
|
||||
g_return_if_fail (!g_application_get_is_remote (G_APPLICATION (application)));
|
||||
|
||||
if (menubar != application->priv->menubar)
|
||||
{
|
||||
|
||||
@@ -115,6 +115,10 @@ GDK_AVAILABLE_IN_3_4
|
||||
gboolean gtk_application_is_inhibited (GtkApplication *application,
|
||||
GtkApplicationInhibitFlags flags);
|
||||
|
||||
GDK_AVAILABLE_IN_3_6
|
||||
GtkWindow * gtk_application_get_window_by_id (GtkApplication *application,
|
||||
guint id);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_APPLICATION_H__ */
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
G_GNUC_INTERNAL
|
||||
gboolean gtk_application_window_publish (GtkApplicationWindow *window,
|
||||
GDBusConnection *session,
|
||||
const gchar *object_path);
|
||||
const gchar *object_path,
|
||||
guint object_id);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void gtk_application_window_unpublish (GtkApplicationWindow *window);
|
||||
@@ -43,8 +44,6 @@ GActionObservable * gtk_application_window_get_observable (GtkAppl
|
||||
G_GNUC_INTERNAL
|
||||
GtkAccelGroup * gtk_application_window_get_accel_group (GtkApplicationWindow *window);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
const gchar * gtk_application_get_dbus_object_path (GtkApplication *application);
|
||||
G_GNUC_INTERNAL
|
||||
const gchar * gtk_application_get_app_menu_object_path (GtkApplication *application);
|
||||
G_GNUC_INTERNAL
|
||||
|
||||
+71
-26
@@ -218,6 +218,8 @@ struct _GtkApplicationWindowPrivate
|
||||
GDBusConnection *session;
|
||||
gchar *object_path;
|
||||
guint export_id;
|
||||
|
||||
guint id;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -257,6 +259,32 @@ gtk_application_window_update_menubar (GtkApplicationWindow *window)
|
||||
}
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gtk_application_window_get_app_desktop_name (void)
|
||||
{
|
||||
gchar *retval = NULL;
|
||||
|
||||
#ifdef HAVE_GIO_UNIX
|
||||
GDesktopAppInfo *app_info;
|
||||
const gchar *app_name = NULL;
|
||||
gchar *desktop_file;
|
||||
|
||||
desktop_file = g_strconcat (g_get_prgname (), ".desktop", NULL);
|
||||
app_info = g_desktop_app_info_new (desktop_file);
|
||||
g_free (desktop_file);
|
||||
|
||||
if (app_info != NULL)
|
||||
app_name = g_app_info_get_name (G_APP_INFO (app_info));
|
||||
|
||||
if (app_name != NULL)
|
||||
retval = g_strdup (app_name);
|
||||
|
||||
g_clear_object (&app_info);
|
||||
#endif /* HAVE_GIO_UNIX */
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_window_update_shell_shows_app_menu (GtkApplicationWindow *window,
|
||||
GtkSettings *settings)
|
||||
@@ -282,33 +310,25 @@ gtk_application_window_update_shell_shows_app_menu (GtkApplicationWindow *window
|
||||
|
||||
if (app_menu != NULL)
|
||||
{
|
||||
const gchar *name;
|
||||
GDesktopAppInfo *app_info = NULL;
|
||||
const gchar *app_name;
|
||||
gchar *name;
|
||||
|
||||
name = g_get_application_name ();
|
||||
if (name == g_get_prgname ())
|
||||
app_name = g_get_application_name ();
|
||||
if (app_name != g_get_prgname ())
|
||||
{
|
||||
const gchar *app_name = NULL;
|
||||
|
||||
#ifdef HAVE_GIO_UNIX
|
||||
gchar *desktop_name;
|
||||
|
||||
desktop_name = g_strconcat (name, ".desktop", NULL);
|
||||
app_info = g_desktop_app_info_new (desktop_name);
|
||||
if (app_info != NULL)
|
||||
app_name = g_app_info_get_name (G_APP_INFO (app_info));
|
||||
|
||||
g_free (desktop_name);
|
||||
#endif /* HAVE_GIO_UNIX */
|
||||
|
||||
if (app_name != NULL &&
|
||||
g_strcmp0 (app_name, name) != 0)
|
||||
name = app_name;
|
||||
else
|
||||
name = _("Application");
|
||||
/* the app has set its application name, use it */
|
||||
name = g_strdup (app_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get the name from .desktop file */
|
||||
name = gtk_application_window_get_app_desktop_name ();
|
||||
if (name == NULL)
|
||||
name = g_strdup (_("Application"));
|
||||
}
|
||||
|
||||
g_menu_append_submenu (window->priv->app_menu_section, name, app_menu);
|
||||
g_clear_object (&app_info);
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -750,7 +770,7 @@ gtk_application_window_real_realize (GtkWidget *widget)
|
||||
|
||||
gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
|
||||
|
||||
if (GDK_IS_X11_WINDOW (gdkwindow))
|
||||
if (GDK_IS_X11_WINDOW (gdkwindow) && window->priv->session)
|
||||
{
|
||||
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_ID",
|
||||
g_application_get_application_id (G_APPLICATION (application)));
|
||||
@@ -759,7 +779,7 @@ gtk_application_window_real_realize (GtkWidget *widget)
|
||||
g_dbus_connection_get_unique_name (window->priv->session));
|
||||
|
||||
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_OBJECT_PATH",
|
||||
gtk_application_get_dbus_object_path (application));
|
||||
g_application_get_dbus_object_path (G_APPLICATION (application)));
|
||||
|
||||
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_WINDOW_OBJECT_PATH",
|
||||
window->priv->object_path);
|
||||
@@ -791,11 +811,13 @@ gtk_application_window_real_unrealize (GtkWidget *widget)
|
||||
gboolean
|
||||
gtk_application_window_publish (GtkApplicationWindow *window,
|
||||
GDBusConnection *session,
|
||||
const gchar *object_path)
|
||||
const gchar *object_path,
|
||||
guint object_id)
|
||||
{
|
||||
g_assert (window->priv->session == NULL);
|
||||
g_assert (window->priv->export_id == 0);
|
||||
g_assert (window->priv->object_path == NULL);
|
||||
g_assert (window->priv->id == 0);
|
||||
|
||||
window->priv->export_id = g_dbus_connection_export_action_group (session, object_path,
|
||||
G_ACTION_GROUP (window->priv->actions),
|
||||
@@ -806,6 +828,7 @@ gtk_application_window_publish (GtkApplicationWindow *window,
|
||||
|
||||
window->priv->session = session;
|
||||
window->priv->object_path = g_strdup (object_path);
|
||||
window->priv->id = object_id;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -816,10 +839,12 @@ gtk_application_window_unpublish (GtkApplicationWindow *window)
|
||||
g_assert (window->priv->session != NULL);
|
||||
g_assert (window->priv->export_id != 0);
|
||||
g_assert (window->priv->object_path != NULL);
|
||||
g_assert (window->priv->id != 0);
|
||||
|
||||
g_dbus_connection_unexport_action_group (window->priv->session, window->priv->export_id);
|
||||
window->priv->session = NULL;
|
||||
window->priv->export_id = 0;
|
||||
window->priv->id = 0;
|
||||
|
||||
g_free (window->priv->object_path);
|
||||
window->priv->object_path = NULL;
|
||||
@@ -1068,3 +1093,23 @@ gtk_application_window_get_accel_group (GtkApplicationWindow *window)
|
||||
{
|
||||
return window->priv->accels;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_window_get_id:
|
||||
* @window: a #GtkApplicationWindow
|
||||
*
|
||||
* Returns the unique ID of the window. If the window has not yet been added to
|
||||
* a #GtkApplication, returns <literal>0</literal>.
|
||||
*
|
||||
* Returns: the unique ID for @window, or <literal>0</literal> if the window
|
||||
* has not yet been added to a #GtkApplication
|
||||
*
|
||||
* Since: 3.6
|
||||
*/
|
||||
guint
|
||||
gtk_application_window_get_id (GtkApplicationWindow *window)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_APPLICATION_WINDOW (window), 0);
|
||||
|
||||
return window->priv->id;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,9 @@ void gtk_application_window_set_show_menubar (GtkApplicationWindow *windo
|
||||
GDK_AVAILABLE_IN_3_4
|
||||
gboolean gtk_application_window_get_show_menubar (GtkApplicationWindow *window);
|
||||
|
||||
GDK_AVAILABLE_IN_3_6
|
||||
guint gtk_application_window_get_id (GtkApplicationWindow *window);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_APPLICATION_WINDOW_H__ */
|
||||
|
||||
+51
-38
@@ -25,6 +25,10 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "gtkborderimageprivate.h"
|
||||
#include "gtkcssbordervalueprivate.h"
|
||||
#include "gtkcssimagevalueprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssrepeatvalueprivate.h"
|
||||
#include "gtkstylepropertiesprivate.h"
|
||||
#include "gtkthemingengineprivate.h"
|
||||
|
||||
@@ -37,23 +41,13 @@ gboolean
|
||||
_gtk_border_image_init (GtkBorderImage *image,
|
||||
GtkThemingEngine *engine)
|
||||
{
|
||||
GtkBorder *width;
|
||||
|
||||
image->source = _gtk_css_value_get_object (_gtk_theming_engine_peek_property (engine, "border-image-source"));
|
||||
image->source = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE));
|
||||
if (image->source == NULL)
|
||||
return FALSE;
|
||||
|
||||
image->slice = *(GtkBorder *) _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-slice"));
|
||||
width = _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-width"));
|
||||
if (width)
|
||||
{
|
||||
image->width = *width;
|
||||
image->has_width = TRUE;
|
||||
}
|
||||
else
|
||||
image->has_width = FALSE;
|
||||
|
||||
image->repeat = *_gtk_css_value_get_border_image_repeat (_gtk_theming_engine_peek_property (engine, "border-image-repeat"));
|
||||
image->slice = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE);
|
||||
image->width = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH);
|
||||
image->repeat = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -65,20 +59,38 @@ struct _GtkBorderImageSliceSize {
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_border_image_compute_border_size (GtkBorderImageSliceSize sizes[3],
|
||||
double offset,
|
||||
double area_size,
|
||||
int start_border,
|
||||
int end_border)
|
||||
gtk_border_image_compute_border_size (GtkBorderImageSliceSize sizes[3],
|
||||
double offset,
|
||||
double area_size,
|
||||
int start_border_width,
|
||||
int end_border_width,
|
||||
const GtkCssValue *start_border,
|
||||
const GtkCssValue *end_border)
|
||||
{
|
||||
/* This code assumes area_size >= start_border + end_border */
|
||||
double start, end;
|
||||
|
||||
if (_gtk_css_number_value_get_unit (start_border) == GTK_CSS_NUMBER)
|
||||
start = start_border_width * _gtk_css_number_value_get (start_border, 100);
|
||||
else
|
||||
start = _gtk_css_number_value_get (start_border, area_size);
|
||||
if (_gtk_css_number_value_get_unit (end_border) == GTK_CSS_NUMBER)
|
||||
end = end_border_width * _gtk_css_number_value_get (end_border, 100);
|
||||
else
|
||||
end = _gtk_css_number_value_get (end_border, area_size);
|
||||
|
||||
/* XXX: reduce vertical and horizontal by the same factor */
|
||||
if (start + end > area_size)
|
||||
{
|
||||
start = start * area_size / (start + end);
|
||||
end = end * area_size / (start + end);
|
||||
}
|
||||
|
||||
sizes[0].offset = offset;
|
||||
sizes[0].size = start_border;
|
||||
sizes[1].offset = offset + start_border;
|
||||
sizes[1].size = area_size - start_border - end_border;
|
||||
sizes[2].offset = offset + area_size - end_border;
|
||||
sizes[2].size = end_border;
|
||||
sizes[0].size = start;
|
||||
sizes[1].offset = offset + start;
|
||||
sizes[1].size = area_size - start - end;
|
||||
sizes[2].offset = offset + area_size - end;
|
||||
sizes[2].size = end;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -90,8 +102,8 @@ gtk_border_image_render_slice (cairo_t *cr,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssBorderRepeatStyle hrepeat,
|
||||
GtkCssBorderRepeatStyle vrepeat)
|
||||
GtkCssRepeatStyle hrepeat,
|
||||
GtkCssRepeatStyle vrepeat)
|
||||
{
|
||||
double hscale, vscale;
|
||||
double xstep, ystep;
|
||||
@@ -236,9 +248,6 @@ _gtk_border_image_render (GtkBorderImage *image,
|
||||
double source_width, source_height;
|
||||
int h, v;
|
||||
|
||||
if (image->has_width)
|
||||
border_width = &image->width;
|
||||
|
||||
_gtk_css_image_get_concrete_size (image->source,
|
||||
0, 0,
|
||||
width, height,
|
||||
@@ -252,22 +261,26 @@ _gtk_border_image_render (GtkBorderImage *image,
|
||||
|
||||
gtk_border_image_compute_slice_size (horizontal_slice,
|
||||
source_width,
|
||||
image->slice.left,
|
||||
image->slice.right);
|
||||
_gtk_css_number_value_get (_gtk_css_border_value_get_left (image->slice), source_width),
|
||||
_gtk_css_number_value_get (_gtk_css_border_value_get_right (image->slice), source_width));
|
||||
gtk_border_image_compute_slice_size (vertical_slice,
|
||||
source_height,
|
||||
image->slice.top,
|
||||
image->slice.bottom);
|
||||
_gtk_css_number_value_get (_gtk_css_border_value_get_top (image->slice), source_height),
|
||||
_gtk_css_number_value_get (_gtk_css_border_value_get_bottom (image->slice), source_height));
|
||||
gtk_border_image_compute_border_size (horizontal_border,
|
||||
x,
|
||||
width,
|
||||
border_width->left,
|
||||
border_width->right);
|
||||
border_width->right,
|
||||
_gtk_css_border_value_get_left (image->width),
|
||||
_gtk_css_border_value_get_right (image->width));
|
||||
gtk_border_image_compute_border_size (vertical_border,
|
||||
y,
|
||||
height,
|
||||
border_width->top,
|
||||
border_width->bottom);
|
||||
border_width->bottom,
|
||||
_gtk_css_border_value_get_top (image->width),
|
||||
_gtk_css_border_value_get_bottom(image->width));
|
||||
|
||||
for (v = 0; v < 3; v++)
|
||||
{
|
||||
@@ -298,8 +311,8 @@ _gtk_border_image_render (GtkBorderImage *image,
|
||||
vertical_border[v].offset,
|
||||
horizontal_border[h].size,
|
||||
vertical_border[v].size,
|
||||
h == 1 ? image->repeat.hrepeat : GTK_CSS_REPEAT_STYLE_STRETCH,
|
||||
v == 1 ? image->repeat.vrepeat : GTK_CSS_REPEAT_STYLE_STRETCH);
|
||||
h == 1 ? _gtk_css_border_repeat_value_get_x (image->repeat) : GTK_CSS_REPEAT_STYLE_STRETCH,
|
||||
v == 1 ? _gtk_css_border_repeat_value_get_y (image->repeat) : GTK_CSS_REPEAT_STYLE_STRETCH);
|
||||
|
||||
cairo_surface_destroy (slice);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
#include "gtkborder.h"
|
||||
#include "gtkcssimageprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
#include "gtkthemingengine.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -34,10 +34,9 @@ typedef struct _GtkBorderImage GtkBorderImage;
|
||||
struct _GtkBorderImage {
|
||||
GtkCssImage *source;
|
||||
|
||||
GtkBorder slice;
|
||||
gboolean has_width;
|
||||
GtkBorder width;
|
||||
GtkCssBorderImageRepeat repeat;
|
||||
GtkCssValue *slice;
|
||||
GtkCssValue *width;
|
||||
GtkCssValue *repeat;
|
||||
};
|
||||
|
||||
gboolean _gtk_border_image_init (GtkBorderImage *image,
|
||||
|
||||
+9
-2
@@ -85,6 +85,7 @@
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkwidgetpath.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "a11y/gtkboxaccessible.h"
|
||||
|
||||
|
||||
@@ -898,7 +899,7 @@ gtk_box_get_path_for_child (GtkContainer *container,
|
||||
box = GTK_BOX (container);
|
||||
private = box->priv;
|
||||
|
||||
path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
|
||||
path = _gtk_widget_create_path (GTK_WIDGET (container));
|
||||
|
||||
if (gtk_widget_get_visible (child))
|
||||
{
|
||||
@@ -937,11 +938,17 @@ gtk_box_get_path_for_child (GtkContainer *container,
|
||||
return path;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_box_invalidate_order_foreach (GtkWidget *widget)
|
||||
{
|
||||
_gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_box_invalidate_order (GtkBox *box)
|
||||
{
|
||||
gtk_container_foreach (GTK_CONTAINER (box),
|
||||
(GtkCallback) gtk_widget_reset_style,
|
||||
(GtkCallback) gtk_box_invalidate_order_foreach,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -963,15 +963,15 @@ end_element (GMarkupParseContext *context,
|
||||
else if (strcmp (element_name, "interface") == 0)
|
||||
{
|
||||
}
|
||||
else if (strcmp (element_name, "menu") == 0)
|
||||
{
|
||||
_gtk_builder_menu_end (data);
|
||||
}
|
||||
else if (data->requested_objects && !data->inside_requested_object)
|
||||
{
|
||||
/* If outside a requested object, simply ignore this tag */
|
||||
return;
|
||||
}
|
||||
else if (strcmp (element_name, "menu") == 0)
|
||||
{
|
||||
_gtk_builder_menu_end (data);
|
||||
}
|
||||
else if (strcmp (element_name, "object") == 0)
|
||||
{
|
||||
ObjectInfo *object_info = state_pop_info (data, ObjectInfo);
|
||||
|
||||
+9
-27
@@ -1677,15 +1677,12 @@ gtk_button_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_button_paint (GtkButton *button,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
GtkStateFlags state)
|
||||
static gboolean
|
||||
gtk_button_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkButton *button = GTK_BUTTON (widget);
|
||||
GtkButtonPrivate *priv = button->priv;
|
||||
GtkWidget *widget;
|
||||
gint x, y;
|
||||
GtkBorder default_border;
|
||||
GtkBorder default_outside_border;
|
||||
@@ -1694,13 +1691,12 @@ _gtk_button_paint (GtkButton *button,
|
||||
gint focus_pad;
|
||||
GtkAllocation allocation;
|
||||
GtkStyleContext *context;
|
||||
GtkStateFlags state;
|
||||
gboolean draw_focus;
|
||||
gint width, height;
|
||||
|
||||
widget = GTK_WIDGET (button);
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_set_state (context, state);
|
||||
state = gtk_style_context_get_state (context);
|
||||
|
||||
gtk_button_get_props (button, &default_border, &default_outside_border, NULL, NULL, &interior_focus);
|
||||
gtk_style_context_get_style (context,
|
||||
@@ -1712,6 +1708,8 @@ _gtk_button_paint (GtkButton *button,
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = allocation.width;
|
||||
height = allocation.height;
|
||||
|
||||
if (gtk_widget_has_default (widget) &&
|
||||
priv->relief == GTK_RELIEF_NORMAL)
|
||||
@@ -1720,8 +1718,6 @@ _gtk_button_paint (GtkButton *button,
|
||||
y += default_border.top;
|
||||
width -= default_border.left + default_border.right;
|
||||
height -= default_border.top + default_border.bottom;
|
||||
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
|
||||
}
|
||||
else if (gtk_widget_get_can_default (widget))
|
||||
{
|
||||
@@ -1789,20 +1785,6 @@ _gtk_button_paint (GtkButton *button,
|
||||
gtk_render_focus (context, cr, x, y, width, height);
|
||||
}
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_button_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkButton *button = GTK_BUTTON (widget);
|
||||
|
||||
_gtk_button_paint (button, cr,
|
||||
gtk_widget_get_allocated_width (widget),
|
||||
gtk_widget_get_allocated_height (widget),
|
||||
gtk_widget_get_state_flags (widget));
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_button_parent_class)->draw (widget, cr);
|
||||
|
||||
return FALSE;
|
||||
|
||||
@@ -63,11 +63,6 @@ struct _GtkButtonPrivate
|
||||
|
||||
void _gtk_button_set_depressed (GtkButton *button,
|
||||
gboolean depressed);
|
||||
void _gtk_button_paint (GtkButton *button,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
GtkStateFlags state);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#undef GDK_DEPRECATED_FOR
|
||||
#define GDK_DEPRECATED
|
||||
#define GDK_DEPRECATED_FOR(f)
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include "deprecated/gtkstyle.h"
|
||||
|
||||
|
||||
@@ -107,7 +107,8 @@ enum {
|
||||
PROP_MAX_WIDTH_CHARS,
|
||||
PROP_WRAP_WIDTH,
|
||||
PROP_ALIGN,
|
||||
|
||||
PROP_PLACEHOLDER_TEXT,
|
||||
|
||||
/* Style args */
|
||||
PROP_BACKGROUND,
|
||||
PROP_FOREGROUND,
|
||||
@@ -171,6 +172,7 @@ struct _GtkCellRendererTextPrivate
|
||||
PangoWrapMode wrap_mode;
|
||||
|
||||
gchar *text;
|
||||
gchar *placeholder_text;
|
||||
|
||||
gdouble font_scale;
|
||||
|
||||
@@ -619,7 +621,22 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class)
|
||||
PANGO_TYPE_ALIGNMENT,
|
||||
PANGO_ALIGN_LEFT,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
|
||||
/**
|
||||
* GtkCellRendererText:placeholder-text:
|
||||
*
|
||||
* The text that will be displayed in the #GtkCellRenderer if
|
||||
* #GtkCellRendererText:editable is %TRUE and the cell is empty.
|
||||
*
|
||||
* Since 3.6
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PLACEHOLDER_TEXT,
|
||||
g_param_spec_string ("placeholder-text",
|
||||
P_("Placeholder text"),
|
||||
P_("Text rendered when an editable cell is empty"),
|
||||
NULL,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
|
||||
/* Style props are set or not */
|
||||
@@ -726,6 +743,7 @@ gtk_cell_renderer_text_finalize (GObject *object)
|
||||
pango_font_description_free (priv->font);
|
||||
|
||||
g_free (priv->text);
|
||||
g_free (priv->placeholder_text);
|
||||
|
||||
if (priv->extra_attrs)
|
||||
pango_attr_list_unref (priv->extra_attrs);
|
||||
@@ -950,6 +968,10 @@ gtk_cell_renderer_text_get_property (GObject *object,
|
||||
g_value_set_int (value, priv->max_width_chars);
|
||||
break;
|
||||
|
||||
case PROP_PLACEHOLDER_TEXT:
|
||||
g_value_set_string (value, priv->placeholder_text);
|
||||
break;
|
||||
|
||||
case PROP_BACKGROUND:
|
||||
case PROP_FOREGROUND:
|
||||
case PROP_MARKUP:
|
||||
@@ -1510,7 +1532,12 @@ gtk_cell_renderer_text_set_property (GObject *object,
|
||||
case PROP_ALIGN_SET:
|
||||
priv->align_set = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
|
||||
case PROP_PLACEHOLDER_TEXT:
|
||||
g_free (priv->placeholder_text);
|
||||
priv->placeholder_text = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
@@ -1536,6 +1563,15 @@ gtk_cell_renderer_text_new (void)
|
||||
return g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, NULL);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
show_placeholder_text (GtkCellRendererText *celltext)
|
||||
{
|
||||
GtkCellRendererTextPrivate *priv = celltext->priv;
|
||||
|
||||
return priv->editable && priv->placeholder_text &&
|
||||
(!priv->text || !priv->text[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
add_attr (PangoAttrList *attr_list,
|
||||
PangoAttribute *attr)
|
||||
@@ -1557,8 +1593,10 @@ get_layout (GtkCellRendererText *celltext,
|
||||
PangoLayout *layout;
|
||||
PangoUnderline uline;
|
||||
gint xpad;
|
||||
gboolean placeholder_layout = show_placeholder_text (celltext);
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, priv->text);
|
||||
layout = gtk_widget_create_pango_layout (widget, placeholder_layout ?
|
||||
priv->placeholder_text : priv->text);
|
||||
|
||||
gtk_cell_renderer_get_padding (GTK_CELL_RENDERER (celltext), &xpad, NULL);
|
||||
|
||||
@@ -1569,7 +1607,7 @@ get_layout (GtkCellRendererText *celltext,
|
||||
|
||||
pango_layout_set_single_paragraph_mode (layout, priv->single_paragraph);
|
||||
|
||||
if (cell_area)
|
||||
if (!placeholder_layout && cell_area)
|
||||
{
|
||||
/* Add options that affect appearance but not size */
|
||||
|
||||
@@ -1594,6 +1632,22 @@ get_layout (GtkCellRendererText *celltext,
|
||||
add_attr (attr_list,
|
||||
pango_attr_strikethrough_new (priv->strikethrough));
|
||||
}
|
||||
else if (placeholder_layout)
|
||||
{
|
||||
PangoColor color;
|
||||
GtkStyleContext *context;
|
||||
GdkRGBA fg = { 0.5, 0.5, 0.5 };
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_lookup_color (context, "placeholder_text_color", &fg);
|
||||
|
||||
color.red = CLAMP (fg.red * 65535. + 0.5, 0, 65535);
|
||||
color.green = CLAMP (fg.green * 65535. + 0.5, 0, 65535);
|
||||
color.blue = CLAMP (fg.blue * 65535. + 0.5, 0, 65535);
|
||||
|
||||
add_attr (attr_list,
|
||||
pango_attr_foreground_new (color.red, color.green, color.blue));
|
||||
}
|
||||
|
||||
add_attr (attr_list, pango_attr_font_desc_new (priv->font));
|
||||
|
||||
|
||||
+1
-10
@@ -60,8 +60,6 @@
|
||||
#define CHECK_DARK (1.0 / 3.0)
|
||||
#define CHECK_LIGHT (2.0 / 3.0)
|
||||
|
||||
#define COLOR_SAMPLE_MARGIN 1
|
||||
|
||||
struct _GtkColorButtonPrivate
|
||||
{
|
||||
GtkWidget *draw_area; /* Widget where we draw the color sample */
|
||||
@@ -437,19 +435,12 @@ gtk_color_button_init (GtkColorButton *button)
|
||||
gtk_widget_push_composite_child ();
|
||||
|
||||
button->priv->draw_area = gtk_drawing_area_new ();
|
||||
g_object_set (button->priv->draw_area,
|
||||
"margin-top", COLOR_SAMPLE_MARGIN,
|
||||
"margin-bottom", COLOR_SAMPLE_MARGIN,
|
||||
"margin-left", 16,
|
||||
"margin-right", 16,
|
||||
NULL);
|
||||
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black");
|
||||
pango_layout_get_pixel_extents (layout, NULL, &rect);
|
||||
g_object_unref (layout);
|
||||
|
||||
gtk_widget_set_size_request (button->priv->draw_area,
|
||||
rect.width, rect.height - 2 * COLOR_SAMPLE_MARGIN);
|
||||
rect.width, rect.height);
|
||||
|
||||
g_signal_connect (button->priv->draw_area, "draw",
|
||||
G_CALLBACK (gtk_color_button_draw_cb), button);
|
||||
|
||||
+9
-2
@@ -41,6 +41,7 @@
|
||||
#include "gtktreeselection.h"
|
||||
#include "gtkseparator.h"
|
||||
#include "gtkwidgetpath.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkwindow.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkprivate.h"
|
||||
@@ -1381,11 +1382,17 @@ gtk_combo_box_button_state_flags_changed (GtkWidget *widget,
|
||||
gtk_widget_queue_draw (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_combo_box_invalidate_order_foreach (GtkWidget *widget)
|
||||
{
|
||||
_gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_combo_box_invalidate_order (GtkComboBox *combo_box)
|
||||
{
|
||||
gtk_container_forall (GTK_CONTAINER (combo_box),
|
||||
(GtkCallback) gtk_widget_reset_style,
|
||||
(GtkCallback) gtk_combo_box_invalidate_order_foreach,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -1408,7 +1415,7 @@ gtk_combo_box_get_path_for_child (GtkContainer *container,
|
||||
GtkWidgetPath *sibling_path;
|
||||
int pos;
|
||||
|
||||
path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
|
||||
path = _gtk_widget_create_path (GTK_WIDGET (container));
|
||||
|
||||
if (gtk_widget_get_visible (child))
|
||||
{
|
||||
|
||||
+115
-85
@@ -46,6 +46,7 @@
|
||||
#include "gtkwindow.h"
|
||||
#include "gtkassistant.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetpath.h"
|
||||
#include "a11y/gtkcontaineraccessible.h"
|
||||
|
||||
@@ -237,8 +238,9 @@ struct _GtkContainerPrivate
|
||||
guint border_width : 16;
|
||||
|
||||
guint has_focus_chain : 1;
|
||||
guint need_resize : 1;
|
||||
guint reallocate_redraws : 1;
|
||||
guint resize_pending : 1;
|
||||
guint restyle_pending : 1;
|
||||
guint resize_mode : 2;
|
||||
guint request_mode : 2;
|
||||
};
|
||||
@@ -342,6 +344,7 @@ static guint vadjustment_key_id = 0;
|
||||
static const gchar hadjustment_key[] = "gtk-hadjustment";
|
||||
static guint hadjustment_key_id = 0;
|
||||
static GSList *container_resize_queue = NULL;
|
||||
static GSList *container_restyle_queue = NULL;
|
||||
static guint container_signals[LAST_SIGNAL] = { 0 };
|
||||
static GtkWidgetClass *parent_class = NULL;
|
||||
extern GParamSpecPool *_gtk_widget_child_property_pool;
|
||||
@@ -1341,7 +1344,6 @@ gtk_container_init (GtkContainer *container)
|
||||
|
||||
priv->focus_child = NULL;
|
||||
priv->border_width = 0;
|
||||
priv->need_resize = FALSE;
|
||||
priv->resize_mode = GTK_RESIZE_PARENT;
|
||||
priv->reallocate_redraws = FALSE;
|
||||
}
|
||||
@@ -1352,8 +1354,13 @@ gtk_container_destroy (GtkWidget *widget)
|
||||
GtkContainer *container = GTK_CONTAINER (widget);
|
||||
GtkContainerPrivate *priv = container->priv;
|
||||
|
||||
if (_gtk_widget_get_resize_pending (GTK_WIDGET (container)))
|
||||
if (priv->resize_pending)
|
||||
_gtk_container_dequeue_resize_handler (container);
|
||||
if (priv->restyle_pending)
|
||||
{
|
||||
container_restyle_queue = g_slist_remove (container_restyle_queue, container);
|
||||
priv->restyle_pending = FALSE;
|
||||
}
|
||||
|
||||
if (priv->focus_child)
|
||||
{
|
||||
@@ -1543,10 +1550,10 @@ void
|
||||
_gtk_container_dequeue_resize_handler (GtkContainer *container)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_CONTAINER (container));
|
||||
g_return_if_fail (_gtk_widget_get_resize_pending (GTK_WIDGET (container)));
|
||||
g_return_if_fail (container->priv->resize_pending);
|
||||
|
||||
container_resize_queue = g_slist_remove (container_resize_queue, container);
|
||||
_gtk_widget_set_resize_pending (GTK_WIDGET (container), FALSE);
|
||||
container->priv->resize_pending = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1622,25 +1629,35 @@ gtk_container_set_reallocate_redraws (GtkContainer *container,
|
||||
container->priv->reallocate_redraws = needs_redraws ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
static GtkContainer*
|
||||
gtk_container_get_resize_container (GtkContainer *container)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkWidget *widget = GTK_WIDGET (container);
|
||||
|
||||
while ((parent = gtk_widget_get_parent (widget)))
|
||||
{
|
||||
widget = parent;
|
||||
if (GTK_IS_RESIZE_CONTAINER (widget))
|
||||
break;
|
||||
}
|
||||
|
||||
return GTK_IS_RESIZE_CONTAINER (widget) ? (GtkContainer*) widget : NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_container_idle_sizer (gpointer data)
|
||||
{
|
||||
GSList *slist;
|
||||
gint64 current_time;
|
||||
|
||||
/* We validate the style contexts in a single loop before even trying
|
||||
* to handle resizes instead of doing validations inline.
|
||||
* This is mostly necessary for compatibility reasons with old code,
|
||||
* because both style_updated and size_allocate functions often change
|
||||
* styles and so could cause infinite loops in this function.
|
||||
*
|
||||
* It's important to note that even an invalid style context returns
|
||||
* sane values. So the result of an invalid style context will never be
|
||||
* a program crash, but only a wrong layout or rendering.
|
||||
*/
|
||||
current_time = g_get_monotonic_time ();
|
||||
slist = container_restyle_queue;
|
||||
container_restyle_queue = NULL;
|
||||
for (; slist; slist = slist->next)
|
||||
{
|
||||
GtkContainer *container = slist->data;
|
||||
|
||||
container->priv->restyle_pending = FALSE;
|
||||
_gtk_style_context_validate (gtk_widget_get_style_context (GTK_WIDGET (container)),
|
||||
current_time,
|
||||
0);
|
||||
}
|
||||
|
||||
/* we may be invoked with a container_resize_queue of NULL, because
|
||||
* queue_resize could have been adding an extra idle function while
|
||||
* the queue still got processed. we better just ignore such case
|
||||
@@ -1649,88 +1666,114 @@ gtk_container_idle_sizer (gpointer data)
|
||||
*/
|
||||
while (container_resize_queue)
|
||||
{
|
||||
GSList *slist;
|
||||
GtkWidget *widget;
|
||||
GtkContainer *container;
|
||||
|
||||
slist = container_resize_queue;
|
||||
container_resize_queue = slist->next;
|
||||
widget = slist->data;
|
||||
container = slist->data;
|
||||
g_slist_free_1 (slist);
|
||||
|
||||
_gtk_widget_set_resize_pending (widget, FALSE);
|
||||
gtk_container_check_resize (GTK_CONTAINER (widget));
|
||||
container->priv->resize_pending = FALSE;
|
||||
gtk_container_check_resize (container);
|
||||
}
|
||||
|
||||
gdk_window_process_all_updates ();
|
||||
|
||||
return FALSE;
|
||||
return container_resize_queue != NULL || container_restyle_queue != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_container_start_idle_sizer (GtkContainer *container)
|
||||
{
|
||||
/* already started */
|
||||
if (container_resize_queue != NULL ||
|
||||
container_restyle_queue != NULL)
|
||||
return;
|
||||
|
||||
gdk_threads_add_idle_full (GTK_PRIORITY_RESIZE,
|
||||
gtk_container_idle_sizer,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_container_queue_resize_handler (GtkContainer *container)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
g_return_if_fail (GTK_IS_RESIZE_CONTAINER (container));
|
||||
|
||||
widget = GTK_WIDGET (container);
|
||||
|
||||
if (gtk_widget_get_visible (widget) &&
|
||||
(gtk_widget_is_toplevel (widget) ||
|
||||
gtk_widget_get_realized (widget)))
|
||||
{
|
||||
switch (container->priv->resize_mode)
|
||||
{
|
||||
case GTK_RESIZE_QUEUE:
|
||||
if (!container->priv->resize_pending)
|
||||
{
|
||||
container->priv->resize_pending = TRUE;
|
||||
gtk_container_start_idle_sizer (container);
|
||||
container_resize_queue = g_slist_prepend (container_resize_queue, container);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_RESIZE_IMMEDIATE:
|
||||
gtk_container_check_resize (container);
|
||||
break;
|
||||
|
||||
case GTK_RESIZE_PARENT:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_container_queue_resize_internal (GtkContainer *container,
|
||||
gboolean invalidate_only)
|
||||
{
|
||||
GtkContainer *resize_container;
|
||||
GtkWidget *parent;
|
||||
GtkWidget *widget;
|
||||
|
||||
g_return_if_fail (GTK_IS_CONTAINER (container));
|
||||
|
||||
widget = GTK_WIDGET (container);
|
||||
|
||||
resize_container = gtk_container_get_resize_container (container);
|
||||
|
||||
while (TRUE)
|
||||
do
|
||||
{
|
||||
_gtk_widget_set_alloc_needed (widget, TRUE);
|
||||
_gtk_widget_set_width_request_needed (widget, TRUE);
|
||||
_gtk_widget_set_height_request_needed (widget, TRUE);
|
||||
|
||||
if ((resize_container && widget == GTK_WIDGET (resize_container)) ||
|
||||
!(parent = gtk_widget_get_parent (widget)))
|
||||
if (GTK_IS_RESIZE_CONTAINER (widget))
|
||||
break;
|
||||
|
||||
widget = parent;
|
||||
widget = gtk_widget_get_parent (widget);
|
||||
}
|
||||
while (widget);
|
||||
|
||||
if (resize_container && !invalidate_only)
|
||||
{
|
||||
if (gtk_widget_get_visible (GTK_WIDGET (resize_container)) &&
|
||||
(gtk_widget_is_toplevel (GTK_WIDGET (resize_container)) ||
|
||||
gtk_widget_get_realized (GTK_WIDGET (resize_container))))
|
||||
{
|
||||
switch (resize_container->priv->resize_mode)
|
||||
{
|
||||
case GTK_RESIZE_QUEUE:
|
||||
if (!_gtk_widget_get_resize_pending (GTK_WIDGET (resize_container)))
|
||||
{
|
||||
_gtk_widget_set_resize_pending (GTK_WIDGET (resize_container), TRUE);
|
||||
if (container_resize_queue == NULL)
|
||||
gdk_threads_add_idle_full (GTK_PRIORITY_RESIZE,
|
||||
gtk_container_idle_sizer,
|
||||
NULL, NULL);
|
||||
container_resize_queue = g_slist_prepend (container_resize_queue, resize_container);
|
||||
}
|
||||
break;
|
||||
if (widget && !invalidate_only)
|
||||
gtk_container_queue_resize_handler (GTK_CONTAINER (widget));
|
||||
}
|
||||
|
||||
case GTK_RESIZE_IMMEDIATE:
|
||||
gtk_container_check_resize (resize_container);
|
||||
break;
|
||||
void
|
||||
_gtk_container_queue_restyle (GtkContainer *container)
|
||||
{
|
||||
GtkContainerPrivate *priv;
|
||||
|
||||
case GTK_RESIZE_PARENT:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we need to let hidden resize containers know that something
|
||||
* changed while they where hidden (currently only evaluated by
|
||||
* toplevels).
|
||||
*/
|
||||
resize_container->priv->need_resize = TRUE;
|
||||
}
|
||||
}
|
||||
g_return_if_fail (GTK_CONTAINER (container));
|
||||
|
||||
priv = container->priv;
|
||||
|
||||
if (priv->restyle_pending)
|
||||
return;
|
||||
|
||||
gtk_container_start_idle_sizer (container);
|
||||
|
||||
container_restyle_queue = g_slist_prepend (container_restyle_queue, container);
|
||||
priv->restyle_pending = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2323,7 +2366,7 @@ gtk_container_real_get_path_for_child (GtkContainer *container,
|
||||
GList *classes;
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (container));
|
||||
path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
|
||||
path = _gtk_widget_create_path (GTK_WIDGET (container));
|
||||
|
||||
/* Copy any permanent classes to the path */
|
||||
classes = gtk_style_context_list_classes (context);
|
||||
@@ -3344,19 +3387,6 @@ gtk_container_propagate_draw (GtkContainer *container,
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_container_get_need_resize (GtkContainer *container)
|
||||
{
|
||||
return container->priv->need_resize;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_container_set_need_resize (GtkContainer *container,
|
||||
gboolean need_resize)
|
||||
{
|
||||
container->priv->need_resize = need_resize;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_container_get_reallocate_redraws (GtkContainer *container)
|
||||
{
|
||||
|
||||
@@ -20,11 +20,14 @@
|
||||
#ifndef __GTK_CONTAINER_PRIVATE_H__
|
||||
#define __GTK_CONTAINER_PRIVATE_H__
|
||||
|
||||
#include "gtkcontainer.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
GList * _gtk_container_get_all_children (GtkContainer *container);
|
||||
void _gtk_container_queue_resize (GtkContainer *container);
|
||||
void _gtk_container_queue_restyle (GtkContainer *container);
|
||||
void _gtk_container_resize_invalidate (GtkContainer *container);
|
||||
void _gtk_container_clear_resize_widgets (GtkContainer *container);
|
||||
gchar* _gtk_container_child_composite_name (GtkContainer *container,
|
||||
@@ -34,9 +37,6 @@ GList * _gtk_container_focus_sort (GtkContainer *container,
|
||||
GList *children,
|
||||
GtkDirectionType direction,
|
||||
GtkWidget *old_focus);
|
||||
gboolean _gtk_container_get_need_resize (GtkContainer *container);
|
||||
void _gtk_container_set_need_resize (GtkContainer *container,
|
||||
gboolean need_resize);
|
||||
gboolean _gtk_container_get_reallocate_redraws (GtkContainer *container);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssanimatedvaluesprivate.h"
|
||||
|
||||
#include "gtkcssarrayvalueprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssshorthandpropertyprivate.h"
|
||||
#include "gtkcssstringvalueprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkcsstransitionprivate.h"
|
||||
#include "gtkstyleanimationprivate.h"
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssAnimatedValues, _gtk_css_animated_values, GTK_TYPE_CSS_COMPUTED_VALUES)
|
||||
|
||||
static void
|
||||
gtk_css_animated_values_dispose (GObject *object)
|
||||
{
|
||||
GtkCssAnimatedValues *values = GTK_CSS_ANIMATED_VALUES (object);
|
||||
|
||||
g_clear_object (&values->computed);
|
||||
g_slist_free_full (values->animations, g_object_unref);
|
||||
values->animations = NULL;
|
||||
|
||||
G_OBJECT_CLASS (_gtk_css_animated_values_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_animated_values_class_init (GtkCssAnimatedValuesClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_css_animated_values_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_animated_values_init (GtkCssAnimatedValues *animated_values)
|
||||
{
|
||||
}
|
||||
|
||||
/* TRANSITIONS */
|
||||
|
||||
typedef struct _TransitionInfo TransitionInfo;
|
||||
struct _TransitionInfo {
|
||||
guint index; /* index into value arrays */
|
||||
gboolean pending; /* TRUE if we still need to handle it */
|
||||
};
|
||||
|
||||
static void
|
||||
transition_info_add (TransitionInfo infos[GTK_CSS_PROPERTY_N_PROPERTIES],
|
||||
GtkStyleProperty *property,
|
||||
guint index)
|
||||
{
|
||||
if (property == NULL)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
|
||||
{
|
||||
GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (i);
|
||||
|
||||
transition_info_add (infos, GTK_STYLE_PROPERTY (prop), index);
|
||||
}
|
||||
}
|
||||
else if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
|
||||
{
|
||||
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
|
||||
{
|
||||
GtkCssStyleProperty *prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
|
||||
|
||||
transition_info_add (infos, GTK_STYLE_PROPERTY (prop), index);
|
||||
}
|
||||
}
|
||||
else if (GTK_IS_CSS_STYLE_PROPERTY (property))
|
||||
{
|
||||
guint id;
|
||||
|
||||
if (!_gtk_css_style_property_is_animated (GTK_CSS_STYLE_PROPERTY (property)))
|
||||
return;
|
||||
|
||||
id = _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (property));
|
||||
g_assert (id < GTK_CSS_PROPERTY_N_PROPERTIES);
|
||||
infos[id].index = index;
|
||||
infos[id].pending = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
transition_infos_set (TransitionInfo infos[GTK_CSS_PROPERTY_N_PROPERTIES],
|
||||
GtkCssValue *transitions)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < _gtk_css_array_value_get_n_values (transitions); i++)
|
||||
{
|
||||
GtkStyleProperty *property;
|
||||
GtkCssValue *prop_value;
|
||||
|
||||
prop_value = _gtk_css_array_value_get_nth (transitions, i);
|
||||
if (g_ascii_strcasecmp (_gtk_css_ident_value_get (prop_value), "all") == 0)
|
||||
property = NULL;
|
||||
else
|
||||
{
|
||||
property = _gtk_style_property_lookup (_gtk_css_ident_value_get (prop_value));
|
||||
if (property == NULL)
|
||||
continue;
|
||||
}
|
||||
|
||||
transition_info_add (infos, property, i);
|
||||
}
|
||||
}
|
||||
|
||||
static GtkStyleAnimation *
|
||||
gtk_css_animated_values_find_transition (GtkCssAnimatedValues *values,
|
||||
guint property_id)
|
||||
{
|
||||
GSList *list;
|
||||
|
||||
for (list = values->animations; list; list = list->next)
|
||||
{
|
||||
if (!GTK_IS_CSS_TRANSITION (list->data))
|
||||
continue;
|
||||
|
||||
if (_gtk_css_transition_get_property (list->data) == property_id)
|
||||
return list->data;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_animated_values_start_transitions (GtkCssAnimatedValues *values,
|
||||
gint64 timestamp,
|
||||
GtkCssComputedValues *source)
|
||||
{
|
||||
TransitionInfo transitions[GTK_CSS_PROPERTY_N_PROPERTIES] = { { 0, } };
|
||||
GtkCssComputedValues *source_computed, *computed;
|
||||
GtkCssValue *durations, *delays, *timing_functions;
|
||||
guint i;
|
||||
|
||||
computed = GTK_CSS_COMPUTED_VALUES (values);
|
||||
if (GTK_IS_CSS_ANIMATED_VALUES (source))
|
||||
source_computed = GTK_CSS_ANIMATED_VALUES (source)->computed;
|
||||
else
|
||||
source_computed = source;
|
||||
|
||||
transition_infos_set (transitions, _gtk_css_computed_values_get_value (computed, GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
|
||||
|
||||
durations = _gtk_css_computed_values_get_value (computed, GTK_CSS_PROPERTY_TRANSITION_DURATION);
|
||||
delays = _gtk_css_computed_values_get_value (computed, GTK_CSS_PROPERTY_TRANSITION_DELAY);
|
||||
timing_functions = _gtk_css_computed_values_get_value (computed, GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION);
|
||||
|
||||
|
||||
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
|
||||
{
|
||||
GtkStyleAnimation *animation;
|
||||
GtkCssValue *start, *end;
|
||||
double duration, delay;
|
||||
|
||||
if (!transitions[i].pending)
|
||||
continue;
|
||||
|
||||
duration = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, transitions[i].index), 100);
|
||||
delay = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, transitions[i].index), 100);
|
||||
if (duration + delay == 0.0)
|
||||
continue;
|
||||
|
||||
start = _gtk_css_computed_values_get_value (source_computed, i);
|
||||
end = _gtk_css_computed_values_get_value (values->computed, i);
|
||||
if (_gtk_css_value_equal (start, end))
|
||||
{
|
||||
if (GTK_IS_CSS_ANIMATED_VALUES (source))
|
||||
{
|
||||
animation = gtk_css_animated_values_find_transition (GTK_CSS_ANIMATED_VALUES (source), i);
|
||||
if (animation)
|
||||
values->animations = g_slist_prepend (values->animations, g_object_ref (animation));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
animation = _gtk_css_transition_new (i,
|
||||
start,
|
||||
end,
|
||||
_gtk_css_array_value_get_nth (timing_functions, i),
|
||||
timestamp + delay * G_USEC_PER_SEC,
|
||||
timestamp + (delay + duration) * G_USEC_PER_SEC);
|
||||
values->animations = g_slist_prepend (values->animations, animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* PUBLIC API */
|
||||
|
||||
static void
|
||||
gtk_css_animated_values_start_animations (GtkCssAnimatedValues *values,
|
||||
gint64 timestamp,
|
||||
GtkCssComputedValues *source)
|
||||
{
|
||||
gtk_css_animated_values_start_transitions (values, timestamp, source);
|
||||
}
|
||||
|
||||
GtkCssComputedValues *
|
||||
_gtk_css_animated_values_new (GtkCssComputedValues *computed,
|
||||
GtkCssComputedValues *source,
|
||||
gint64 timestamp)
|
||||
{
|
||||
GtkCssAnimatedValues *values;
|
||||
GtkCssValue *value;
|
||||
GtkBitmask *ignore;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (computed), NULL);
|
||||
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (source), NULL);
|
||||
|
||||
values = g_object_new (GTK_TYPE_CSS_ANIMATED_VALUES, NULL);
|
||||
|
||||
values->computed = g_object_ref (computed);
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
value = _gtk_css_computed_values_get_value (computed, i);
|
||||
|
||||
if (value == NULL)
|
||||
break;
|
||||
|
||||
_gtk_css_computed_values_set_value (GTK_CSS_COMPUTED_VALUES (values),
|
||||
i,
|
||||
value,
|
||||
_gtk_css_computed_values_get_section (computed, i));
|
||||
}
|
||||
|
||||
gtk_css_animated_values_start_animations (values, timestamp, source);
|
||||
|
||||
ignore = _gtk_css_animated_values_advance (values, timestamp);
|
||||
_gtk_bitmask_free (ignore);
|
||||
|
||||
return GTK_CSS_COMPUTED_VALUES (values);
|
||||
}
|
||||
|
||||
GtkBitmask *
|
||||
_gtk_css_animated_values_advance (GtkCssAnimatedValues *values,
|
||||
gint64 timestamp)
|
||||
{
|
||||
GtkBitmask *changed;
|
||||
GSList *list;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_ANIMATED_VALUES (values), NULL);
|
||||
g_return_val_if_fail (timestamp >= values->current_time, NULL);
|
||||
|
||||
changed = _gtk_bitmask_new ();
|
||||
|
||||
values->current_time = timestamp;
|
||||
|
||||
list = values->animations;
|
||||
while (list)
|
||||
{
|
||||
GtkStyleAnimation *animation = list->data;
|
||||
|
||||
list = list->next;
|
||||
|
||||
changed = _gtk_style_animation_set_values (animation,
|
||||
changed,
|
||||
timestamp,
|
||||
GTK_CSS_COMPUTED_VALUES (values));
|
||||
|
||||
if (_gtk_style_animation_is_finished (animation, timestamp))
|
||||
{
|
||||
values->animations = g_slist_remove (values->animations, animation);
|
||||
g_object_unref (animation);
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_css_animated_values_is_finished (GtkCssAnimatedValues *values)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_CSS_ANIMATED_VALUES (values), TRUE);
|
||||
|
||||
return values->animations == NULL;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_ANIMATED_VALUES_PRIVATE_H__
|
||||
#define __GTK_CSS_ANIMATED_VALUES_PRIVATE_H__
|
||||
|
||||
#include "gtk/gtkcsscomputedvaluesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CSS_ANIMATED_VALUES (_gtk_css_animated_values_get_type ())
|
||||
#define GTK_CSS_ANIMATED_VALUES(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_ANIMATED_VALUES, GtkCssAnimatedValues))
|
||||
#define GTK_CSS_ANIMATED_VALUES_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_ANIMATED_VALUES, GtkCssAnimatedValuesClass))
|
||||
#define GTK_IS_CSS_ANIMATED_VALUES(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_ANIMATED_VALUES))
|
||||
#define GTK_IS_CSS_ANIMATED_VALUES_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_ANIMATED_VALUES))
|
||||
#define GTK_CSS_ANIMATED_VALUES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_ANIMATED_VALUES, GtkCssAnimatedValuesClass))
|
||||
|
||||
typedef struct _GtkCssAnimatedValues GtkCssAnimatedValues;
|
||||
typedef struct _GtkCssAnimatedValuesClass GtkCssAnimatedValuesClass;
|
||||
|
||||
struct _GtkCssAnimatedValues
|
||||
{
|
||||
GtkCssComputedValues parent;
|
||||
|
||||
gint64 current_time; /* the current time in our world */
|
||||
GtkCssComputedValues *computed; /* the computed values we'd have without animations */
|
||||
GSList *animations; /* the running animations */
|
||||
};
|
||||
|
||||
struct _GtkCssAnimatedValuesClass
|
||||
{
|
||||
GtkCssComputedValuesClass parent_class;
|
||||
};
|
||||
|
||||
GType _gtk_css_animated_values_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkCssComputedValues * _gtk_css_animated_values_new (GtkCssComputedValues *computed,
|
||||
GtkCssComputedValues *source,
|
||||
gint64 timestamp);
|
||||
|
||||
GtkBitmask * _gtk_css_animated_values_advance (GtkCssAnimatedValues *values,
|
||||
gint64 timestamp) G_GNUC_WARN_UNUSED_RESULT;
|
||||
gboolean _gtk_css_animated_values_is_finished (GtkCssAnimatedValues *values);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_ANIMATED_VALUES_PRIVATE_H__ */
|
||||
@@ -0,0 +1,206 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssarrayvalueprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
guint n_values;
|
||||
GtkCssValue *values[1];
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_array_free (GtkCssValue *value)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < value->n_values; i++)
|
||||
{
|
||||
_gtk_css_value_unref (value->values[i]);
|
||||
}
|
||||
|
||||
g_slice_free1 (sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (value->n_values - 1), value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_array_equal (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (value1->n_values != value2->n_values)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < value1->n_values; i++)
|
||||
{
|
||||
if (!_gtk_css_value_equal (value1->values[i],
|
||||
value2->values[i]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_array_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_array_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (value->n_values == 0)
|
||||
{
|
||||
g_string_append (string, "none");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < value->n_values; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append (string, ", ");
|
||||
_gtk_css_value_print (value->values[i], string);
|
||||
}
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_ARRAY = {
|
||||
gtk_css_value_array_free,
|
||||
gtk_css_value_array_equal,
|
||||
gtk_css_value_array_transition,
|
||||
gtk_css_value_array_print
|
||||
};
|
||||
|
||||
static GtkCssValue none_singleton = { >K_CSS_VALUE_ARRAY, 1, 0, { NULL } };
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_array_value_new (GtkCssValue *content)
|
||||
{
|
||||
if (content == NULL)
|
||||
return _gtk_css_value_ref (&none_singleton);
|
||||
|
||||
return _gtk_css_array_value_new_from_array (&content, 1);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_array_value_new_from_array (GtkCssValue **values,
|
||||
guint n_values)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
g_return_val_if_fail (values != NULL, NULL);
|
||||
g_return_val_if_fail (n_values > 0, NULL);
|
||||
|
||||
result = _gtk_css_value_alloc (>K_CSS_VALUE_ARRAY, sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (n_values - 1));
|
||||
result->n_values = n_values;
|
||||
memcpy (&result->values[0], values, sizeof (GtkCssValue *) * n_values);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_array_value_parse (GtkCssParser *parser,
|
||||
GtkCssValue *(* parse_func) (GtkCssParser *parser),
|
||||
gboolean allow_none)
|
||||
{
|
||||
GtkCssValue *value, *result;
|
||||
GPtrArray *values;
|
||||
|
||||
if (allow_none &&
|
||||
_gtk_css_parser_try (parser, "none", TRUE))
|
||||
return _gtk_css_value_ref (&none_singleton);
|
||||
|
||||
values = g_ptr_array_new ();
|
||||
|
||||
do {
|
||||
value = parse_func (parser);
|
||||
|
||||
if (value == NULL)
|
||||
{
|
||||
g_ptr_array_set_free_func (values, (GDestroyNotify) _gtk_css_value_unref);
|
||||
g_ptr_array_free (values, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_ptr_array_add (values, value);
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
|
||||
result = _gtk_css_array_value_new_from_array ((GtkCssValue **) values->pdata, values->len);
|
||||
g_ptr_array_free (values, TRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_array_value_compute (GtkCssValue *value,
|
||||
GtkCssValue * (* compute_func) (GtkCssValue *, GtkStyleContext *),
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
gboolean changed = FALSE;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_ARRAY, NULL);
|
||||
g_return_val_if_fail (compute_func != NULL, NULL);
|
||||
|
||||
if (value->n_values == 0)
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
|
||||
for (i = 0; i < value->n_values; i++)
|
||||
{
|
||||
result->values[i] = (* compute_func) (value->values[i], context);
|
||||
changed |= (result->values[i] != value->values[i]);
|
||||
}
|
||||
|
||||
if (!changed)
|
||||
{
|
||||
_gtk_css_value_unref (result);
|
||||
return _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_array_value_get_nth (const GtkCssValue *value,
|
||||
guint i)
|
||||
{
|
||||
g_return_val_if_fail (value != NULL, NULL);
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_ARRAY, NULL);
|
||||
g_return_val_if_fail (value->n_values > 0, NULL);
|
||||
|
||||
return value->values[i % value->n_values];
|
||||
}
|
||||
|
||||
guint
|
||||
_gtk_css_array_value_get_n_values (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value != NULL, 0);
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_ARRAY, 0);
|
||||
|
||||
return value->n_values;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_ARRAY_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_ARRAY_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
#include "gtktypes.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_array_value_new (GtkCssValue *content);
|
||||
GtkCssValue * _gtk_css_array_value_new_from_array (GtkCssValue **values,
|
||||
guint n_values);
|
||||
GtkCssValue * _gtk_css_array_value_parse (GtkCssParser *parser,
|
||||
GtkCssValue * (* parse_func) (GtkCssParser *),
|
||||
gboolean allow_none);
|
||||
|
||||
GtkCssValue * _gtk_css_array_value_compute (GtkCssValue *value,
|
||||
GtkCssValue * (* compute_func) (GtkCssValue *, GtkStyleContext *),
|
||||
GtkStyleContext *context);
|
||||
GtkCssValue * _gtk_css_array_value_get_nth (const GtkCssValue *value,
|
||||
guint i);
|
||||
guint _gtk_css_array_value_get_n_values (const GtkCssValue *value);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_ARRAY_VALUE_PRIVATE_H__ */
|
||||
@@ -0,0 +1,258 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssbgsizevalueprivate.h"
|
||||
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
guint cover :1;
|
||||
guint contain :1;
|
||||
GtkCssValue *x;
|
||||
GtkCssValue *y;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_bg_size_free (GtkCssValue *value)
|
||||
{
|
||||
if (value->x)
|
||||
_gtk_css_value_unref (value->x);
|
||||
if (value->y)
|
||||
_gtk_css_value_unref (value->y);
|
||||
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_bg_size_equal (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
return value1->cover == value2->cover &&
|
||||
value2->contain == value2->contain &&
|
||||
(value1->x == value2->x ||
|
||||
(value1->x != NULL && value2->x != NULL &&
|
||||
_gtk_css_value_equal (value1->x, value2->x))) &&
|
||||
(value1->y == value2->y ||
|
||||
(value1->y != NULL && value2->y != NULL &&
|
||||
_gtk_css_value_equal (value1->y, value2->y)));
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_bg_size_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
if (start->cover)
|
||||
return end->cover ? _gtk_css_value_ref (end) : NULL;
|
||||
if (start->contain)
|
||||
return end->contain ? _gtk_css_value_ref (end) : NULL;
|
||||
|
||||
if ((start->x != NULL) ^ (end->x != NULL) ||
|
||||
(start->y != NULL) ^ (end->y != NULL))
|
||||
return NULL;
|
||||
|
||||
if (start->x)
|
||||
{
|
||||
x = _gtk_css_value_transition (start->x, end->x, progress);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
x = NULL;
|
||||
|
||||
if (start->y)
|
||||
{
|
||||
y = _gtk_css_value_transition (start->y, end->y, progress);
|
||||
if (y == NULL)
|
||||
{
|
||||
_gtk_css_value_unref (x);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
y = NULL;
|
||||
|
||||
return _gtk_css_bg_size_value_new (x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_bg_size_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
if (value->cover)
|
||||
g_string_append (string, "cover");
|
||||
else if (value->contain)
|
||||
g_string_append (string, "contain");
|
||||
else
|
||||
{
|
||||
if (value->x == NULL)
|
||||
g_string_append (string, "auto");
|
||||
else
|
||||
_gtk_css_value_print (value->x, string);
|
||||
|
||||
if (value->y)
|
||||
{
|
||||
g_string_append_c (string, ' ');
|
||||
_gtk_css_value_print (value->y, string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_BG_SIZE = {
|
||||
gtk_css_value_bg_size_free,
|
||||
gtk_css_value_bg_size_equal,
|
||||
gtk_css_value_bg_size_transition,
|
||||
gtk_css_value_bg_size_print
|
||||
};
|
||||
|
||||
static GtkCssValue auto_singleton = { >K_CSS_VALUE_BG_SIZE, 1, FALSE, FALSE, NULL, NULL };
|
||||
static GtkCssValue cover_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, NULL, NULL };
|
||||
static GtkCssValue contain_singleton = { >K_CSS_VALUE_BG_SIZE, 1, FALSE, TRUE, NULL, NULL };
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_bg_size_value_new (GtkCssValue *x,
|
||||
GtkCssValue *y)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
if (x == NULL && y == NULL)
|
||||
return _gtk_css_value_ref (&auto_singleton);
|
||||
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_BG_SIZE);
|
||||
result->x = x;
|
||||
result->y = y;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_bg_size_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
if (_gtk_css_parser_try (parser, "cover", TRUE))
|
||||
return _gtk_css_value_ref (&cover_singleton);
|
||||
else if (_gtk_css_parser_try (parser, "contain", TRUE))
|
||||
return _gtk_css_value_ref (&contain_singleton);
|
||||
|
||||
if (_gtk_css_parser_try (parser, "auto", TRUE))
|
||||
x = NULL;
|
||||
else
|
||||
{
|
||||
x = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_gtk_css_parser_try (parser, "auto", TRUE))
|
||||
y = NULL;
|
||||
else if (!_gtk_css_parser_has_number (parser))
|
||||
y = NULL;
|
||||
else
|
||||
{
|
||||
y = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (y == NULL)
|
||||
{
|
||||
_gtk_css_value_unref (x);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return _gtk_css_bg_size_value_new (x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_bg_size_compute_size_for_cover_contain (gboolean cover,
|
||||
GtkCssImage *image,
|
||||
double width,
|
||||
double height,
|
||||
double *concrete_width,
|
||||
double *concrete_height)
|
||||
{
|
||||
double aspect, image_aspect;
|
||||
|
||||
image_aspect = _gtk_css_image_get_aspect_ratio (image);
|
||||
if (image_aspect == 0.0)
|
||||
{
|
||||
*concrete_width = width;
|
||||
*concrete_height = height;
|
||||
return;
|
||||
}
|
||||
|
||||
aspect = width / height;
|
||||
|
||||
if ((aspect >= image_aspect && cover) ||
|
||||
(aspect < image_aspect && !cover))
|
||||
{
|
||||
*concrete_width = width;
|
||||
*concrete_height = width / image_aspect;
|
||||
}
|
||||
else
|
||||
{
|
||||
*concrete_height = height;
|
||||
*concrete_width = height * image_aspect;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_css_bg_size_value_compute_size (const GtkCssValue *value,
|
||||
GtkCssImage *image,
|
||||
double area_width,
|
||||
double area_height,
|
||||
double *out_width,
|
||||
double *out_height)
|
||||
{
|
||||
g_return_if_fail (value->class == >K_CSS_VALUE_BG_SIZE);
|
||||
|
||||
if (value->contain || value->cover)
|
||||
gtk_css_bg_size_compute_size_for_cover_contain (value->cover,
|
||||
image,
|
||||
area_width, area_height,
|
||||
out_width, out_height);
|
||||
else
|
||||
_gtk_css_image_get_concrete_size (image,
|
||||
/* note: 0 does the right thing here for 'auto' */
|
||||
value->x ? _gtk_css_number_value_get (value->x, area_width) : 0,
|
||||
value->y ? _gtk_css_number_value_get (value->y, area_height) : 0,
|
||||
area_width, area_height,
|
||||
out_width, out_height);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_bg_size_value_compute (GtkCssValue *value,
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_BG_SIZE, NULL);
|
||||
|
||||
if (value->x == NULL && value->y == NULL)
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
return _gtk_css_bg_size_value_new (value->x ? _gtk_css_number_value_compute (value->x, context) : NULL,
|
||||
value->y ? _gtk_css_number_value_compute (value->y, context) : NULL);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_BG_SIZE_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_BG_SIZE_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcssimageprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_bg_size_value_new (GtkCssValue *x,
|
||||
GtkCssValue *y);
|
||||
GtkCssValue * _gtk_css_bg_size_value_parse (GtkCssParser *parser);
|
||||
|
||||
void _gtk_css_bg_size_value_compute_size (const GtkCssValue *bg_size,
|
||||
GtkCssImage *image,
|
||||
double area_width,
|
||||
double area_height,
|
||||
double *out_width,
|
||||
double *out_height);
|
||||
GtkCssValue * _gtk_css_bg_size_value_compute (GtkCssValue *bg_size,
|
||||
GtkStyleContext *context);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_BG_SIZE_VALUE_PRIVATE_H__ */
|
||||
@@ -0,0 +1,235 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssbordervalueprivate.h"
|
||||
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
guint fill :1;
|
||||
GtkCssValue *values[4];
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_border_free (GtkCssValue *value)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (value->values[i])
|
||||
_gtk_css_value_unref (value->values[i]);
|
||||
}
|
||||
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_border_equal (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (value1->fill != value2->fill)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (!_gtk_css_value_equal0 (value1->values[i], value2->values[i]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_border_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_border_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
guint i, n;
|
||||
|
||||
if (!_gtk_css_value_equal0 (value->values[GTK_CSS_RIGHT], value->values[GTK_CSS_LEFT]))
|
||||
n = 4;
|
||||
else if (!_gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_BOTTOM]))
|
||||
n = 3;
|
||||
else if (!_gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_RIGHT]))
|
||||
n = 2;
|
||||
else
|
||||
n = 1;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append_c (string, ' ');
|
||||
|
||||
if (value->values[i] == NULL)
|
||||
g_string_append (string, "auto");
|
||||
else
|
||||
_gtk_css_value_print (value->values[i], string);
|
||||
}
|
||||
|
||||
if (value->fill)
|
||||
g_string_append (string, " fill");
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_BORDER = {
|
||||
gtk_css_value_border_free,
|
||||
gtk_css_value_border_equal,
|
||||
gtk_css_value_border_transition,
|
||||
gtk_css_value_border_print
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_value_new (GtkCssValue *top,
|
||||
GtkCssValue *right,
|
||||
GtkCssValue *bottom,
|
||||
GtkCssValue *left)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_BORDER);
|
||||
result->values[GTK_CSS_TOP] = top;
|
||||
result->values[GTK_CSS_RIGHT] = right;
|
||||
result->values[GTK_CSS_BOTTOM] = bottom;
|
||||
result->values[GTK_CSS_LEFT] = left;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
gboolean allow_auto,
|
||||
gboolean allow_fill)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
guint i;
|
||||
|
||||
result = _gtk_css_border_value_new (NULL, NULL, NULL, NULL);
|
||||
|
||||
if (allow_fill)
|
||||
result->fill = _gtk_css_parser_try (parser, "fill", TRUE);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (allow_auto && _gtk_css_parser_try (parser, "auto", TRUE))
|
||||
continue;
|
||||
|
||||
if (!_gtk_css_parser_has_number (parser))
|
||||
break;
|
||||
|
||||
result->values[i] = _gtk_css_number_value_parse (parser, flags);
|
||||
if (result->values[i] == NULL)
|
||||
{
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a number");
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (allow_fill && !result->fill)
|
||||
result->fill = _gtk_css_parser_try (parser, "fill", TRUE);
|
||||
|
||||
for (; i < 4; i++)
|
||||
{
|
||||
if (result->values[(i - 1) >> 1])
|
||||
result->values[i] = _gtk_css_value_ref (result->values[(i - 1) >> 1]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_value_get_top (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_BORDER, NULL);
|
||||
|
||||
return value->values[GTK_CSS_TOP];
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_value_get_right (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_BORDER, NULL);
|
||||
|
||||
return value->values[GTK_CSS_RIGHT];
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_value_get_bottom (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_BORDER, NULL);
|
||||
|
||||
return value->values[GTK_CSS_BOTTOM];
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_value_get_left (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_BORDER, NULL);
|
||||
|
||||
return value->values[GTK_CSS_LEFT];
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_value_compute (GtkCssValue *value,
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
GtkCssValue *computed;
|
||||
gboolean changed = FALSE;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_BORDER, NULL);
|
||||
|
||||
computed = _gtk_css_border_value_new (NULL, NULL, NULL, NULL);
|
||||
computed->fill = value->fill;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (value->values[i])
|
||||
{
|
||||
computed->values[i] = _gtk_css_number_value_compute (value->values[i], context);
|
||||
changed |= (computed->values[i] != value->values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!changed)
|
||||
{
|
||||
_gtk_css_value_unref (computed);
|
||||
return _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
return computed;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_BORDER_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_BORDER_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_border_value_new (GtkCssValue *top,
|
||||
GtkCssValue *right,
|
||||
GtkCssValue *bottom,
|
||||
GtkCssValue *left);
|
||||
GtkCssValue * _gtk_css_border_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
gboolean allow_auto,
|
||||
gboolean allow_fill);
|
||||
|
||||
GtkCssValue * _gtk_css_border_value_get_top (const GtkCssValue *value);
|
||||
GtkCssValue * _gtk_css_border_value_get_right (const GtkCssValue *value);
|
||||
GtkCssValue * _gtk_css_border_value_get_bottom (const GtkCssValue *value);
|
||||
GtkCssValue * _gtk_css_border_value_get_left (const GtkCssValue *value);
|
||||
|
||||
GtkCssValue * _gtk_css_border_value_compute (GtkCssValue *border,
|
||||
GtkStyleContext *context);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_BORDER_VALUE_PRIVATE_H__ */
|
||||
+49
-46
@@ -21,9 +21,9 @@
|
||||
|
||||
#include "gtkcsscomputedvaluesprivate.h"
|
||||
|
||||
#include "gtkcssinheritvalueprivate.h"
|
||||
#include "gtkcssinitialvalueprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
#include "gtkprivatetypebuiltins.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssComputedValues, _gtk_css_computed_values, G_TYPE_OBJECT)
|
||||
|
||||
@@ -73,6 +73,16 @@ maybe_unref_section (gpointer section)
|
||||
gtk_css_section_unref (section);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_computed_values_ensure_array (GtkCssComputedValues *values,
|
||||
guint at_least_size)
|
||||
{
|
||||
if (values->values == NULL)
|
||||
values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
|
||||
if (at_least_size > values->values->len)
|
||||
g_ptr_array_set_size (values->values, at_least_size);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
|
||||
GtkStyleContext *context,
|
||||
@@ -89,10 +99,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
|
||||
prop = _gtk_css_style_property_lookup_by_id (id);
|
||||
parent = gtk_style_context_get_parent (context);
|
||||
|
||||
if (values->values == NULL)
|
||||
values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
|
||||
if (id <= values->values->len)
|
||||
g_ptr_array_set_size (values->values, id + 1);
|
||||
gtk_css_computed_values_ensure_array (values, id + 1);
|
||||
|
||||
/* http://www.w3.org/TR/css3-cascade/#cascade
|
||||
* Then, for every element, the value for each property can be found
|
||||
@@ -101,26 +108,19 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
|
||||
*/
|
||||
if (specified != NULL)
|
||||
{
|
||||
if (_gtk_css_value_is_special (specified))
|
||||
if (_gtk_css_value_is_inherit (specified))
|
||||
{
|
||||
switch (_gtk_css_value_get_special_kind (specified))
|
||||
{
|
||||
case GTK_CSS_INHERIT:
|
||||
/* 3) if the value of the winning declaration is ‘inherit’,
|
||||
* the inherited value (see below) becomes the specified value.
|
||||
*/
|
||||
specified = NULL;
|
||||
break;
|
||||
case GTK_CSS_INITIAL:
|
||||
/* if the value of the winning declaration is ‘initial’,
|
||||
* the initial value (see below) becomes the specified value.
|
||||
*/
|
||||
specified = _gtk_css_style_property_get_initial_value (prop);
|
||||
break;
|
||||
default:
|
||||
/* This is part of (2) above */
|
||||
break;
|
||||
}
|
||||
/* 3) if the value of the winning declaration is ‘inherit’,
|
||||
* the inherited value (see below) becomes the specified value.
|
||||
*/
|
||||
specified = NULL;
|
||||
}
|
||||
else if (_gtk_css_value_is_initial (specified))
|
||||
{
|
||||
/* if the value of the winning declaration is ‘initial’,
|
||||
* the initial value (see below) becomes the specified value.
|
||||
*/
|
||||
specified = _gtk_css_style_property_get_initial_value (prop);
|
||||
}
|
||||
|
||||
/* 2) If the cascading process (described below) yields a winning
|
||||
@@ -164,8 +164,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
|
||||
{
|
||||
GtkCssValue *parent_value;
|
||||
/* Set NULL here and do the inheritance upon lookup? */
|
||||
parent_value = _gtk_style_context_peek_property (parent,
|
||||
_gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)));
|
||||
parent_value = _gtk_style_context_peek_property (parent, id);
|
||||
|
||||
g_ptr_array_index (values->values, id) = _gtk_css_value_ref (parent_value);
|
||||
}
|
||||
@@ -189,10 +188,7 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
|
||||
{
|
||||
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
|
||||
|
||||
if (values->values == NULL)
|
||||
values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
|
||||
if (id <= values->values->len)
|
||||
g_ptr_array_set_size (values->values, id + 1);
|
||||
gtk_css_computed_values_ensure_array (values, id + 1);
|
||||
|
||||
if (g_ptr_array_index (values->values, id))
|
||||
_gtk_css_value_unref (g_ptr_array_index (values->values, id));
|
||||
@@ -222,21 +218,6 @@ _gtk_css_computed_values_get_value (GtkCssComputedValues *values,
|
||||
return g_ptr_array_index (values->values, id);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_computed_values_get_value_by_name (GtkCssComputedValues *values,
|
||||
const char *name)
|
||||
{
|
||||
GtkStyleProperty *prop;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
prop = _gtk_style_property_lookup (name);
|
||||
g_assert (GTK_IS_CSS_STYLE_PROPERTY (prop));
|
||||
|
||||
return _gtk_css_computed_values_get_value (values, _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)));
|
||||
}
|
||||
|
||||
GtkCssSection *
|
||||
_gtk_css_computed_values_get_section (GtkCssComputedValues *values,
|
||||
guint id)
|
||||
@@ -250,3 +231,25 @@ _gtk_css_computed_values_get_section (GtkCssComputedValues *values,
|
||||
return g_ptr_array_index (values->sections, id);
|
||||
}
|
||||
|
||||
GtkBitmask *
|
||||
_gtk_css_computed_values_get_difference (GtkCssComputedValues *values,
|
||||
GtkCssComputedValues *other)
|
||||
{
|
||||
GtkBitmask *result;
|
||||
guint i, len;
|
||||
|
||||
len = MIN (values->values->len, other->values->len);
|
||||
result = _gtk_bitmask_new ();
|
||||
if (values->values->len != other->values->len)
|
||||
result = _gtk_bitmask_invert_range (result, len, MAX (values->values->len, other->values->len));
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (!_gtk_css_value_equal (g_ptr_array_index (values->values, i),
|
||||
g_ptr_array_index (other->values, i)))
|
||||
result = _gtk_bitmask_set (result, i, TRUE);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "gtk/gtkbitmaskprivate.h"
|
||||
#include "gtk/gtkcsssection.h"
|
||||
#include "gtk/gtkstylecontext.h"
|
||||
#include "gtk/gtkcssvalueprivate.h"
|
||||
@@ -67,10 +68,10 @@ void _gtk_css_computed_values_set_value (GtkCssCom
|
||||
|
||||
GtkCssValue * _gtk_css_computed_values_get_value (GtkCssComputedValues *values,
|
||||
guint id);
|
||||
GtkCssValue * _gtk_css_computed_values_get_value_by_name (GtkCssComputedValues *values,
|
||||
const char *name);
|
||||
GtkCssSection * _gtk_css_computed_values_get_section (GtkCssComputedValues *values,
|
||||
guint id);
|
||||
GtkBitmask * _gtk_css_computed_values_get_difference (GtkCssComputedValues *values,
|
||||
GtkCssComputedValues *other);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcsscornervalueprivate.h"
|
||||
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
GtkCssValue *x;
|
||||
GtkCssValue *y;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_corner_free (GtkCssValue *value)
|
||||
{
|
||||
_gtk_css_value_unref (value->x);
|
||||
_gtk_css_value_unref (value->y);
|
||||
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_corner_equal (const GtkCssValue *corner1,
|
||||
const GtkCssValue *corner2)
|
||||
{
|
||||
return _gtk_css_value_equal (corner1->x, corner2->x)
|
||||
&& _gtk_css_value_equal (corner1->y, corner2->y);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_corner_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
x = _gtk_css_value_transition (start->x, end->x, progress);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
y = _gtk_css_value_transition (start->y, end->y, progress);
|
||||
if (y == NULL)
|
||||
{
|
||||
_gtk_css_value_unref (x);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _gtk_css_corner_value_new (x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_corner_print (const GtkCssValue *corner,
|
||||
GString *string)
|
||||
{
|
||||
_gtk_css_value_print (corner->x, string);
|
||||
if (!_gtk_css_value_equal (corner->x, corner->y))
|
||||
{
|
||||
g_string_append_c (string, ' ');
|
||||
_gtk_css_value_print (corner->y, string);
|
||||
}
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_CORNER = {
|
||||
gtk_css_value_corner_free,
|
||||
gtk_css_value_corner_equal,
|
||||
gtk_css_value_corner_transition,
|
||||
gtk_css_value_corner_print
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_corner_value_new (GtkCssValue *x,
|
||||
GtkCssValue *y)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_CORNER);
|
||||
result->x = x;
|
||||
result->y = y;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_corner_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
x = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_NUMBER_AS_PIXELS
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!_gtk_css_parser_has_number (parser))
|
||||
y = _gtk_css_value_ref (x);
|
||||
else
|
||||
{
|
||||
y = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_NUMBER_AS_PIXELS
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (y == NULL)
|
||||
{
|
||||
_gtk_css_value_unref (x);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return _gtk_css_corner_value_new (x, y);
|
||||
}
|
||||
|
||||
double
|
||||
_gtk_css_corner_value_get_x (const GtkCssValue *corner,
|
||||
double one_hundred_percent)
|
||||
{
|
||||
g_return_val_if_fail (corner != NULL, 0.0);
|
||||
g_return_val_if_fail (corner->class == >K_CSS_VALUE_CORNER, 0.0);
|
||||
|
||||
return _gtk_css_number_value_get (corner->x, one_hundred_percent);
|
||||
}
|
||||
|
||||
double
|
||||
_gtk_css_corner_value_get_y (const GtkCssValue *corner,
|
||||
double one_hundred_percent)
|
||||
{
|
||||
g_return_val_if_fail (corner != NULL, 0.0);
|
||||
g_return_val_if_fail (corner->class == >K_CSS_VALUE_CORNER, 0.0);
|
||||
|
||||
return _gtk_css_number_value_get (corner->y, one_hundred_percent);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_corner_value_compute (GtkCssValue *corner,
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
g_return_val_if_fail (corner->class == >K_CSS_VALUE_CORNER, NULL);
|
||||
|
||||
x = _gtk_css_number_value_compute (corner->x, context);
|
||||
y = _gtk_css_number_value_compute (corner->y, context);
|
||||
if (x == corner->x && y == corner->y)
|
||||
{
|
||||
_gtk_css_value_unref (x);
|
||||
_gtk_css_value_unref (y);
|
||||
return _gtk_css_value_ref (corner);
|
||||
}
|
||||
|
||||
return _gtk_css_corner_value_new (x, y);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_CORNER_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_CORNER_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_corner_value_new (GtkCssValue *x,
|
||||
GtkCssValue *y);
|
||||
GtkCssValue * _gtk_css_corner_value_parse (GtkCssParser *parser);
|
||||
|
||||
double _gtk_css_corner_value_get_x (const GtkCssValue *corner,
|
||||
double one_hundred_percent);
|
||||
double _gtk_css_corner_value_get_y (const GtkCssValue *corner,
|
||||
double one_hundred_percent);
|
||||
GtkCssValue * _gtk_css_corner_value_compute (GtkCssValue *corner,
|
||||
GtkStyleContext *context);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_CORNER_VALUE_PRIVATE_H__ */
|
||||
+75
-13
@@ -24,17 +24,29 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gtkcssstylefuncsprivate.h"
|
||||
#include "gtkcsstypedvalueprivate.h"
|
||||
#include "gtkstylepropertiesprivate.h"
|
||||
#include "gtkthemingengine.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssCustomProperty, _gtk_css_custom_property, GTK_TYPE_CSS_STYLE_PROPERTY)
|
||||
|
||||
static gboolean
|
||||
static GType
|
||||
gtk_css_custom_property_get_specified_type (GParamSpec *pspec)
|
||||
{
|
||||
if (pspec->value_type == GDK_TYPE_RGBA ||
|
||||
pspec->value_type == GDK_TYPE_COLOR)
|
||||
return GTK_TYPE_SYMBOLIC_COLOR;
|
||||
else
|
||||
return pspec->value_type;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_custom_property_parse_value (GtkStyleProperty *property,
|
||||
GValue *value,
|
||||
GtkCssParser *parser,
|
||||
GFile *base)
|
||||
{
|
||||
GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (property);
|
||||
GValue value = G_VALUE_INIT;
|
||||
gboolean success;
|
||||
|
||||
if (custom->property_parse_func)
|
||||
@@ -42,12 +54,12 @@ gtk_css_custom_property_parse_value (GtkStyleProperty *property,
|
||||
GError *error = NULL;
|
||||
char *value_str;
|
||||
|
||||
g_value_init (value, _gtk_style_property_get_value_type (property));
|
||||
g_value_init (&value, _gtk_style_property_get_value_type (property));
|
||||
|
||||
value_str = _gtk_css_parser_read_value (parser);
|
||||
if (value_str != NULL)
|
||||
{
|
||||
success = (* custom->property_parse_func) (value_str, value, &error);
|
||||
success = (* custom->property_parse_func) (value_str, &value, &error);
|
||||
g_free (value_str);
|
||||
}
|
||||
else
|
||||
@@ -55,16 +67,50 @@ gtk_css_custom_property_parse_value (GtkStyleProperty *property,
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkCssStyleProperty *style = GTK_CSS_STYLE_PROPERTY (property);
|
||||
g_value_init (value, _gtk_css_style_property_get_specified_type (style));
|
||||
g_value_init (&value, gtk_css_custom_property_get_specified_type (custom->pspec));
|
||||
|
||||
success = _gtk_css_style_parse_value (value, parser, base);
|
||||
success = _gtk_css_style_parse_value (&value, parser, base);
|
||||
}
|
||||
|
||||
if (!success)
|
||||
g_value_unset (value);
|
||||
{
|
||||
g_value_unset (&value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return success;
|
||||
return _gtk_css_typed_value_new_take (&value);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_custom_property_query (GtkStyleProperty *property,
|
||||
GValue *value,
|
||||
GtkStyleQueryFunc query_func,
|
||||
gpointer query_data)
|
||||
{
|
||||
GtkCssStyleProperty *style = GTK_CSS_STYLE_PROPERTY (property);
|
||||
GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (property);
|
||||
GtkCssValue *css_value;
|
||||
|
||||
css_value = (* query_func) (_gtk_css_style_property_get_id (style), query_data);
|
||||
if (css_value == NULL)
|
||||
css_value = _gtk_css_style_property_get_initial_value (style);
|
||||
|
||||
g_value_init (value, custom->pspec->value_type);
|
||||
g_value_copy (_gtk_css_typed_value_get (css_value), value);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_custom_property_assign (GtkStyleProperty *property,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
const GValue *value)
|
||||
{
|
||||
GtkCssValue *css_value = _gtk_css_typed_value_new (value);
|
||||
_gtk_style_properties_set_property_by_property (props,
|
||||
GTK_CSS_STYLE_PROPERTY (property),
|
||||
state,
|
||||
css_value);
|
||||
_gtk_css_value_unref (css_value);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -73,18 +119,33 @@ _gtk_css_custom_property_class_init (GtkCssCustomPropertyClass *klass)
|
||||
GtkStylePropertyClass *property_class = GTK_STYLE_PROPERTY_CLASS (klass);
|
||||
|
||||
property_class->parse_value = gtk_css_custom_property_parse_value;
|
||||
property_class->query = gtk_css_custom_property_query;
|
||||
property_class->assign = gtk_css_custom_property_assign;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_custom_property_compute_value (GtkCssStyleProperty *property,
|
||||
GtkStyleContext *context,
|
||||
GtkCssValue *specified)
|
||||
{
|
||||
GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (property);
|
||||
|
||||
return _gtk_css_style_compute_value (context, custom->pspec->value_type, specified);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_custom_property_init (GtkCssCustomProperty *custom_property)
|
||||
_gtk_css_custom_property_init (GtkCssCustomProperty *custom)
|
||||
{
|
||||
GtkCssStyleProperty *style = GTK_CSS_STYLE_PROPERTY (custom);
|
||||
|
||||
style->compute_value = gtk_css_custom_property_compute_value;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
GtkCssValue *result;
|
||||
|
||||
g_value_init (&value, pspec->value_type);
|
||||
|
||||
@@ -111,7 +172,10 @@ gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
|
||||
else
|
||||
g_param_value_set_default (pspec, &value);
|
||||
|
||||
return _gtk_css_value_new_take_gvalue (&value);
|
||||
result = _gtk_css_typed_value_new (&value);
|
||||
g_value_unset (&value);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Property registration functions */
|
||||
@@ -184,7 +248,6 @@ gtk_theming_engine_register_property (const gchar *name_space,
|
||||
node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
|
||||
"initial-value", initial,
|
||||
"name", name,
|
||||
"computed-type", pspec->value_type,
|
||||
"value-type", pspec->value_type,
|
||||
NULL);
|
||||
node->pspec = pspec;
|
||||
@@ -227,7 +290,6 @@ gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
|
||||
node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
|
||||
"initial-value", initial,
|
||||
"name", pspec->name,
|
||||
"computed-type", pspec->value_type,
|
||||
"value-type", pspec->value_type,
|
||||
NULL);
|
||||
node->pspec = pspec;
|
||||
|
||||
@@ -0,0 +1,370 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcsseasevalueprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
typedef enum {
|
||||
GTK_CSS_EASE_CUBIC_BEZIER,
|
||||
GTK_CSS_EASE_STEPS
|
||||
} GtkCssEaseType;
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
GtkCssEaseType type;
|
||||
union {
|
||||
struct {
|
||||
double x1;
|
||||
double y1;
|
||||
double x2;
|
||||
double y2;
|
||||
} cubic;
|
||||
struct {
|
||||
guint steps;
|
||||
gboolean start;
|
||||
} steps;
|
||||
} u;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_ease_free (GtkCssValue *value)
|
||||
{
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_ease_equal (const GtkCssValue *ease1,
|
||||
const GtkCssValue *ease2)
|
||||
{
|
||||
if (ease1->type != ease2->type)
|
||||
return FALSE;
|
||||
|
||||
switch (ease1->type)
|
||||
{
|
||||
case GTK_CSS_EASE_CUBIC_BEZIER:
|
||||
return ease1->u.cubic.x1 == ease2->u.cubic.x1 &&
|
||||
ease1->u.cubic.y1 == ease2->u.cubic.y1 &&
|
||||
ease1->u.cubic.x2 == ease2->u.cubic.x2 &&
|
||||
ease1->u.cubic.y2 == ease2->u.cubic.y2;
|
||||
case GTK_CSS_EASE_STEPS:
|
||||
return ease1->u.steps.steps == ease2->u.steps.steps &&
|
||||
ease1->u.steps.start == ease2->u.steps.start;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_ease_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_ease_print (const GtkCssValue *ease,
|
||||
GString *string)
|
||||
{
|
||||
switch (ease->type)
|
||||
{
|
||||
case GTK_CSS_EASE_CUBIC_BEZIER:
|
||||
if (ease->u.cubic.x1 == 0.25 && ease->u.cubic.y1 == 0.1 &&
|
||||
ease->u.cubic.x2 == 0.25 && ease->u.cubic.y2 == 1.0)
|
||||
g_string_append (string, "ease");
|
||||
else if (ease->u.cubic.x1 == 0.0 && ease->u.cubic.y1 == 0.0 &&
|
||||
ease->u.cubic.x2 == 1.0 && ease->u.cubic.y2 == 1.0)
|
||||
g_string_append (string, "linear");
|
||||
else if (ease->u.cubic.x1 == 0.42 && ease->u.cubic.y1 == 0.0 &&
|
||||
ease->u.cubic.x2 == 1.0 && ease->u.cubic.y2 == 1.0)
|
||||
g_string_append (string, "ease-in");
|
||||
else if (ease->u.cubic.x1 == 0.0 && ease->u.cubic.y1 == 0.0 &&
|
||||
ease->u.cubic.x2 == 0.58 && ease->u.cubic.y2 == 1.0)
|
||||
g_string_append (string, "ease-out");
|
||||
else if (ease->u.cubic.x1 == 0.42 && ease->u.cubic.y1 == 0.0 &&
|
||||
ease->u.cubic.x2 == 0.58 && ease->u.cubic.y2 == 1.0)
|
||||
g_string_append (string, "ease-in-out");
|
||||
else
|
||||
g_string_append_printf (string, "cubic-bezier(%g,%g,%g,%g)",
|
||||
ease->u.cubic.x1, ease->u.cubic.y1,
|
||||
ease->u.cubic.x2, ease->u.cubic.y2);
|
||||
break;
|
||||
case GTK_CSS_EASE_STEPS:
|
||||
if (ease->u.steps.steps == 1)
|
||||
{
|
||||
g_string_append (string, ease->u.steps.start ? "step-start" : "step-end");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_append_printf (string, "steps(%u%s)", ease->u.steps.steps, ease->u.steps.start ? ",start" : "");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_EASE = {
|
||||
gtk_css_value_ease_free,
|
||||
gtk_css_value_ease_equal,
|
||||
gtk_css_value_ease_transition,
|
||||
gtk_css_value_ease_print
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_ease_value_new_cubic_bezier (double x1,
|
||||
double y1,
|
||||
double x2,
|
||||
double y2)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
g_return_val_if_fail (x1 >= 0.0, NULL);
|
||||
g_return_val_if_fail (x1 <= 1.0, NULL);
|
||||
g_return_val_if_fail (x2 >= 0.0, NULL);
|
||||
g_return_val_if_fail (x2 <= 1.0, NULL);
|
||||
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_EASE);
|
||||
|
||||
value->type = GTK_CSS_EASE_CUBIC_BEZIER;
|
||||
value->u.cubic.x1 = x1;
|
||||
value->u.cubic.y1 = y1;
|
||||
value->u.cubic.x2 = x2;
|
||||
value->u.cubic.y2 = y2;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
_gtk_css_ease_value_new_steps (guint n_steps,
|
||||
gboolean start)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
g_return_val_if_fail (n_steps > 0, NULL);
|
||||
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_EASE);
|
||||
|
||||
value->type = GTK_CSS_EASE_STEPS;
|
||||
value->u.steps.steps = n_steps;
|
||||
value->u.steps.start = start;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
guint is_bezier :1;
|
||||
guint needs_custom :1;
|
||||
double values[4];
|
||||
} parser_values[] = {
|
||||
{ "linear", TRUE, FALSE, { 0.0, 0.0, 1.0, 1.0 } },
|
||||
{ "ease-in-out", TRUE, FALSE, { 0.42, 0.0, 0.58, 1.0 } },
|
||||
{ "ease-in", TRUE, FALSE, { 0.42, 0.0, 1.0, 1.0 } },
|
||||
{ "ease-out", TRUE, FALSE, { 0.0, 0.0, 0.58, 1.0 } },
|
||||
{ "ease", TRUE, FALSE, { 0.25, 0.1, 0.25, 1.0 } },
|
||||
{ "step-start", FALSE, FALSE, { 1.0, 1.0, 0.0, 0.0 } },
|
||||
{ "step-end", FALSE, FALSE, { 1.0, 0.0, 0.0, 0.0 } },
|
||||
{ "steps", FALSE, TRUE, { 0.0, 0.0, 0.0, 0.0 } },
|
||||
{ "cubic-bezier", TRUE, TRUE, { 0.0, 0.0, 0.0, 0.0 } }
|
||||
};
|
||||
|
||||
gboolean
|
||||
_gtk_css_ease_value_can_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (parser_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_has_prefix (parser, parser_values[i].name))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_ease_value_parse_cubic_bezier (GtkCssParser *parser)
|
||||
{
|
||||
double values[4];
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (!_gtk_css_parser_try (parser, i ? "," : "(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected '%s'", i ? "," : "(");
|
||||
return NULL;
|
||||
}
|
||||
if (!_gtk_css_parser_try_double (parser, &values[i]))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a number");
|
||||
return NULL;
|
||||
}
|
||||
if ((i == 0 || i == 2) &&
|
||||
(values[i] < 0 || values[i] > 1.0))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "value %g out of range. Must be from 0.0 to 1.0", values[i]);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Missing closing ')' for cubic-bezier");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _gtk_css_ease_value_new_cubic_bezier (values[0], values[1], values[2], values[3]);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_ease_value_parse_steps (GtkCssParser *parser)
|
||||
{
|
||||
guint n_steps;
|
||||
gboolean start;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, "(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected '('");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_uint (parser, &n_steps))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected number of steps");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, "start", TRUE))
|
||||
start = TRUE;
|
||||
else if (_gtk_css_parser_try (parser, "end", TRUE))
|
||||
start = FALSE;
|
||||
else
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Only allowed values are 'start' and 'end'");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
start = FALSE;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Missing closing ')' for steps");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _gtk_css_ease_value_new_steps (n_steps, start);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_ease_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (parser_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, parser_values[i].name, FALSE))
|
||||
{
|
||||
if (parser_values[i].needs_custom)
|
||||
{
|
||||
if (parser_values[i].is_bezier)
|
||||
return gtk_css_ease_value_parse_cubic_bezier (parser);
|
||||
else
|
||||
return gtk_css_ease_value_parse_steps (parser);
|
||||
}
|
||||
|
||||
_gtk_css_parser_skip_whitespace (parser);
|
||||
|
||||
if (parser_values[i].is_bezier)
|
||||
return _gtk_css_ease_value_new_cubic_bezier (parser_values[i].values[0],
|
||||
parser_values[i].values[1],
|
||||
parser_values[i].values[2],
|
||||
parser_values[i].values[3]);
|
||||
else
|
||||
return _gtk_css_ease_value_new_steps (parser_values[i].values[0],
|
||||
parser_values[i].values[1] != 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
_gtk_css_parser_error (parser, "Unknown value");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
double
|
||||
_gtk_css_ease_value_transform (const GtkCssValue *ease,
|
||||
double progress)
|
||||
{
|
||||
g_return_val_if_fail (ease->class == >K_CSS_VALUE_EASE, 1.0);
|
||||
|
||||
if (progress <= 0)
|
||||
return 0;
|
||||
if (progress >= 1)
|
||||
return 1;
|
||||
|
||||
switch (ease->type)
|
||||
{
|
||||
case GTK_CSS_EASE_CUBIC_BEZIER:
|
||||
{
|
||||
static const double epsilon = 0.00001;
|
||||
double tmin, t, tmax;
|
||||
|
||||
tmin = 0.0;
|
||||
tmax = 1.0;
|
||||
t = progress;
|
||||
|
||||
while (tmin < tmax)
|
||||
{
|
||||
double sample;
|
||||
sample = (((1.0 + 3 * ease->u.cubic.x1 - 3 * ease->u.cubic.x2) * t
|
||||
+ -6 * ease->u.cubic.x1 + 3 * ease->u.cubic.x2) * t
|
||||
+ 3 * ease->u.cubic.x1 ) * t;
|
||||
if (fabs(sample - progress) < epsilon)
|
||||
break;
|
||||
|
||||
if (progress > sample)
|
||||
tmin = t;
|
||||
else
|
||||
tmax = t;
|
||||
t = (tmax + tmin) * .5;
|
||||
}
|
||||
|
||||
return (((1.0 + 3 * ease->u.cubic.y1 - 3 * ease->u.cubic.y2) * t
|
||||
+ -6 * ease->u.cubic.y1 + 3 * ease->u.cubic.y2) * t
|
||||
+ 3 * ease->u.cubic.y1 ) * t;
|
||||
}
|
||||
case GTK_CSS_EASE_STEPS:
|
||||
progress *= ease->u.steps.steps;
|
||||
progress = floor (progress) + ease->u.steps.start ? 0 : 1;
|
||||
return progress / ease->u.steps.steps;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_EASE_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_EASE_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_ease_value_new_cubic_bezier (double x1,
|
||||
double y1,
|
||||
double x2,
|
||||
double y2);
|
||||
gboolean _gtk_css_ease_value_can_parse (GtkCssParser *parser);
|
||||
GtkCssValue * _gtk_css_ease_value_parse (GtkCssParser *parser);
|
||||
|
||||
double _gtk_css_ease_value_transform (const GtkCssValue *ease,
|
||||
double progress);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_EASE_VALUE_PRIVATE_H__ */
|
||||
@@ -0,0 +1,127 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssenginevalueprivate.h"
|
||||
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
GtkThemingEngine *engine;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_engine_free (GtkCssValue *value)
|
||||
{
|
||||
g_object_unref (value->engine);
|
||||
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_engine_equal (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
return value1->engine == value2->engine;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_engine_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_engine_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
char *name;
|
||||
|
||||
g_object_get (value->engine, "name", &name, NULL);
|
||||
|
||||
if (name)
|
||||
g_string_append (string, name);
|
||||
else
|
||||
g_string_append (string, "none");
|
||||
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_ENGINE = {
|
||||
gtk_css_value_engine_free,
|
||||
gtk_css_value_engine_equal,
|
||||
gtk_css_value_engine_transition,
|
||||
gtk_css_value_engine_print
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_engine_value_new (GtkThemingEngine *engine)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
|
||||
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_ENGINE);
|
||||
result->engine = g_object_ref (engine);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_engine_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
GtkThemingEngine *engine;
|
||||
char *str;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
if (_gtk_css_parser_try (parser, "none", TRUE))
|
||||
return _gtk_css_engine_value_new (gtk_theming_engine_load (NULL));
|
||||
|
||||
str = _gtk_css_parser_try_ident (parser, TRUE);
|
||||
if (str == NULL)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a valid theme name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
engine = gtk_theming_engine_load (str);
|
||||
|
||||
if (engine == NULL)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Theming engine '%s' not found", str);
|
||||
g_free (str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_free (str);
|
||||
|
||||
return _gtk_css_engine_value_new (engine);
|
||||
}
|
||||
|
||||
GtkThemingEngine *
|
||||
_gtk_css_engine_value_get_engine (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_ENGINE, NULL);
|
||||
|
||||
return value->engine;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_ENGINE_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_ENGINE_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
#include "gtkthemingengine.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_engine_value_new (GtkThemingEngine *engine);
|
||||
GtkCssValue * _gtk_css_engine_value_parse (GtkCssParser *parser);
|
||||
|
||||
GtkThemingEngine * _gtk_css_engine_value_get_engine (const GtkCssValue *engine);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_ENGINE_VALUE_PRIVATE_H__ */
|
||||
@@ -0,0 +1,323 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
|
||||
/* repeated API */
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
int value;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_enum_free (GtkCssValue *value)
|
||||
{
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_enum_equal (const GtkCssValue *enum1,
|
||||
const GtkCssValue *enum2)
|
||||
{
|
||||
return enum1 == enum2;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_enum_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_enum_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, value->name);
|
||||
}
|
||||
|
||||
/* GtkBorderStyle */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_BORDER_STYLE = {
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_equal,
|
||||
gtk_css_value_enum_transition,
|
||||
gtk_css_value_enum_print
|
||||
};
|
||||
|
||||
static GtkCssValue border_style_values[] = {
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_NONE, "none" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_SOLID, "solid" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_INSET, "inset" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_OUTSET, "outset" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_HIDDEN, "hidden" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_DOTTED, "dotted" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_DASHED, "dashed" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_DOUBLE, "double" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_GROOVE, "groove" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_RIDGE, "ridge" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_style_value_new (GtkBorderStyle border_style)
|
||||
{
|
||||
g_return_val_if_fail (border_style < G_N_ELEMENTS (border_style_values), NULL);
|
||||
|
||||
return _gtk_css_value_ref (&border_style_values[border_style]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_border_style_value_try_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (border_style_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, border_style_values[i].name, TRUE))
|
||||
return _gtk_css_value_ref (&border_style_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkBorderStyle
|
||||
_gtk_css_border_style_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_BORDER_STYLE, GTK_BORDER_STYLE_NONE);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* PangoStyle */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_equal,
|
||||
gtk_css_value_enum_transition,
|
||||
gtk_css_value_enum_print
|
||||
};
|
||||
|
||||
static GtkCssValue font_style_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, PANGO_STYLE_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, PANGO_STYLE_OBLIQUE, "oblique" },
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, PANGO_STYLE_ITALIC, "italic" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_font_style_value_new (PangoStyle font_style)
|
||||
{
|
||||
g_return_val_if_fail (font_style < G_N_ELEMENTS (font_style_values), NULL);
|
||||
|
||||
return _gtk_css_value_ref (&font_style_values[font_style]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_font_style_value_try_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (font_style_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, font_style_values[i].name, TRUE))
|
||||
return _gtk_css_value_ref (&font_style_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PangoStyle
|
||||
_gtk_css_font_style_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_FONT_STYLE, PANGO_STYLE_NORMAL);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* PangoVariant */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT = {
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_equal,
|
||||
gtk_css_value_enum_transition,
|
||||
gtk_css_value_enum_print
|
||||
};
|
||||
|
||||
static GtkCssValue font_variant_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_VARIANT, 1, PANGO_VARIANT_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT, 1, PANGO_VARIANT_SMALL_CAPS, "small-caps" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_font_variant_value_new (PangoVariant font_variant)
|
||||
{
|
||||
g_return_val_if_fail (font_variant < G_N_ELEMENTS (font_variant_values), NULL);
|
||||
|
||||
return _gtk_css_value_ref (&font_variant_values[font_variant]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_font_variant_value_try_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (font_variant_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, font_variant_values[i].name, TRUE))
|
||||
return _gtk_css_value_ref (&font_variant_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PangoVariant
|
||||
_gtk_css_font_variant_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_FONT_VARIANT, PANGO_VARIANT_NORMAL);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* PangoWeight */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_FONT_WEIGHT = {
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_equal,
|
||||
gtk_css_value_enum_transition,
|
||||
gtk_css_value_enum_print
|
||||
};
|
||||
|
||||
static GtkCssValue font_weight_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_THIN, "100" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_ULTRALIGHT, "200" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_LIGHT, "300" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_MEDIUM, "500" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_SEMIBOLD, "600" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_BOLD, "bold" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_ULTRABOLD, "800" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_HEAVY, "900" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_font_weight_value_new (PangoWeight font_weight)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (font_weight_values); i++)
|
||||
{
|
||||
if (font_weight_values[i].value == font_weight)
|
||||
return _gtk_css_value_ref (&font_weight_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_font_weight_value_try_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (font_weight_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, font_weight_values[i].name, TRUE))
|
||||
return _gtk_css_value_ref (&font_weight_values[i]);
|
||||
}
|
||||
/* special cases go here */
|
||||
if (_gtk_css_parser_try (parser, "400", TRUE))
|
||||
return _gtk_css_value_ref (&font_weight_values[3]);
|
||||
if (_gtk_css_parser_try (parser, "700", TRUE))
|
||||
return _gtk_css_value_ref (&font_weight_values[6]);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PangoWeight
|
||||
_gtk_css_font_weight_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_FONT_WEIGHT, PANGO_WEIGHT_NORMAL);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* GtkCssArea */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_equal,
|
||||
gtk_css_value_enum_transition,
|
||||
gtk_css_value_enum_print
|
||||
};
|
||||
|
||||
static GtkCssValue area_values[] = {
|
||||
{ >K_CSS_VALUE_AREA, 1, GTK_CSS_AREA_BORDER_BOX, "border-box" },
|
||||
{ >K_CSS_VALUE_AREA, 1, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
|
||||
{ >K_CSS_VALUE_AREA, 1, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_area_value_new (GtkCssArea area)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
|
||||
{
|
||||
if (area_values[i].value == area)
|
||||
return _gtk_css_value_ref (&area_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_area_value_try_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, area_values[i].name, TRUE))
|
||||
return _gtk_css_value_ref (&area_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkCssArea
|
||||
_gtk_css_area_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_AREA, GTK_CSS_AREA_BORDER_BOX);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_ENUM_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_ENUM_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkenums.h"
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_border_style_value_new (GtkBorderStyle border_style);
|
||||
GtkCssValue * _gtk_css_border_style_value_try_parse (GtkCssParser *parser);
|
||||
GtkBorderStyle _gtk_css_border_style_value_get (const GtkCssValue *value);
|
||||
|
||||
GtkCssValue * _gtk_css_font_style_value_new (PangoStyle style);
|
||||
GtkCssValue * _gtk_css_font_style_value_try_parse (GtkCssParser *parser);
|
||||
PangoStyle _gtk_css_font_style_value_get (const GtkCssValue *value);
|
||||
|
||||
GtkCssValue * _gtk_css_font_variant_value_new (PangoVariant variant);
|
||||
GtkCssValue * _gtk_css_font_variant_value_try_parse (GtkCssParser *parser);
|
||||
PangoVariant _gtk_css_font_variant_value_get (const GtkCssValue *value);
|
||||
|
||||
GtkCssValue * _gtk_css_font_weight_value_new (PangoWeight weight);
|
||||
GtkCssValue * _gtk_css_font_weight_value_try_parse (GtkCssParser *parser);
|
||||
PangoWeight _gtk_css_font_weight_value_get (const GtkCssValue *value);
|
||||
|
||||
GtkCssValue * _gtk_css_area_value_new (GtkCssArea area);
|
||||
GtkCssValue * _gtk_css_area_value_try_parse (GtkCssParser *parser);
|
||||
GtkCssArea _gtk_css_area_value_get (const GtkCssValue *value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_ENUM_VALUE_PRIVATE_H__ */
|
||||
+3
-1
@@ -22,6 +22,7 @@
|
||||
#include "gtkcssimageprivate.h"
|
||||
|
||||
/* for the types only */
|
||||
#include "gtk/gtkcssimagecrossfadeprivate.h"
|
||||
#include "gtk/gtkcssimagegradientprivate.h"
|
||||
#include "gtk/gtkcssimagelinearprivate.h"
|
||||
#include "gtk/gtkcssimageurlprivate.h"
|
||||
@@ -324,7 +325,8 @@ gtk_css_image_get_parser_type (GtkCssParser *parser)
|
||||
{ "-gtk-gradient", _gtk_css_image_gradient_get_type },
|
||||
{ "-gtk-win32-theme-part", _gtk_css_image_win32_get_type },
|
||||
{ "linear-gradient", _gtk_css_image_linear_get_type },
|
||||
{ "repeating-linear-gradient", _gtk_css_image_linear_get_type }
|
||||
{ "repeating-linear-gradient", _gtk_css_image_linear_get_type },
|
||||
{ "cross-fade", _gtk_css_image_cross_fade_get_type }
|
||||
};
|
||||
guint i;
|
||||
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gtkcssimagecrossfadeprivate.h"
|
||||
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssImageCrossFade, _gtk_css_image_cross_fade, GTK_TYPE_CSS_IMAGE)
|
||||
|
||||
static int
|
||||
gtk_css_image_cross_fade_get_width (GtkCssImage *image)
|
||||
{
|
||||
GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image);
|
||||
int start_width, end_width;
|
||||
|
||||
if (cross_fade->start)
|
||||
{
|
||||
start_width = _gtk_css_image_get_width (cross_fade->start);
|
||||
/* no intrinsic width, what now? */
|
||||
if (start_width == 0)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
start_width = 0;
|
||||
|
||||
if (cross_fade->end)
|
||||
{
|
||||
end_width = _gtk_css_image_get_width (cross_fade->end);
|
||||
/* no intrinsic width, what now? */
|
||||
if (end_width == 0)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
end_width = 0;
|
||||
|
||||
return start_width + (end_width - start_width) * cross_fade->progress;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_css_image_cross_fade_get_height (GtkCssImage *image)
|
||||
{
|
||||
GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image);
|
||||
int start_height, end_height;
|
||||
|
||||
if (cross_fade->start)
|
||||
{
|
||||
start_height = _gtk_css_image_get_height (cross_fade->start);
|
||||
/* no intrinsic height, what now? */
|
||||
if (start_height == 0)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
start_height = 0;
|
||||
|
||||
if (cross_fade->end)
|
||||
{
|
||||
end_height = _gtk_css_image_get_height (cross_fade->end);
|
||||
/* no intrinsic height, what now? */
|
||||
if (end_height == 0)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
end_height = 0;
|
||||
|
||||
return start_height + (end_height - start_height) * cross_fade->progress;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_cross_fade_draw (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image);
|
||||
|
||||
if (cross_fade->progress <= 0.0)
|
||||
{
|
||||
if (cross_fade->start)
|
||||
_gtk_css_image_draw (cross_fade->start, cr, width, height);
|
||||
}
|
||||
else if (cross_fade->progress >= 1.0)
|
||||
{
|
||||
if (cross_fade->end)
|
||||
_gtk_css_image_draw (cross_fade->end, cr, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (cross_fade->start && cross_fade->end)
|
||||
{
|
||||
/* to reduce the group size */
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
cairo_clip (cr);
|
||||
|
||||
cairo_push_group (cr);
|
||||
|
||||
_gtk_css_image_draw (cross_fade->start, cr, width, height);
|
||||
|
||||
surface = _gtk_css_image_get_surface (cross_fade->end,
|
||||
cairo_get_target (cr),
|
||||
width, height);
|
||||
cairo_set_source_surface (cr, surface, 0, 0);
|
||||
cairo_paint_with_alpha (cr, cross_fade->progress);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
cairo_pop_group_to_source (cr);
|
||||
cairo_paint (cr);
|
||||
}
|
||||
else if (cross_fade->start || cross_fade->end)
|
||||
{
|
||||
surface = _gtk_css_image_get_surface (cross_fade->start ? cross_fade->start : cross_fade->end,
|
||||
cairo_get_target (cr),
|
||||
width, height);
|
||||
cairo_set_source_surface (cr, surface, 0, 0);
|
||||
cairo_paint_with_alpha (cr, cross_fade->start ? 1.0 - cross_fade->progress : cross_fade->progress);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_cross_fade_parse (GtkCssImage *image,
|
||||
GtkCssParser *parser,
|
||||
GFile *base)
|
||||
{
|
||||
GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image);
|
||||
GtkCssValue *number;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, "cross-fade(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected 'cross-fade('");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
cross_fade->start = _gtk_css_image_new_parse (parser, base);
|
||||
if (cross_fade->start == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Missing comma after first image");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
cross_fade->end = _gtk_css_image_new_parse (parser, base);
|
||||
if (cross_fade->end == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Missing comma after second image");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Missing closing bracket");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
number = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_PERCENT | GTK_CSS_POSITIVE_ONLY);
|
||||
if (number == NULL)
|
||||
return FALSE;
|
||||
cross_fade->progress = _gtk_css_number_value_get (number, 1);
|
||||
_gtk_css_value_unref (number);
|
||||
|
||||
if (cross_fade->progress > 100)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Percentages ovre 100%% are not allowed");
|
||||
return FALSE;
|
||||
}
|
||||
cross_fade->progress /= 100.0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_cross_fade_print (GtkCssImage *image,
|
||||
GString *string)
|
||||
{
|
||||
GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image);
|
||||
|
||||
g_string_append (string, "cross_fade(");
|
||||
if (cross_fade->start)
|
||||
_gtk_css_image_print (cross_fade->start, string);
|
||||
else
|
||||
g_string_append (string, "none");
|
||||
g_string_append (string, ",");
|
||||
if (cross_fade->end)
|
||||
_gtk_css_image_print (cross_fade->end, string);
|
||||
else
|
||||
g_string_append (string, "none");
|
||||
g_string_append (string, ",");
|
||||
g_string_append_printf (string, "%g%%", cross_fade->progress * 100.0);
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_cross_fade_dispose (GObject *object)
|
||||
{
|
||||
GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (object);
|
||||
|
||||
g_clear_object (&cross_fade->start);
|
||||
g_clear_object (&cross_fade->end);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_css_image_cross_fade_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_image_cross_fade_class_init (GtkCssImageCrossFadeClass *klass)
|
||||
{
|
||||
GtkCssImageClass *image_class = GTK_CSS_IMAGE_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
image_class->get_width = gtk_css_image_cross_fade_get_width;
|
||||
image_class->get_height = gtk_css_image_cross_fade_get_height;
|
||||
image_class->draw = gtk_css_image_cross_fade_draw;
|
||||
image_class->parse = gtk_css_image_cross_fade_parse;
|
||||
image_class->print = gtk_css_image_cross_fade_print;
|
||||
|
||||
object_class->dispose = gtk_css_image_cross_fade_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_image_cross_fade_init (GtkCssImageCrossFade *image_cross_fade)
|
||||
{
|
||||
}
|
||||
|
||||
GtkCssImage *
|
||||
_gtk_css_image_cross_fade_new (GtkCssImage *start,
|
||||
GtkCssImage *end,
|
||||
double progress)
|
||||
{
|
||||
GtkCssImageCrossFade *cross_fade;
|
||||
|
||||
g_return_val_if_fail (start == NULL || GTK_IS_CSS_IMAGE (start), NULL);
|
||||
g_return_val_if_fail (end == NULL || GTK_IS_CSS_IMAGE (end), NULL);
|
||||
|
||||
cross_fade = g_object_new (GTK_TYPE_CSS_IMAGE_CROSS_FADE, NULL);
|
||||
if (start)
|
||||
cross_fade->start = g_object_ref (start);
|
||||
if (end)
|
||||
cross_fade->end = g_object_ref (end);
|
||||
cross_fade->progress = progress;
|
||||
|
||||
return GTK_CSS_IMAGE (cross_fade);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_IMAGE_CROSS_FADE_PRIVATE_H__
|
||||
#define __GTK_CSS_IMAGE_CROSS_FADE_PRIVATE_H__
|
||||
|
||||
#include "gtk/gtkcssimageprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CSS_IMAGE_CROSS_FADE (_gtk_css_image_cross_fade_get_type ())
|
||||
#define GTK_CSS_IMAGE_CROSS_FADE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_IMAGE_CROSS_FADE, GtkCssImageCrossFade))
|
||||
#define GTK_CSS_IMAGE_CROSS_FADE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_IMAGE_CROSS_FADE, GtkCssImageCrossFadeClass))
|
||||
#define GTK_IS_CSS_IMAGE_CROSS_FADE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_IMAGE_CROSS_FADE))
|
||||
#define GTK_IS_CSS_IMAGE_CROSS_FADE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_IMAGE_CROSS_FADE))
|
||||
#define GTK_CSS_IMAGE_CROSS_FADE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_IMAGE_CROSS_FADE, GtkCssImageCrossFadeClass))
|
||||
|
||||
typedef struct _GtkCssImageCrossFade GtkCssImageCrossFade;
|
||||
typedef struct _GtkCssImageCrossFadeClass GtkCssImageCrossFadeClass;
|
||||
|
||||
struct _GtkCssImageCrossFade
|
||||
{
|
||||
GtkCssImage parent;
|
||||
|
||||
GtkCssImage *start;
|
||||
GtkCssImage *end;
|
||||
double progress;
|
||||
};
|
||||
|
||||
struct _GtkCssImageCrossFadeClass
|
||||
{
|
||||
GtkCssImageClass parent_class;
|
||||
};
|
||||
|
||||
GType _gtk_css_image_cross_fade_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkCssImage * _gtk_css_image_cross_fade_new (GtkCssImage *start,
|
||||
GtkCssImage *end,
|
||||
double progress);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_IMAGE_CROSS_FADE_PRIVATE_H__ */
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "gtkcssimagegradientprivate.h"
|
||||
|
||||
#include "gtkcssprovider.h"
|
||||
#include "gtksymboliccolorprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssImageGradient, _gtk_css_image_gradient, GTK_TYPE_CSS_IMAGE)
|
||||
|
||||
@@ -287,7 +288,7 @@ _gtk_gradient_parse (GtkCssParser *parser)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
color = _gtk_css_parser_read_symbolic_color (parser);
|
||||
color = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
|
||||
if (color == NULL)
|
||||
{
|
||||
gtk_gradient_unref (gradient);
|
||||
|
||||
+72
-78
@@ -23,8 +23,10 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssrgbavalueprivate.h"
|
||||
#include "gtkcssprovider.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtksymboliccolorprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssImageLinear, _gtk_css_image_linear, GTK_TYPE_CSS_IMAGE)
|
||||
|
||||
@@ -39,12 +41,10 @@ gtk_css_image_linear_get_start_end (GtkCssImageLinear *linear,
|
||||
guint i;
|
||||
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, 0);
|
||||
if (stop->offset.unit == GTK_CSS_NUMBER)
|
||||
if (stop->offset == NULL)
|
||||
*start = 0;
|
||||
else if (stop->offset.unit == GTK_CSS_PX)
|
||||
*start = stop->offset.value / length;
|
||||
else
|
||||
*start = stop->offset.value / 100;
|
||||
*start = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
*end = *start;
|
||||
|
||||
@@ -52,18 +52,15 @@ gtk_css_image_linear_get_start_end (GtkCssImageLinear *linear,
|
||||
{
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
|
||||
|
||||
if (stop->offset.unit == GTK_CSS_NUMBER)
|
||||
if (stop->offset == NULL)
|
||||
continue;
|
||||
|
||||
if (stop->offset.unit == GTK_CSS_PX)
|
||||
pos = stop->offset.value / length;
|
||||
else
|
||||
pos = stop->offset.value / 100;
|
||||
pos = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
*end = MAX (pos, *end);
|
||||
}
|
||||
|
||||
if (stop->offset.unit == GTK_CSS_NUMBER)
|
||||
if (stop->offset == NULL)
|
||||
*end = MAX (*end, 1.0);
|
||||
}
|
||||
|
||||
@@ -136,11 +133,9 @@ gtk_css_image_linear_draw (GtkCssImage *image,
|
||||
double offset;
|
||||
int i, last;
|
||||
|
||||
g_return_if_fail (linear->is_computed);
|
||||
|
||||
if (linear->angle.unit == GTK_CSS_NUMBER)
|
||||
if (_gtk_css_number_value_get_unit (linear->angle) == GTK_CSS_NUMBER)
|
||||
{
|
||||
guint side = linear->angle.value;
|
||||
guint side = _gtk_css_number_value_get (linear->angle, 100);
|
||||
|
||||
if (side & (1 << GTK_CSS_RIGHT))
|
||||
x = width;
|
||||
@@ -158,7 +153,7 @@ gtk_css_image_linear_draw (GtkCssImage *image,
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_image_linear_compute_start_point (linear->angle.value,
|
||||
gtk_css_image_linear_compute_start_point (_gtk_css_number_value_get (linear->angle, 100),
|
||||
width, height,
|
||||
&x, &y);
|
||||
}
|
||||
@@ -181,7 +176,7 @@ gtk_css_image_linear_draw (GtkCssImage *image,
|
||||
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
|
||||
|
||||
if (stop->offset.unit == GTK_CSS_NUMBER)
|
||||
if (stop->offset == NULL)
|
||||
{
|
||||
if (i == 0)
|
||||
pos = 0.0;
|
||||
@@ -190,25 +185,26 @@ gtk_css_image_linear_draw (GtkCssImage *image,
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else if (stop->offset.unit == GTK_CSS_PX)
|
||||
pos = stop->offset.value / length;
|
||||
else
|
||||
pos = stop->offset.value / 100;
|
||||
pos = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
pos = MAX (pos, offset);
|
||||
step = (pos - offset) / (i - last);
|
||||
for (last = last + 1; last <= i; last++)
|
||||
{
|
||||
const GdkRGBA *rgba;
|
||||
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, last);
|
||||
|
||||
rgba = _gtk_css_rgba_value_get_rgba (stop->color);
|
||||
offset += step;
|
||||
|
||||
cairo_pattern_add_color_stop_rgba (pattern,
|
||||
(offset - start) / (end - start),
|
||||
stop->color.rgba.red,
|
||||
stop->color.rgba.green,
|
||||
stop->color.rgba.blue,
|
||||
stop->color.rgba.alpha);
|
||||
rgba->red,
|
||||
rgba->green,
|
||||
rgba->blue,
|
||||
rgba->alpha);
|
||||
}
|
||||
|
||||
offset = pos;
|
||||
@@ -294,7 +290,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_gtk_css_number_init (&linear->angle, side, GTK_CSS_NUMBER);
|
||||
linear->angle = _gtk_css_number_value_new (side, GTK_CSS_NUMBER);
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
@@ -304,9 +300,8 @@ gtk_css_image_linear_parse (GtkCssImage *image,
|
||||
}
|
||||
else if (_gtk_css_parser_has_number (parser))
|
||||
{
|
||||
if (!_gtk_css_parser_read_number (parser,
|
||||
&linear->angle,
|
||||
GTK_CSS_PARSE_ANGLE))
|
||||
linear->angle = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
|
||||
if (linear->angle == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
@@ -316,27 +311,29 @@ gtk_css_image_linear_parse (GtkCssImage *image,
|
||||
}
|
||||
}
|
||||
else
|
||||
_gtk_css_number_init (&linear->angle, 1 << GTK_CSS_BOTTOM, GTK_CSS_NUMBER);
|
||||
linear->angle = _gtk_css_number_value_new (1 << GTK_CSS_BOTTOM, GTK_CSS_NUMBER);
|
||||
|
||||
do {
|
||||
GtkCssImageLinearColorStop stop;
|
||||
|
||||
stop.color.symbolic = _gtk_css_parser_read_symbolic_color (parser);
|
||||
if (stop.color.symbolic == NULL)
|
||||
stop.color = _gtk_css_symbolic_value_new (parser);
|
||||
if (stop.color == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (_gtk_css_parser_has_number (parser))
|
||||
{
|
||||
if (!_gtk_css_parser_read_number (parser,
|
||||
&stop.offset,
|
||||
GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH))
|
||||
return FALSE;
|
||||
stop.offset = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (stop.offset == NULL)
|
||||
{
|
||||
_gtk_css_value_unref (stop.color);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* use NUMBER to mark as unset number */
|
||||
_gtk_css_number_init (&stop.offset, 0, GTK_CSS_NUMBER);
|
||||
stop.offset = NULL;
|
||||
}
|
||||
|
||||
g_array_append_val (linear->stops, stop);
|
||||
@@ -359,17 +356,14 @@ gtk_css_image_linear_print (GtkCssImage *image,
|
||||
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
|
||||
guint i;
|
||||
|
||||
/* XXX: Do these need to be prinatable? */
|
||||
g_return_if_fail (!linear->is_computed);
|
||||
|
||||
if (linear->repeating)
|
||||
g_string_append (string, "repeating-linear-gradient(");
|
||||
else
|
||||
g_string_append (string, "linear-gradient(");
|
||||
|
||||
if (linear->angle.unit == GTK_CSS_NUMBER)
|
||||
if (_gtk_css_number_value_get_unit (linear->angle) == GTK_CSS_NUMBER)
|
||||
{
|
||||
guint side = linear->angle.value;
|
||||
guint side = _gtk_css_number_value_get (linear->angle, 100);
|
||||
|
||||
if (side != (1 << GTK_CSS_BOTTOM))
|
||||
{
|
||||
@@ -390,28 +384,25 @@ gtk_css_image_linear_print (GtkCssImage *image,
|
||||
}
|
||||
else
|
||||
{
|
||||
_gtk_css_number_print (&linear->angle, string);
|
||||
_gtk_css_value_print (linear->angle, string);
|
||||
g_string_append (string, ", ");
|
||||
}
|
||||
|
||||
for (i = 0; i < linear->stops->len; i++)
|
||||
{
|
||||
GtkCssImageLinearColorStop *stop;
|
||||
char *s;
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (string, ", ");
|
||||
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
|
||||
|
||||
s = gtk_symbolic_color_to_string (stop->color.symbolic);
|
||||
g_string_append (string, s);
|
||||
g_free (s);
|
||||
_gtk_css_value_print (stop->color, string);
|
||||
|
||||
if (stop->offset.unit != GTK_CSS_NUMBER)
|
||||
if (stop->offset)
|
||||
{
|
||||
g_string_append (string, " ");
|
||||
_gtk_css_number_print (&stop->offset, string);
|
||||
_gtk_css_value_print (stop->offset, string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,19 +413,18 @@ static GtkCssImage *
|
||||
gtk_css_image_linear_compute (GtkCssImage *image,
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
static const GdkRGBA transparent = { 0, 0, 0, 0 };
|
||||
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
|
||||
GtkCssImageLinear *copy;
|
||||
GtkCssValue *fallback;
|
||||
guint i;
|
||||
|
||||
if (linear->is_computed)
|
||||
return g_object_ref (linear);
|
||||
|
||||
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
|
||||
copy->is_computed = TRUE;
|
||||
copy->repeating = linear->repeating;
|
||||
|
||||
_gtk_css_number_compute (©->angle, &linear->angle, context);
|
||||
copy->angle = _gtk_css_number_value_compute (linear->angle, context);
|
||||
|
||||
fallback = _gtk_css_symbolic_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
|
||||
g_array_set_size (copy->stops, linear->stops->len);
|
||||
for (i = 0; i < linear->stops->len; i++)
|
||||
{
|
||||
@@ -443,17 +433,19 @@ gtk_css_image_linear_compute (GtkCssImage *image,
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
|
||||
scopy = &g_array_index (copy->stops, GtkCssImageLinearColorStop, i);
|
||||
|
||||
if (!_gtk_style_context_resolve_color (context,
|
||||
stop->color.symbolic,
|
||||
&scopy->color.rgba))
|
||||
{
|
||||
static const GdkRGBA transparent = { 0, 0, 0, 0 };
|
||||
scopy->color.rgba = transparent;
|
||||
}
|
||||
scopy->color = _gtk_css_rgba_value_compute_from_symbolic (stop->color,
|
||||
fallback,
|
||||
context,
|
||||
FALSE);
|
||||
|
||||
_gtk_css_number_compute (&scopy->offset, &stop->offset, context);
|
||||
if (stop->offset)
|
||||
scopy->offset = _gtk_css_number_value_compute (stop->offset, context);
|
||||
else
|
||||
scopy->offset = NULL;
|
||||
}
|
||||
|
||||
_gtk_css_value_unref (fallback);
|
||||
|
||||
return GTK_CSS_IMAGE (copy);
|
||||
}
|
||||
|
||||
@@ -464,23 +456,16 @@ gtk_css_image_linear_dispose (GObject *object)
|
||||
|
||||
if (linear->stops)
|
||||
{
|
||||
if (!linear->is_computed)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < linear->stops->len; i++)
|
||||
{
|
||||
GtkCssImageLinearColorStop *stop;
|
||||
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
|
||||
|
||||
gtk_symbolic_color_unref (stop->color.symbolic);
|
||||
}
|
||||
}
|
||||
g_array_free (linear->stops, TRUE);
|
||||
linear->stops = NULL;
|
||||
}
|
||||
|
||||
if (linear->angle)
|
||||
{
|
||||
_gtk_css_value_unref (linear->angle);
|
||||
linear->angle = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (_gtk_css_image_linear_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
@@ -498,11 +483,20 @@ _gtk_css_image_linear_class_init (GtkCssImageLinearClass *klass)
|
||||
object_class->dispose = gtk_css_image_linear_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_clear_color_stop (gpointer color_stop)
|
||||
{
|
||||
GtkCssImageLinearColorStop *stop = color_stop;
|
||||
|
||||
_gtk_css_value_unref (stop->color);
|
||||
if (stop->offset)
|
||||
_gtk_css_value_unref (stop->offset);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_image_linear_init (GtkCssImageLinear *linear)
|
||||
{
|
||||
linear->stops = g_array_new (FALSE, FALSE, sizeof (GtkCssImageLinearColorStop));
|
||||
|
||||
_gtk_css_number_init (&linear->angle, 1 << GTK_CSS_BOTTOM, GTK_CSS_NUMBER);
|
||||
g_array_set_clear_func (linear->stops, gtk_css_image_clear_color_stop);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define __GTK_CSS_IMAGE_LINEAR_PRIVATE_H__
|
||||
|
||||
#include "gtk/gtkcssimageprivate.h"
|
||||
#include "gtk/gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -36,20 +37,16 @@ typedef struct _GtkCssImageLinearClass GtkCssImageLinearClass;
|
||||
typedef struct _GtkCssImageLinearColorStop GtkCssImageLinearColorStop;
|
||||
|
||||
struct _GtkCssImageLinearColorStop {
|
||||
GtkCssNumber offset;
|
||||
union {
|
||||
GtkSymbolicColor *symbolic;
|
||||
GdkRGBA rgba;
|
||||
} color;
|
||||
GtkCssValue *offset;
|
||||
GtkCssValue *color;
|
||||
};
|
||||
|
||||
struct _GtkCssImageLinear
|
||||
{
|
||||
GtkCssImage parent;
|
||||
|
||||
GtkCssNumber angle; /* warning: We use GTK_CSS_NUMBER as an enum for the corners */
|
||||
GtkCssValue *angle; /* warning: We use GTK_CSS_NUMBER as an enum for the corners */
|
||||
GArray *stops;
|
||||
guint is_computed :1;
|
||||
guint repeating :1;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssimagevalueprivate.h"
|
||||
|
||||
#include "gtkcssimagecrossfadeprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
GtkCssImage *image;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_image_free (GtkCssValue *value)
|
||||
{
|
||||
g_object_unref (value->image);
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_image_equal (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
return value1->image == value2->image;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_image_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
GtkCssImage *fade;
|
||||
|
||||
fade = _gtk_css_image_cross_fade_new (_gtk_css_image_value_get_image (start),
|
||||
_gtk_css_image_value_get_image (end),
|
||||
progress);
|
||||
|
||||
return _gtk_css_image_value_new (fade);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_image_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
if (value->image)
|
||||
_gtk_css_image_print (value->image, string);
|
||||
else
|
||||
g_string_append (string, "none");
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
|
||||
gtk_css_value_image_free,
|
||||
gtk_css_value_image_equal,
|
||||
gtk_css_value_image_transition,
|
||||
gtk_css_value_image_print
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_image_value_new (GtkCssImage *image)
|
||||
{
|
||||
static GtkCssValue none_singleton = { >K_CSS_VALUE_IMAGE, 1, NULL };
|
||||
GtkCssValue *value;
|
||||
|
||||
if (image == NULL)
|
||||
return _gtk_css_value_ref (&none_singleton);
|
||||
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_IMAGE);
|
||||
value->image = image;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssImage *
|
||||
_gtk_css_image_value_get_image (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_IMAGE, NULL);
|
||||
|
||||
return value->image;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_IMAGE_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_IMAGE_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssimageprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_image_value_new (GtkCssImage *image);
|
||||
|
||||
GtkCssImage * _gtk_css_image_value_get_image (const GtkCssValue *image);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_IMAGE_VALUE_PRIVATE_H__ */
|
||||
@@ -0,0 +1,76 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssinheritvalueprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_inherit_free (GtkCssValue *value)
|
||||
{
|
||||
/* Can only happen if the unique value gets unreffed too often */
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_inherit_equal (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_inherit_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_inherit_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, "inherit");
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_INHERIT = {
|
||||
gtk_css_value_inherit_free,
|
||||
gtk_css_value_inherit_equal,
|
||||
gtk_css_value_inherit_transition,
|
||||
gtk_css_value_inherit_print
|
||||
};
|
||||
|
||||
static GtkCssValue inherit = { >K_CSS_VALUE_INHERIT, 1 };
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_inherit_value_new (void)
|
||||
{
|
||||
return _gtk_css_value_ref (&inherit);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_css_value_is_inherit (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
return value == &inherit;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_INHERIT_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_INHERIT_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_inherit_value_new (void);
|
||||
|
||||
gboolean _gtk_css_value_is_inherit (const GtkCssValue *value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_INHERIT_VALUE_PRIVATE_H__ */
|
||||
@@ -0,0 +1,76 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssinitialvalueprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_initial_free (GtkCssValue *value)
|
||||
{
|
||||
/* Can only happen if the unique value gets unreffed too often */
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_initial_equal (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_initial_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_initial_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, "initial");
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_INITIAL = {
|
||||
gtk_css_value_initial_free,
|
||||
gtk_css_value_initial_equal,
|
||||
gtk_css_value_initial_transition,
|
||||
gtk_css_value_initial_print
|
||||
};
|
||||
|
||||
static GtkCssValue initial = { >K_CSS_VALUE_INITIAL, 1 };
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_initial_value_new (void)
|
||||
{
|
||||
return _gtk_css_value_ref (&initial);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_css_value_is_initial (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
return value == &initial;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_INITIAL_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_INITIAL_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_initial_value_new (void);
|
||||
|
||||
gboolean _gtk_css_value_is_initial (const GtkCssValue *value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_INITIAL_VALUE_PRIVATE_H__ */
|
||||
@@ -0,0 +1,423 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssmatcherprivate.h"
|
||||
|
||||
#include "gtkwidgetpath.h"
|
||||
|
||||
/* GTK_CSS_MATCHER_WIDGET_PATH */
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_widget_path_get_parent (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *child)
|
||||
{
|
||||
if (child->path.index == 0)
|
||||
return FALSE;
|
||||
|
||||
matcher->path.klass = child->path.klass;
|
||||
matcher->path.path = child->path.path;
|
||||
matcher->path.state_flags = 0;
|
||||
matcher->path.index = child->path.index - 1;
|
||||
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *next)
|
||||
{
|
||||
if (next->path.sibling_index == 0)
|
||||
return FALSE;
|
||||
|
||||
matcher->path.klass = next->path.klass;
|
||||
matcher->path.path = next->path.path;
|
||||
matcher->path.state_flags = 0;
|
||||
matcher->path.index = next->path.index;
|
||||
matcher->path.sibling_index = next->path.sibling_index - 1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkStateFlags
|
||||
gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher)
|
||||
{
|
||||
return matcher->path.state_flags;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher,
|
||||
const char *name)
|
||||
{
|
||||
const GtkWidgetPath *siblings;
|
||||
GType type;
|
||||
|
||||
type = g_type_from_name (name);
|
||||
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
|
||||
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
|
||||
return g_type_is_a (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index), type);
|
||||
else
|
||||
return g_type_is_a (gtk_widget_path_iter_get_object_type (matcher->path.path, matcher->path.index), type);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_widget_path_has_class (const GtkCssMatcher *matcher,
|
||||
GQuark class_name)
|
||||
{
|
||||
const GtkWidgetPath *siblings;
|
||||
|
||||
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
|
||||
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
|
||||
return gtk_widget_path_iter_has_qclass (siblings, matcher->path.sibling_index, class_name);
|
||||
else
|
||||
return gtk_widget_path_iter_has_qclass (matcher->path.path, matcher->path.index, class_name);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_widget_path_has_id (const GtkCssMatcher *matcher,
|
||||
const char *id)
|
||||
{
|
||||
const GtkWidgetPath *siblings;
|
||||
|
||||
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
|
||||
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
|
||||
return gtk_widget_path_iter_has_name (siblings, matcher->path.sibling_index, id);
|
||||
else
|
||||
return gtk_widget_path_iter_has_name (matcher->path.path, matcher->path.index, id);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_widget_path_has_regions (const GtkCssMatcher *matcher)
|
||||
{
|
||||
const GtkWidgetPath *siblings;
|
||||
GSList *regions;
|
||||
gboolean result;
|
||||
|
||||
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
|
||||
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
|
||||
regions = gtk_widget_path_iter_list_regions (siblings, matcher->path.sibling_index);
|
||||
else
|
||||
regions = gtk_widget_path_iter_list_regions (matcher->path.path, matcher->path.index);
|
||||
result = regions != NULL;
|
||||
g_slist_free (regions);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher,
|
||||
const char *region,
|
||||
GtkRegionFlags flags)
|
||||
{
|
||||
const GtkWidgetPath *siblings;
|
||||
GtkRegionFlags region_flags;
|
||||
|
||||
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
|
||||
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
|
||||
{
|
||||
if (!gtk_widget_path_iter_has_region (siblings, matcher->path.sibling_index, region, ®ion_flags))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gtk_widget_path_iter_has_region (matcher->path.path, matcher->path.index, region, ®ion_flags))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((flags & region_flags) != flags)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_widget_path_has_position (const GtkCssMatcher *matcher,
|
||||
gboolean forward,
|
||||
int a,
|
||||
int b)
|
||||
{
|
||||
const GtkWidgetPath *siblings;
|
||||
int x;
|
||||
|
||||
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
|
||||
if (!siblings)
|
||||
return FALSE;
|
||||
|
||||
if (forward)
|
||||
x = matcher->path.sibling_index + 1;
|
||||
else
|
||||
x = gtk_widget_path_length (siblings) - matcher->path.sibling_index;
|
||||
|
||||
x -= b;
|
||||
|
||||
if (a == 0)
|
||||
return x == 0;
|
||||
|
||||
if (x % a)
|
||||
return FALSE;
|
||||
|
||||
return x / a > 0;
|
||||
}
|
||||
|
||||
static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
|
||||
gtk_css_matcher_widget_path_get_parent,
|
||||
gtk_css_matcher_widget_path_get_previous,
|
||||
gtk_css_matcher_widget_path_get_state,
|
||||
gtk_css_matcher_widget_path_has_name,
|
||||
gtk_css_matcher_widget_path_has_class,
|
||||
gtk_css_matcher_widget_path_has_id,
|
||||
gtk_css_matcher_widget_path_has_regions,
|
||||
gtk_css_matcher_widget_path_has_region,
|
||||
gtk_css_matcher_widget_path_has_position,
|
||||
};
|
||||
|
||||
gboolean
|
||||
_gtk_css_matcher_init (GtkCssMatcher *matcher,
|
||||
const GtkWidgetPath *path,
|
||||
GtkStateFlags state)
|
||||
{
|
||||
if (gtk_widget_path_length (path) == 0)
|
||||
return FALSE;
|
||||
|
||||
matcher->path.klass = >K_CSS_MATCHER_WIDGET_PATH;
|
||||
matcher->path.path = path;
|
||||
matcher->path.state_flags = state;
|
||||
matcher->path.index = gtk_widget_path_length (path) - 1;
|
||||
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->path.index);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* GTK_CSS_MATCHER_WIDGET_ANY */
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_any_get_parent (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *child)
|
||||
{
|
||||
_gtk_css_matcher_any_init (matcher);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_any_get_previous (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *next)
|
||||
{
|
||||
_gtk_css_matcher_any_init (matcher);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkStateFlags
|
||||
gtk_css_matcher_any_get_state (const GtkCssMatcher *matcher)
|
||||
{
|
||||
/* XXX: This gets tricky when we implement :not() */
|
||||
|
||||
return GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED
|
||||
| GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT
|
||||
| GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_BACKDROP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_any_has_name (const GtkCssMatcher *matcher,
|
||||
const char *name)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_any_has_class (const GtkCssMatcher *matcher,
|
||||
GQuark class_name)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_any_has_id (const GtkCssMatcher *matcher,
|
||||
const char *id)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_any_has_regions (const GtkCssMatcher *matcher)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_any_has_region (const GtkCssMatcher *matcher,
|
||||
const char *region,
|
||||
GtkRegionFlags flags)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_any_has_position (const GtkCssMatcher *matcher,
|
||||
gboolean forward,
|
||||
int a,
|
||||
int b)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = {
|
||||
gtk_css_matcher_any_get_parent,
|
||||
gtk_css_matcher_any_get_previous,
|
||||
gtk_css_matcher_any_get_state,
|
||||
gtk_css_matcher_any_has_name,
|
||||
gtk_css_matcher_any_has_class,
|
||||
gtk_css_matcher_any_has_id,
|
||||
gtk_css_matcher_any_has_regions,
|
||||
gtk_css_matcher_any_has_region,
|
||||
gtk_css_matcher_any_has_position,
|
||||
};
|
||||
|
||||
void
|
||||
_gtk_css_matcher_any_init (GtkCssMatcher *matcher)
|
||||
{
|
||||
matcher->klass = >K_CSS_MATCHER_ANY;
|
||||
}
|
||||
|
||||
/* GTK_CSS_MATCHER_WIDGET_SUPERSET */
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_superset_get_parent (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *child)
|
||||
{
|
||||
_gtk_css_matcher_any_init (matcher);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_superset_get_previous (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *next)
|
||||
{
|
||||
_gtk_css_matcher_any_init (matcher);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkStateFlags
|
||||
gtk_css_matcher_superset_get_state (const GtkCssMatcher *matcher)
|
||||
{
|
||||
/* XXX: This gets tricky when we implement :not() */
|
||||
|
||||
if (matcher->superset.relevant & GTK_CSS_CHANGE_STATE)
|
||||
return _gtk_css_matcher_get_state (matcher->superset.subset);
|
||||
else
|
||||
return GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED
|
||||
| GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT
|
||||
| GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_BACKDROP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_superset_has_name (const GtkCssMatcher *matcher,
|
||||
const char *name)
|
||||
{
|
||||
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
|
||||
return _gtk_css_matcher_has_name (matcher->superset.subset, name);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_superset_has_class (const GtkCssMatcher *matcher,
|
||||
GQuark class_name)
|
||||
{
|
||||
if (matcher->superset.relevant & GTK_CSS_CHANGE_CLASS)
|
||||
return _gtk_css_matcher_has_class (matcher->superset.subset, class_name);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_superset_has_id (const GtkCssMatcher *matcher,
|
||||
const char *id)
|
||||
{
|
||||
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
|
||||
return _gtk_css_matcher_has_id (matcher->superset.subset, id);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_superset_has_regions (const GtkCssMatcher *matcher)
|
||||
{
|
||||
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
|
||||
return _gtk_css_matcher_has_regions (matcher->superset.subset);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_superset_has_region (const GtkCssMatcher *matcher,
|
||||
const char *region,
|
||||
GtkRegionFlags flags)
|
||||
{
|
||||
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
|
||||
{
|
||||
if (matcher->superset.relevant & GTK_CSS_CHANGE_POSITION)
|
||||
return _gtk_css_matcher_has_region (matcher->superset.subset, region, flags);
|
||||
else
|
||||
return _gtk_css_matcher_has_region (matcher->superset.subset, region, 0);
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_matcher_superset_has_position (const GtkCssMatcher *matcher,
|
||||
gboolean forward,
|
||||
int a,
|
||||
int b)
|
||||
{
|
||||
if (matcher->superset.relevant & GTK_CSS_CHANGE_POSITION)
|
||||
return _gtk_css_matcher_has_position (matcher->superset.subset, forward, a, b);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
|
||||
gtk_css_matcher_superset_get_parent,
|
||||
gtk_css_matcher_superset_get_previous,
|
||||
gtk_css_matcher_superset_get_state,
|
||||
gtk_css_matcher_superset_has_name,
|
||||
gtk_css_matcher_superset_has_class,
|
||||
gtk_css_matcher_superset_has_id,
|
||||
gtk_css_matcher_superset_has_regions,
|
||||
gtk_css_matcher_superset_has_region,
|
||||
gtk_css_matcher_superset_has_position,
|
||||
};
|
||||
|
||||
void
|
||||
_gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *subset,
|
||||
GtkCssChange relevant)
|
||||
{
|
||||
g_return_if_fail (subset != NULL);
|
||||
g_return_if_fail ((relevant & ~(GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_STATE)) == 0);
|
||||
|
||||
matcher->superset.klass = >K_CSS_MATCHER_SUPERSET;
|
||||
matcher->superset.subset = subset;
|
||||
matcher->superset.relevant = relevant;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_MATCHER_PRIVATE_H__
|
||||
#define __GTK_CSS_MATCHER_PRIVATE_H__
|
||||
|
||||
#include <gtk/gtkenums.h>
|
||||
#include <gtk/gtktypes.h>
|
||||
#include "gtk/gtkcsstypesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef union _GtkCssMatcher GtkCssMatcher;
|
||||
typedef struct _GtkCssMatcherSuperset GtkCssMatcherSuperset;
|
||||
typedef struct _GtkCssMatcherWidgetPath GtkCssMatcherWidgetPath;
|
||||
typedef struct _GtkCssMatcherClass GtkCssMatcherClass;
|
||||
|
||||
struct _GtkCssMatcherClass {
|
||||
gboolean (* get_parent) (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *child);
|
||||
gboolean (* get_previous) (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *next);
|
||||
|
||||
GtkStateFlags (* get_state) (const GtkCssMatcher *matcher);
|
||||
gboolean (* has_name) (const GtkCssMatcher *matcher,
|
||||
const char *name);
|
||||
gboolean (* has_class) (const GtkCssMatcher *matcher,
|
||||
GQuark class_name);
|
||||
gboolean (* has_id) (const GtkCssMatcher *matcher,
|
||||
const char *id);
|
||||
gboolean (* has_regions) (const GtkCssMatcher *matcher);
|
||||
gboolean (* has_region) (const GtkCssMatcher *matcher,
|
||||
const char *region,
|
||||
GtkRegionFlags flags);
|
||||
gboolean (* has_position) (const GtkCssMatcher *matcher,
|
||||
gboolean forward,
|
||||
int a,
|
||||
int b);
|
||||
};
|
||||
|
||||
struct _GtkCssMatcherWidgetPath {
|
||||
const GtkCssMatcherClass *klass;
|
||||
const GtkWidgetPath *path;
|
||||
GtkStateFlags state_flags;
|
||||
guint index;
|
||||
guint sibling_index;
|
||||
};
|
||||
|
||||
struct _GtkCssMatcherSuperset {
|
||||
const GtkCssMatcherClass *klass;
|
||||
const GtkCssMatcher *subset;
|
||||
GtkCssChange relevant;
|
||||
};
|
||||
|
||||
union _GtkCssMatcher {
|
||||
const GtkCssMatcherClass *klass;
|
||||
GtkCssMatcherWidgetPath path;
|
||||
GtkCssMatcherSuperset superset;
|
||||
};
|
||||
|
||||
gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher,
|
||||
const GtkWidgetPath *path,
|
||||
GtkStateFlags state) G_GNUC_WARN_UNUSED_RESULT;
|
||||
void _gtk_css_matcher_any_init (GtkCssMatcher *matcher);
|
||||
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *subset,
|
||||
GtkCssChange relevant);
|
||||
|
||||
|
||||
static inline gboolean
|
||||
_gtk_css_matcher_get_parent (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *child)
|
||||
{
|
||||
return child->klass->get_parent (matcher, child);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gtk_css_matcher_get_previous (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *next)
|
||||
{
|
||||
return next->klass->get_previous (matcher, next);
|
||||
}
|
||||
|
||||
static inline GtkStateFlags
|
||||
_gtk_css_matcher_get_state (const GtkCssMatcher *matcher)
|
||||
{
|
||||
return matcher->klass->get_state (matcher);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gtk_css_matcher_has_name (const GtkCssMatcher *matcher,
|
||||
const char *name)
|
||||
{
|
||||
return matcher->klass->has_name (matcher, name);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gtk_css_matcher_has_class (const GtkCssMatcher *matcher,
|
||||
GQuark class_name)
|
||||
{
|
||||
return matcher->klass->has_class (matcher, class_name);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gtk_css_matcher_has_id (const GtkCssMatcher *matcher,
|
||||
const char *id)
|
||||
{
|
||||
return matcher->klass->has_id (matcher, id);
|
||||
}
|
||||
|
||||
|
||||
static inline gboolean
|
||||
_gtk_css_matcher_has_regions (const GtkCssMatcher *matcher)
|
||||
{
|
||||
return matcher->klass->has_regions (matcher);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gtk_css_matcher_has_region (const GtkCssMatcher *matcher,
|
||||
const char *region,
|
||||
GtkRegionFlags flags)
|
||||
{
|
||||
return matcher->klass->has_region (matcher, region, flags);
|
||||
}
|
||||
|
||||
static inline guint
|
||||
_gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
|
||||
gboolean forward,
|
||||
int a,
|
||||
int b)
|
||||
{
|
||||
return matcher->klass->has_position (matcher, forward, a, b);
|
||||
}
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_MATCHER_PRIVATE_H__ */
|
||||
@@ -0,0 +1,211 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
GtkCssUnit unit;
|
||||
double value;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_number_free (GtkCssValue *value)
|
||||
{
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_number_equal (const GtkCssValue *number1,
|
||||
const GtkCssValue *number2)
|
||||
{
|
||||
return number1->unit == number2->unit &&
|
||||
number1->value == number2->value;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_number_transition (GtkCssValue *start,
|
||||
GtkCssValue *end,
|
||||
double progress)
|
||||
{
|
||||
/* FIXME: This needs to be supported at least for percentages,
|
||||
* but for that we kinda need to support calc(5px + 50%) */
|
||||
if (start->unit != end->unit)
|
||||
return NULL;
|
||||
|
||||
return _gtk_css_number_value_new (start->value + (end->value - start->value) * progress,
|
||||
start->unit);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_number_print (const GtkCssValue *number,
|
||||
GString *string)
|
||||
{
|
||||
char buf[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
const char *names[] = {
|
||||
/* [GTK_CSS_NUMBER] = */ "",
|
||||
/* [GTK_CSS_PERCENT] = */ "%",
|
||||
/* [GTK_CSS_PX] = */ "px",
|
||||
/* [GTK_CSS_PT] = */ "pt",
|
||||
/* [GTK_CSS_EM] = */ "em",
|
||||
/* [GTK_CSS_EX] = */ "ex",
|
||||
/* [GTK_CSS_PC] = */ "pc",
|
||||
/* [GTK_CSS_IN] = */ "in",
|
||||
/* [GTK_CSS_CM] = */ "cm",
|
||||
/* [GTK_CSS_MM] = */ "mm",
|
||||
/* [GTK_CSS_RAD] = */ "rad",
|
||||
/* [GTK_CSS_DEG] = */ "deg",
|
||||
/* [GTK_CSS_GRAD] = */ "grad",
|
||||
/* [GTK_CSS_TURN] = */ "turn",
|
||||
/* [GTK_CSS_S] = */ "s",
|
||||
/* [GTK_CSS_MS] = */ "ms",
|
||||
};
|
||||
|
||||
g_ascii_dtostr (buf, sizeof (buf), number->value);
|
||||
g_string_append (string, buf);
|
||||
if (number->value != 0.0)
|
||||
g_string_append (string, names[number->unit]);
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_NUMBER = {
|
||||
gtk_css_value_number_free,
|
||||
gtk_css_value_number_equal,
|
||||
gtk_css_value_number_transition,
|
||||
gtk_css_value_number_print
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_number_value_new (double value,
|
||||
GtkCssUnit unit)
|
||||
{
|
||||
static GtkCssValue zero_singleton = { >K_CSS_VALUE_NUMBER, 1, GTK_CSS_NUMBER, 0 };
|
||||
static GtkCssValue px_singletons[] = {
|
||||
{ >K_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 0 },
|
||||
{ >K_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 1 },
|
||||
{ >K_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 2 },
|
||||
{ >K_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 3 },
|
||||
{ >K_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 4 },
|
||||
};
|
||||
GtkCssValue *result;
|
||||
|
||||
if (unit == GTK_CSS_NUMBER && value == 0)
|
||||
return _gtk_css_value_ref (&zero_singleton);
|
||||
|
||||
if (unit == GTK_CSS_PX &&
|
||||
(value == 0 ||
|
||||
value == 1 ||
|
||||
value == 2 ||
|
||||
value == 3 ||
|
||||
value == 4))
|
||||
{
|
||||
return _gtk_css_value_ref (&px_singletons[(int) value]);
|
||||
}
|
||||
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_NUMBER);
|
||||
result->unit = unit;
|
||||
result->value = value;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssUnit
|
||||
_gtk_css_number_value_get_unit (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_NUMBER, GTK_CSS_NUMBER);
|
||||
|
||||
return value->unit;
|
||||
}
|
||||
|
||||
double
|
||||
_gtk_css_number_value_get (const GtkCssValue *number,
|
||||
double one_hundred_percent)
|
||||
{
|
||||
g_return_val_if_fail (number != NULL, 0.0);
|
||||
g_return_val_if_fail (number->class == >K_CSS_VALUE_NUMBER, 0.0);
|
||||
|
||||
if (number->unit == GTK_CSS_PERCENT)
|
||||
return number->value * one_hundred_percent / 100;
|
||||
else
|
||||
return number->value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_number_value_compute (GtkCssValue *number,
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
g_return_val_if_fail (number->class == >K_CSS_VALUE_NUMBER, NULL);
|
||||
|
||||
switch (number->unit)
|
||||
{
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
/* fall through */
|
||||
case GTK_CSS_PERCENT:
|
||||
case GTK_CSS_NUMBER:
|
||||
case GTK_CSS_PX:
|
||||
case GTK_CSS_DEG:
|
||||
case GTK_CSS_S:
|
||||
return _gtk_css_value_ref (number);
|
||||
case GTK_CSS_PT:
|
||||
return _gtk_css_number_value_new (number->value * 96.0 / 72.0,
|
||||
GTK_CSS_PX);
|
||||
case GTK_CSS_PC:
|
||||
return _gtk_css_number_value_new (number->value * 96.0 / 72.0 * 12.0,
|
||||
GTK_CSS_PX);
|
||||
break;
|
||||
case GTK_CSS_IN:
|
||||
return _gtk_css_number_value_new (number->value * 96.0,
|
||||
GTK_CSS_PX);
|
||||
break;
|
||||
case GTK_CSS_CM:
|
||||
return _gtk_css_number_value_new (number->value * 96.0 * 0.39370078740157477,
|
||||
GTK_CSS_PX);
|
||||
break;
|
||||
case GTK_CSS_MM:
|
||||
return _gtk_css_number_value_new (number->value * 96.0 * 0.039370078740157477,
|
||||
GTK_CSS_PX);
|
||||
break;
|
||||
case GTK_CSS_EM:
|
||||
return _gtk_css_number_value_new (number->value *
|
||||
_gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
|
||||
GTK_CSS_PX);
|
||||
break;
|
||||
case GTK_CSS_EX:
|
||||
/* for now we pretend ex is half of em */
|
||||
return _gtk_css_number_value_new (number->value * 0.5 *
|
||||
_gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
|
||||
GTK_CSS_PX);
|
||||
case GTK_CSS_RAD:
|
||||
return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),
|
||||
GTK_CSS_DEG);
|
||||
case GTK_CSS_GRAD:
|
||||
return _gtk_css_number_value_new (number->value * 360.0 / 400.0,
|
||||
GTK_CSS_DEG);
|
||||
case GTK_CSS_TURN:
|
||||
return _gtk_css_number_value_new (number->value * 360.0,
|
||||
GTK_CSS_DEG);
|
||||
case GTK_CSS_MS:
|
||||
return _gtk_css_number_value_new (number->value / 1000.0,
|
||||
GTK_CSS_S);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user