Compare commits
348 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 |
@@ -1,108 +1,53 @@
|
||||
Overview of Changes in GTK+ 3.4.4
|
||||
Overview of Changes in GTK+ 3.5.1
|
||||
=================================
|
||||
|
||||
* GtkIconView:
|
||||
Fallout from the layout rewrite has been fixed
|
||||
* Wayland:
|
||||
- Allow the wayland backend to be used without cairo-gl
|
||||
- Expose GdkWaylandDisplayManager for runtime checks
|
||||
|
||||
* Bugs fixed:
|
||||
531319 "weight-set" cellrenderertext attribute misbehaves...
|
||||
571254 Constructing a pixel value from components
|
||||
613561 single quote missing in translation of gtk-2-18.kn.po
|
||||
643490 gtk-style-context-add-provider () documentation ne...
|
||||
646798 Add a tip about "cloning contexts"
|
||||
647779 Doesn't mention GtkDialog replacements
|
||||
649569 GDK_THREADS_ENTER in file_print_cb@modules/printba...
|
||||
659613 GtkLockButton docs are inaccurate
|
||||
663991 _XOPEN_SOURCE 500 causes error in Solaris Studio c...
|
||||
664646 dnd pointer lock when dragging tab between two ged...
|
||||
667808 Accept -1 as the position where insert an element ...
|
||||
670369 gdk: annotate the attributes_mask type for gdk_win...
|
||||
671437 GtkStyle background color regression
|
||||
671817 GTK+ doesn't create ~/.local/share (path) and ~/.l...
|
||||
673749 Error Message When Creating Tray Icon
|
||||
675167 GtkPlug gets key translation wrong with multiple l...
|
||||
675423 doc: Add missing CDATA around a XML programlisting...
|
||||
675535 GtkScale in GtkToolbar: strange behaviour with dou...
|
||||
675809 Crash when clicking xrefs
|
||||
675899 Infobar not loadable by GTKBuilder (using python g...
|
||||
675990 gtk_tree_column_set_visible badly interact with th...
|
||||
676077 Windows: Weird characters appearing when using cer...
|
||||
676243 Document removing of accelerators
|
||||
676262 Build failure in gdk
|
||||
676329 GDK_SMOOTH_SCROLL_MASK lacks "Since"
|
||||
677127 Misc annotation fixes
|
||||
677293 GtkFontSelectionDialog partially broken on gtk 3.4
|
||||
677363 grid: Add missing guard to gtk_grid_get_child_at()
|
||||
677551 a11y: fix a typo leading to a crash
|
||||
677649 gtk[list,tree]store: fix transformation of GValues...
|
||||
677774 gdk: add missing annotations to gdk_event_get_scro...
|
||||
677775 gdk: add a missing annotation to GdkEventProperty
|
||||
677809 Regression: gtkiconview changes in 3.4.2 / master ...
|
||||
677915 entry-completion: don't move to leftmost character...
|
||||
677941 Gtk.ListStore doesn't have the method "reorder" as...
|
||||
678175 [Patch] Memory leak in GtkImage
|
||||
678407 GtkImage: fix get_property('stock')
|
||||
678829 Bloatpad example application has "parse" action in...
|
||||
679166 modelmenu: set the accel group on the GtkMenu
|
||||
679228 signal parameter names are not valid C identifiers
|
||||
679409 docs: link against libgdk-3.la
|
||||
679454 modelmenu: listen for toplevel changes on the atta...
|
||||
679537 Crash in GtkEntry gtk_entry_get_icon_pixbuf()
|
||||
* Theming:
|
||||
- Optimizations to style invalidation
|
||||
- Support CSS animatable properties
|
||||
|
||||
* Updated translations:
|
||||
German
|
||||
Indonesian
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 3.4.3
|
||||
=================================
|
||||
|
||||
* GtkIconView:
|
||||
- The sizing and layout has been rewritten
|
||||
|
||||
* Bug fixes:
|
||||
478344 GtkTreeRowReference falsely said to auto-subscribe...
|
||||
587873 Documentation should explain MessageDialogs don't ...
|
||||
663072 GtkSelectionData is incorrectly documented
|
||||
670449 Splash screen stays
|
||||
672947 GtkEntryCompletion sizing/position fixes
|
||||
673237 window: Remove needless call to ensure_state_flag_...
|
||||
674192 out-of-tree build failure: demos/widget-factory/wi...
|
||||
674549 widget receives leave event when button released
|
||||
675421 GtkFileChooser should set its role
|
||||
675501 gtkquartz.h is not the gtk+-3.5.2.tar.xz archive
|
||||
|
||||
* Translation updates:
|
||||
Dutch
|
||||
Italian
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 3.4.2
|
||||
=================================
|
||||
|
||||
* Bug fixes:
|
||||
* 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
|
||||
671249 GApplication: Allow a null application_id?
|
||||
668931 Scrolling down via PageDown/PageUp keys impossible in list...
|
||||
669989 gtk_grid_attach(): Documentation doesn't mention multiple ...
|
||||
670373 modules/printing/cups/gtkprintbackendcups.c won't build wi...
|
||||
672789 gtk_builder_add_objects_from_file() crashes on GtkUIManage...
|
||||
673259 The gdk/gdkkeysyms-update.pl script and the keysym files g...
|
||||
673650 Evince 3.4: adding new annotation is not possible (pencil ...
|
||||
674050 Free image->priv->icon_helper in gtk_image_finalize instea...
|
||||
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 not ins...
|
||||
674200 ./configure gives wrong error message if -lXext is ...
|
||||
674286 "Delete confirmation" dialog has wrong padding
|
||||
674326 Use localizations of option names and values contained in ...
|
||||
674587 treemodelsort: allow iter_previous() to go past the second...
|
||||
674806 icontheme: search first in all themes if the requested ico...
|
||||
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
|
||||
674890 Fix the colord support in GtkPrinterCups when the PPD is l...
|
||||
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:
|
||||
Simplified Chinese
|
||||
* 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,6 +72,24 @@ 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
|
||||
=====================
|
||||
|
||||
|
||||
+30
-36
@@ -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], [4])
|
||||
m4_define([gtk_interface_age], [4])
|
||||
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])
|
||||
@@ -125,7 +125,6 @@ AC_SUBST([GAIL_LT_CURRENT_MINUS_AGE],[gail_lt_current_minus_age])
|
||||
AC_PROG_CC
|
||||
AC_PROG_CC_C_O
|
||||
AC_PROG_CC_STDC
|
||||
AC_PROG_MKDIR_P
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
@@ -317,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
|
||||
@@ -380,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)
|
||||
@@ -408,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
|
||||
|
||||
@@ -1233,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
|
||||
@@ -1256,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=""
|
||||
@@ -1291,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"
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/* Color Chooser
|
||||
/* Color Selector
|
||||
*
|
||||
* GtkColorSelection lets the user choose a color. GtkColorSelectionDialog is
|
||||
* a prebuilt dialog containing a GtkColorSelection.
|
||||
*
|
||||
* A GtkColorChooser lets the user choose a color. There are several
|
||||
* implementations of the GtkColorChooser interface in GTK+. The
|
||||
* GtkColorChooserDialog is a prebuilt dialog containing a
|
||||
* GtkColorChooserWidget.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@@ -78,7 +77,7 @@ do_colorsel (GtkWidget *do_widget)
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Color Chooser");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Color Selection");
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
<releaseinfo>
|
||||
This document is for the GDK 3 library, version &version;
|
||||
The latest versions can be found online at
|
||||
<ulink role="online-location" url="http://developer.gnome.org/gdk3/">http://developer.gnome.org/gdk3/</ulink>.
|
||||
<ulink role="online-location" url="http://developer.gnome.org/devel/gdk3/">http://developer.gnome.org/devel/gdk3/</ulink>.
|
||||
If you are looking for the older GDK 2 series of libraries,
|
||||
see <ulink role="online-location" url="http://developer.gnome.org/gdk/">http://developer.gnome.org/gdk/</ulink>.
|
||||
see <ulink role="online-location" url="http://developer.gnome.org/devel/gdk/">http://developer.gnome.org/devel/gdk/</ulink>.
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -106,7 +106,6 @@ CPPFLAGS += \
|
||||
-UGTK_DISABLE_SINGLE_INCLUDES
|
||||
|
||||
GTKDOC_LIBS = \
|
||||
$(top_builddir)/gdk/libgdk-3.la \
|
||||
$(top_builddir)/gtk/libgtk-3.la \
|
||||
$(GTK_DEP_LIBS)
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
<releaseinfo>
|
||||
This document is for the GTK+ 3 library, version &version;.
|
||||
The latest versions can be found online at
|
||||
<ulink role="online-location" url="http://developer.gnome.org/gtk3/">http://developer.gnome.org/gtk3/</ulink>.
|
||||
<ulink role="online-location" url="http://developer.gnome.org/devel/gtk3/">http://developer.gnome.org/devel/gtk3/</ulink>.
|
||||
If you are looking for the older GTK+ 2 series of libraries,
|
||||
see <ulink role="online-location" url="http://developer.gnome.org/gtk/">http://developer.gnome.org/gtk/</ulink>.
|
||||
see <ulink role="online-location" url="http://developer.gnome.org/devel/gtk/">http://developer.gnome.org/devel/gtk/</ulink>.
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ GtkAccelGroupActivate
|
||||
GtkAccelGroupFindFunc
|
||||
gtk_accel_group_disconnect
|
||||
gtk_accel_group_disconnect_key
|
||||
gtk_accel_group_query
|
||||
gtk_accel_group_activate
|
||||
gtk_accel_group_lock
|
||||
gtk_accel_group_unlock
|
||||
@@ -95,7 +96,6 @@ GTK_ACCEL_GROUP_GET_CLASS
|
||||
GTK_ACCEL_GROUP_GET_PRIVATE
|
||||
GtkAccelGroupPrivate
|
||||
GtkAccelGroupEntry
|
||||
gtk_accel_group_query
|
||||
gtk_accel_group_get_type
|
||||
</SECTION>
|
||||
|
||||
@@ -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
|
||||
@@ -7019,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
|
||||
@@ -7052,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
|
||||
|
||||
@@ -82,8 +82,9 @@
|
||||
Over the years, a number of functions, and in some cases, entire
|
||||
widgets have been deprecated. These deprecations are clearly spelled
|
||||
out in the API reference, with hints about the recommended replacements.
|
||||
The API reference for GTK+ 2 also includes an
|
||||
<ulink url="http://developer.gnome.org/gtk/2.24/api-index-deprecated.html">index</ulink> of all deprecated symbols.
|
||||
The API reference also includes an
|
||||
<link linkend="api-index-deprecated">index</link> of all deprecated
|
||||
symbols.
|
||||
</para>
|
||||
<para>
|
||||
To verify that your program does not use any deprecated symbols,
|
||||
@@ -91,14 +92,7 @@
|
||||
as follows:
|
||||
<programlisting>
|
||||
make CFLAGS+="-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
Note that some parts of our API, such as enumeration values, are
|
||||
not well covered by the deprecation warnings. In most cases, using
|
||||
them will require you to also use deprecated functions, which will
|
||||
trigger warnings. But some things, like the %GTK_DIALOG_NO_SEPARATOR
|
||||
flag that has disappeared in GTK+ 3, may not.
|
||||
</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
@@ -279,7 +273,7 @@ gdk_cairo_set_source_pixbuf() instead of cairo_set_source_surface().
|
||||
<para>
|
||||
Drawing layouts clipped is often used to avoid overdraw or to
|
||||
allow drawing selections. Code would have looked like this:
|
||||
<informalexample><programlisting>
|
||||
<informalexample><programlisting>
|
||||
GdkGC *gc;
|
||||
|
||||
/* setup */
|
||||
@@ -1000,8 +994,7 @@ AM_CONDITIONAL(BUILD_x11, [test "x$have_x11" = "xyes"])
|
||||
Another convenience function that can help when implementing
|
||||
::draw for multi-window widgets is gtk_cairo_transform_to_window(),
|
||||
which transforms a cairo context from widget-relative coordinates
|
||||
to window-relative coordinates. You may want to use cairo_save() and
|
||||
cairo_restore() when modifying the cairo context in your draw function.
|
||||
to window-relative coordinates.
|
||||
</para>
|
||||
<para>
|
||||
All GtkStyle drawing functions (gtk_paint_box(), etc) have been changed
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir) \
|
||||
$(DEP_CFLAGS)
|
||||
|
||||
GTKDOC_LIBS = $(top_builddir)/libgail-util/libgailutil-3.la
|
||||
GTKDOC_LIBS = $(top_builddir)/libgail-util/libgailutil.la
|
||||
|
||||
# gtkdoc-mkdb related varaibles
|
||||
MKDB_OPTIONS =
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<releaseinfo>
|
||||
Version &version;
|
||||
The latest version of this documentation can be found on-line at
|
||||
<ulink role="online-location" url="http://developer.gnome.org/gail-libgail-util/unstable/">http://developer.gnome.org/gail-libgail-util/unstable/</ulink>.
|
||||
<ulink role="online-location" url="http://developer.gnome.org/devel/gail-libgail-util/unstable/">http://developer.gnome.org/devel/gail-libgail-util/unstable/</ulink>.
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
<chapter id="libgail-util-main">
|
||||
|
||||
+2
-2
@@ -285,8 +285,8 @@ bloat_pad_startup (GApplication *application)
|
||||
" <attribute name='accel'><Primary>c</attribute>"
|
||||
" </item>"
|
||||
" <item>"
|
||||
" <attribute name='label' translatable='yes'>_Paste</attribute>"
|
||||
" <attribute name='action'>win.paste</attribute>"
|
||||
" <attribute name='label' translatable='yes'>_Parse</attribute>"
|
||||
" <attribute name='action'>win.parse</attribute>"
|
||||
" <attribute name='accel'><Primary>v</attribute>"
|
||||
" </item>"
|
||||
" </section>"
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -560,9 +560,9 @@ gdk_x11_get_xatom_by_name_for_display
|
||||
gdk_x11_get_xatom_name
|
||||
gdk_x11_get_xatom_name_for_display
|
||||
gdk_x11_grab_server
|
||||
gdk_x11_keymap_get_group_for_state_libgtk_only
|
||||
gdk_x11_keymap_get_type
|
||||
gdk_x11_keymap_key_is_modifier_libgtk_only
|
||||
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
-1
@@ -939,7 +939,7 @@ GList *
|
||||
gdk_device_list_slave_devices (GdkDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER, NULL);
|
||||
g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER, NULL);
|
||||
|
||||
return g_list_copy (device->slaves);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1215,8 +1215,8 @@ gdk_event_get_scroll_direction (const GdkEvent *event,
|
||||
/**
|
||||
* gdk_event_get_scroll_deltas:
|
||||
* @event: a #GdkEvent
|
||||
* @delta_x: (out): return location for X delta
|
||||
* @delta_y: (out): return location for Y delta
|
||||
* @delta_x: return location for X delta
|
||||
* @delta_y: return location for Y delta
|
||||
*
|
||||
* Retrieves the scroll deltas from a #GdkEvent
|
||||
*
|
||||
|
||||
+14
-3
@@ -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,
|
||||
@@ -349,7 +360,7 @@ typedef enum
|
||||
* @GDK_SCROLL_LEFT: the window is scrolled to the left.
|
||||
* @GDK_SCROLL_RIGHT: the window is scrolled to the right.
|
||||
* @GDK_SCROLL_SMOOTH: the scrolling is determined by the delta values
|
||||
* in #GdkEventScroll. See gdk_event_get_scroll_deltas(). Since: 3.4
|
||||
* in #GdkEventScroll. See gdk_event_get_scroll_deltas().
|
||||
*
|
||||
* Specifies the direction for #GdkEventScroll.
|
||||
*/
|
||||
@@ -910,8 +921,8 @@ struct _GdkEventConfigure
|
||||
* <function>XSendEvent</function>).
|
||||
* @atom: the property that was changed.
|
||||
* @time: the time of the event in milliseconds.
|
||||
* @state: (type GdkPropertyState): whether the property was changed
|
||||
* (%GDK_PROPERTY_NEW_VALUE) or deleted (%GDK_PROPERTY_DELETE).
|
||||
* @state: whether the property was changed (%GDK_PROPERTY_NEW_VALUE) or
|
||||
* deleted (%GDK_PROPERTY_DELETE).
|
||||
*
|
||||
* Describes a property change on a window.
|
||||
*/
|
||||
|
||||
+1
-8
@@ -830,18 +830,13 @@ static const struct {
|
||||
/* Following items added to GTK, not in the xterm table */
|
||||
|
||||
/* A few ASCII control characters */
|
||||
#ifndef GDK_WINDOWING_WIN32
|
||||
|
||||
{ 0xFF08 /* Backspace */, '\b' },
|
||||
{ 0xFF09 /* Tab */, '\t' },
|
||||
#endif
|
||||
|
||||
{ 0xFF0A /* Linefeed */, '\n' },
|
||||
{ 0xFF0B /* Vert. Tab */, '\v' },
|
||||
|
||||
#ifndef GDK_WINDOWING_WIN32
|
||||
{ 0xFF0D /* Return */, '\r' },
|
||||
{ 0xFF1B /* Escape */, '\033' },
|
||||
#endif
|
||||
|
||||
/* Numeric keypad */
|
||||
|
||||
@@ -866,9 +861,7 @@ static const struct {
|
||||
|
||||
/* End numeric keypad */
|
||||
|
||||
#ifndef GDK_WINDOWING_WIN32
|
||||
{ 0xFFFF /* Delete */, '\177' }
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -217,13 +217,6 @@ gdk_offscreen_window_reparent (GdkWindow *window,
|
||||
return was_mapped;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_offscreen_window_set_device_cursor (GdkWindow *window,
|
||||
GdkDevice *device,
|
||||
GdkCursor *cursor)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
from_embedder (GdkWindow *window,
|
||||
double embedder_x, double embedder_y,
|
||||
@@ -734,7 +727,7 @@ gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
|
||||
impl_class->move_resize = gdk_offscreen_window_move_resize;
|
||||
impl_class->set_background = gdk_offscreen_window_set_background;
|
||||
impl_class->reparent = gdk_offscreen_window_reparent;
|
||||
impl_class->set_device_cursor = gdk_offscreen_window_set_device_cursor;
|
||||
impl_class->set_device_cursor = NULL;
|
||||
impl_class->get_geometry = gdk_offscreen_window_get_geometry;
|
||||
impl_class->get_root_coords = gdk_offscreen_window_get_root_coords;
|
||||
impl_class->get_device_state = gdk_offscreen_window_get_device_state;
|
||||
|
||||
+1
-2
@@ -148,8 +148,7 @@ parse_rgb_value (const gchar *str,
|
||||
* A standard name (Taken from the X11 rgb.txt file).
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* A hex value in the form '#rgb' '#rrggbb' '#rrrgggbbb'
|
||||
* or '#rrrrggggbbbb'
|
||||
* A hex value in the form '#rgb' '#rrggbb' '#rrrgggbbb' or '#rrrrggggbbbb'
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* A RGB color in the form 'rgb(r,g,b)' (In this case the color will
|
||||
|
||||
+3
-3
@@ -135,7 +135,7 @@ typedef struct _GdkAppLaunchContext GdkAppLaunchContext;
|
||||
* in memory as 0xcc, 0xee, 0xff, 0x00.
|
||||
* @GDK_MSB_FIRST: The values are stored with the most-significant byte
|
||||
* first. For instance, the 32-bit value 0xffeecc would be stored
|
||||
* in memory as 0x00, 0xff, 0xee, 0xcc.
|
||||
* in memory as 0x00, 0xcc, 0xee, 0xff.
|
||||
*
|
||||
* A set of values describing the possible byte-orders
|
||||
* for storing pixel values in memory.
|
||||
@@ -348,8 +348,8 @@ typedef enum
|
||||
* @GDK_SUBSTRUCTURE_MASK: receive events about window configuration changes of
|
||||
* child windows
|
||||
* @GDK_SCROLL_MASK: receive scroll events
|
||||
* @GDK_TOUCH_MASK: receive touch events. Since 3.4
|
||||
* @GDK_SMOOTH_SCROLL_MASK: receive smooth scrolling events. Since 3.4
|
||||
* @GDK_TOUCH_MASK: receive touch events
|
||||
* @GDK_SMOOTH_SCROLL_MASK: receive smooth scrolling events
|
||||
* @GDK_ALL_EVENTS_MASK: the combination of all the above event masks.
|
||||
*
|
||||
* A set of bit-flags to indicate which events a window is to receive.
|
||||
|
||||
@@ -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__ */
|
||||
|
||||
+9
-10
@@ -397,11 +397,11 @@ gdk_window_class_init (GdkWindowClass *klass)
|
||||
/**
|
||||
* GdkWindow::to-embedder:
|
||||
* @window: the offscreen window on which the signal is emitted
|
||||
* @offscreen_x: x coordinate in the offscreen window
|
||||
* @offscreen_y: y coordinate in the offscreen window
|
||||
* @embedder_x: (out) (type double): return location for the x
|
||||
* @offscreen-x: x coordinate in the offscreen window
|
||||
* @offscreen-y: y coordinate in the offscreen window
|
||||
* @embedder-x: (out) (type double): return location for the x
|
||||
* coordinate in the embedder window
|
||||
* @embedder_y: (out) (type double): return location for the y
|
||||
* @embedder-y: (out) (type double): return location for the y
|
||||
* coordinate in the embedder window
|
||||
*
|
||||
* The ::to-embedder signal is emitted to translate coordinates
|
||||
@@ -428,11 +428,11 @@ gdk_window_class_init (GdkWindowClass *klass)
|
||||
/**
|
||||
* GdkWindow::from-embedder:
|
||||
* @window: the offscreen window on which the signal is emitted
|
||||
* @embedder_x: x coordinate in the embedder window
|
||||
* @embedder_y: y coordinate in the embedder window
|
||||
* @offscreen_x: (out) (type double): return location for the x
|
||||
* @embedder-x: x coordinate in the embedder window
|
||||
* @embedder-y: y coordinate in the embedder window
|
||||
* @offscreen-x: (out) (type double): return location for the x
|
||||
* coordinate in the offscreen window
|
||||
* @offscreen_y: (out) (type double): return location for the y
|
||||
* @offscreen-y: (out) (type double): return location for the y
|
||||
* coordinate in the offscreen window
|
||||
*
|
||||
* The ::from-embedder signal is emitted to translate coordinates
|
||||
@@ -1300,8 +1300,7 @@ sync_native_window_stack_position (GdkWindow *window)
|
||||
* @parent: (allow-none): a #GdkWindow, or %NULL to create the window as a child of
|
||||
* the default root window for the default display.
|
||||
* @attributes: attributes of the new window
|
||||
* @attributes_mask: (type GdkWindowAttributesType): mask indicating which
|
||||
* fields in @attributes are valid
|
||||
* @attributes_mask: mask indicating which fields in @attributes are valid
|
||||
*
|
||||
* Creates a new #GdkWindow using the attributes from
|
||||
* @attributes. See #GdkWindowAttr and #GdkWindowAttributesType for
|
||||
|
||||
@@ -220,7 +220,6 @@ const static struct {
|
||||
{ 0xf2c6, GDK_KEY_dead_circumflex },
|
||||
{ 0xf302, GDK_KEY_dead_circumflex },
|
||||
{ 0xf07e, GDK_KEY_dead_tilde },
|
||||
{ 0xf2dc, GDK_KEY_dead_tilde },
|
||||
{ 0xf303, GDK_KEY_dead_tilde },
|
||||
{ 0xf342, GDK_KEY_dead_perispomeni },
|
||||
{ 0xf0af, GDK_KEY_dead_macron },
|
||||
|
||||
@@ -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_keymap_get_group_for_state_libgtk_only (keymap, 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_libgtk_only (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);
|
||||
|
||||
|
||||
@@ -1163,7 +1163,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
event->key.group = xev->group.effective;
|
||||
|
||||
event->key.hardware_keycode = xev->detail;
|
||||
event->key.is_modifier = gdk_x11_keymap_key_is_modifier_libgtk_only (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));
|
||||
|
||||
@@ -659,15 +659,16 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
* means we hid the window ourselves, so we will have already flipped
|
||||
* the iconified bit off.
|
||||
*/
|
||||
if (window && GDK_WINDOW_IS_MAPPED (window))
|
||||
gdk_synthesize_window_state (window,
|
||||
0,
|
||||
GDK_WINDOW_STATE_ICONIFIED);
|
||||
if (window)
|
||||
{
|
||||
if (GDK_WINDOW_IS_MAPPED (window))
|
||||
gdk_synthesize_window_state (window,
|
||||
0,
|
||||
GDK_WINDOW_STATE_ICONIFIED);
|
||||
_gdk_x11_window_grab_check_unmap (window, xevent->xany.serial);
|
||||
}
|
||||
}
|
||||
|
||||
if (window)
|
||||
_gdk_x11_window_grab_check_unmap (window, xevent->xany.serial);
|
||||
|
||||
break;
|
||||
|
||||
case MapNotify:
|
||||
|
||||
@@ -240,12 +240,12 @@ gdk_drag_context_find (GdkDisplay *display,
|
||||
Window source_xid,
|
||||
Window dest_xid)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GList *tmp_list = contexts;
|
||||
GdkDragContext *context;
|
||||
GdkX11DragContext *context_x11;
|
||||
Window context_dest_xid;
|
||||
|
||||
for (tmp_list = contexts; tmp_list; tmp_list = tmp_list->next)
|
||||
while (tmp_list)
|
||||
{
|
||||
context = (GdkDragContext *)tmp_list->data;
|
||||
context_x11 = (GdkX11DragContext *)context;
|
||||
@@ -265,6 +265,8 @@ gdk_drag_context_find (GdkDisplay *display,
|
||||
(GDK_WINDOW_XID (context->source_window) == source_xid))) &&
|
||||
((dest_xid == None) || (context_dest_xid == dest_xid)))
|
||||
return context;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
+10
-6
@@ -1430,7 +1430,7 @@ _gdk_x11_display_manager_keyval_convert_case (GdkDisplayManager *manager,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_x11_keymap_get_group_for_state_libgtk_only:
|
||||
* gdk_x11_keymap_get_group_for_state:
|
||||
* @keymap: a #GdkX11Keymap
|
||||
* @state: raw state returned from X
|
||||
*
|
||||
@@ -1439,10 +1439,12 @@ _gdk_x11_display_manager_keyval_convert_case (GdkDisplayManager *manager,
|
||||
* directly includes an is_modifier field.
|
||||
*
|
||||
* Returns: the index of the active keyboard group for the event
|
||||
*
|
||||
* Since: 3.6
|
||||
*/
|
||||
gint
|
||||
gdk_x11_keymap_get_group_for_state_libgtk_only (GdkKeymap *keymap,
|
||||
guint state)
|
||||
gdk_x11_keymap_get_group_for_state (GdkKeymap *keymap,
|
||||
guint state)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkX11Display *display_x11;
|
||||
@@ -1516,7 +1518,7 @@ gdk_x11_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_x11_keymap_key_is_modifier_libgtk_only:
|
||||
* gdk_x11_keymap_key_is_modifier:
|
||||
* @keymap: a #GdkX11Keymap
|
||||
* @keycode: the hardware keycode from a key event
|
||||
*
|
||||
@@ -1528,10 +1530,12 @@ gdk_x11_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
* an is_modifier field.
|
||||
*
|
||||
* Returns: %TRUE if the hardware keycode is a modifier key
|
||||
*
|
||||
* Since: 3.6
|
||||
*/
|
||||
gboolean
|
||||
gdk_x11_keymap_key_is_modifier_libgtk_only (GdkKeymap *keymap,
|
||||
guint keycode)
|
||||
gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
|
||||
guint keycode)
|
||||
{
|
||||
GdkX11Keymap *keymap_x11 = GDK_X11_KEYMAP (keymap);
|
||||
gint i;
|
||||
|
||||
@@ -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,11 +42,13 @@ typedef struct _GdkX11KeymapClass GdkX11KeymapClass;
|
||||
|
||||
GType gdk_x11_keymap_get_type (void);
|
||||
|
||||
gint gdk_x11_keymap_get_group_for_state_libgtk_only (GdkKeymap *keymap,
|
||||
guint state);
|
||||
GDK_AVAILABLE_IN_3_6
|
||||
gint gdk_x11_keymap_get_group_for_state (GdkKeymap *keymap,
|
||||
guint state);
|
||||
|
||||
gboolean gdk_x11_keymap_key_is_modifier_libgtk_only (GdkKeymap *keymap,
|
||||
guint keycode);
|
||||
GDK_AVAILABLE_IN_3_6
|
||||
gboolean gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
|
||||
guint keycode);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_X11_KEYMAP_H__ */
|
||||
|
||||
+56
-13
@@ -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,7 +909,7 @@ gtk_use_win32_c_sources = \
|
||||
gtk_use_quartz_c_sources = \
|
||||
gtksearchenginequartz.c \
|
||||
gtkmountoperation-stub.c \
|
||||
gtkquartz-menu.c \
|
||||
gtkmodelmenu-quartz.c \
|
||||
gtkquartz.c
|
||||
gtk_use_stub_c_sources = \
|
||||
gtkmountoperation-stub.c
|
||||
@@ -889,7 +933,7 @@ endif
|
||||
|
||||
gtk_use_quartz_private_h_sources = \
|
||||
gtksearchenginequartz.h \
|
||||
gtkquartz-menu.h \
|
||||
gtkmodelmenu-quartz.h \
|
||||
gtkquartz.h
|
||||
if USE_QUARTZ
|
||||
gtk_c_sources += $(gtk_use_quartz_c_sources)
|
||||
@@ -898,9 +942,8 @@ gtk_private_h_sources += $(gtk_use_quartz_private_h_sources)
|
||||
endif
|
||||
|
||||
gtk_all_private_h_sources = \
|
||||
$(gtk_private_h_sources) \
|
||||
$(gtk_use_x11_private_h_sources) \
|
||||
$(gtk_use_win32_private_h_sources) \
|
||||
$(gtk_use_win32_private_h_sources) \
|
||||
$(gtk_use_quartz_private_h_sources)
|
||||
|
||||
if !USE_X11
|
||||
@@ -1109,7 +1152,7 @@ endif
|
||||
|
||||
if USE_QUARTZ
|
||||
install-mac-key-theme:
|
||||
$(MKDIR_P) $(DESTDIR)$(datadir)/themes/Mac/gtk-3.0
|
||||
$(mkdir_p) $(DESTDIR)$(datadir)/themes/Mac/gtk-3.0
|
||||
$(INSTALL_DATA) $(srcdir)/gtk-keys.css.mac $(DESTDIR)$(datadir)/themes/Mac/gtk-3.0/gtk-keys.css
|
||||
uninstall-mac-key-theme:
|
||||
rm -f $(DESTDIR)$(datadir)/themes/Mac/gtk-3.0/gtk-keys.css
|
||||
@@ -1152,9 +1195,9 @@ dist-hook: ../build/win32/vs9/gtk.vcproj ../build/win32/vs10/gtk.vcxproj ../buil
|
||||
|
||||
# Install a RC file for the default GTK+ theme, and key themes
|
||||
install-data-local: install-ms-lib install-def-file install-mac-key-theme
|
||||
$(MKDIR_P) $(DESTDIR)$(datadir)/themes/Default/gtk-3.0
|
||||
$(mkdir_p) $(DESTDIR)$(datadir)/themes/Default/gtk-3.0
|
||||
$(INSTALL_DATA) $(srcdir)/gtk-keys.css.default $(DESTDIR)$(datadir)/themes/Default/gtk-3.0/gtk-keys.css
|
||||
$(MKDIR_P) $(DESTDIR)$(datadir)/themes/Emacs/gtk-3.0
|
||||
$(mkdir_p) $(DESTDIR)$(datadir)/themes/Emacs/gtk-3.0
|
||||
$(INSTALL_DATA) $(srcdir)/gtk-keys.css.emacs $(DESTDIR)$(datadir)/themes/Emacs/gtk-3.0/gtk-keys.css
|
||||
|
||||
uninstall-local: uninstall-ms-lib uninstall-def-file uninstall-mac-key-theme
|
||||
|
||||
@@ -542,8 +542,11 @@ gtk_text_cell_accessible_get_character_extents (AtkText *text,
|
||||
gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer);
|
||||
|
||||
g_object_get (gtk_renderer, "text", &renderer_text, NULL);
|
||||
if (renderer_text == NULL)
|
||||
return;
|
||||
if (text == NULL)
|
||||
{
|
||||
g_free (renderer_text);
|
||||
return;
|
||||
}
|
||||
|
||||
parent = atk_object_get_parent (ATK_OBJECT (text));
|
||||
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
|
||||
|
||||
@@ -1785,41 +1785,24 @@ _gtk_tree_view_accessible_toggle_visibility (GtkTreeView *treeview,
|
||||
GtkTreeViewColumn *column)
|
||||
{
|
||||
AtkObject *obj;
|
||||
guint i, id;
|
||||
guint id;
|
||||
|
||||
obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
|
||||
if (obj == NULL)
|
||||
return;
|
||||
|
||||
id = get_column_number (treeview, column);
|
||||
|
||||
if (gtk_tree_view_column_get_visible (column))
|
||||
{
|
||||
id = get_column_number (treeview, column);
|
||||
|
||||
_gtk_tree_view_accessible_do_add_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
|
||||
treeview,
|
||||
column,
|
||||
id);
|
||||
}
|
||||
_gtk_tree_view_accessible_do_add_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
|
||||
treeview,
|
||||
column,
|
||||
id);
|
||||
else
|
||||
{
|
||||
id = 0;
|
||||
|
||||
for (i = 0; i < gtk_tree_view_get_n_columns (treeview); i++)
|
||||
{
|
||||
GtkTreeViewColumn *cur = gtk_tree_view_get_column (treeview, i);
|
||||
|
||||
if (gtk_tree_view_column_get_visible (cur))
|
||||
id++;
|
||||
|
||||
if (cur == column)
|
||||
break;
|
||||
}
|
||||
|
||||
_gtk_tree_view_accessible_do_remove_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
|
||||
treeview,
|
||||
column,
|
||||
id);
|
||||
}
|
||||
_gtk_tree_view_accessible_do_remove_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
|
||||
treeview,
|
||||
column,
|
||||
id);
|
||||
}
|
||||
|
||||
static GtkTreeViewColumn *
|
||||
|
||||
+36
-15
@@ -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)
|
||||
@@ -821,11 +823,12 @@ gtk_font_selection_show_available_fonts (GtkFontSelection *fontsel)
|
||||
const gchar *name = pango_font_family_get_name (families[i]);
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_list_store_insert_with_values (model, &iter, -1,
|
||||
FAMILY_COLUMN, families[i],
|
||||
FAMILY_NAME_COLUMN, name,
|
||||
-1);
|
||||
|
||||
gtk_list_store_append (model, &iter);
|
||||
gtk_list_store_set (model, &iter,
|
||||
FAMILY_COLUMN, families[i],
|
||||
FAMILY_NAME_COLUMN, name,
|
||||
-1);
|
||||
|
||||
if (i == 0 || !g_ascii_strcasecmp (name, "sans"))
|
||||
{
|
||||
match_family = families[i];
|
||||
@@ -922,10 +925,11 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
|
||||
GtkTreeIter iter;
|
||||
const gchar *str = pango_font_face_get_face_name (faces[i]);
|
||||
|
||||
gtk_list_store_insert_with_values (model, &iter, -1,
|
||||
FACE_COLUMN, faces[i],
|
||||
FACE_NAME_COLUMN, str,
|
||||
-1);
|
||||
gtk_list_store_append (model, &iter);
|
||||
gtk_list_store_set (model, &iter,
|
||||
FACE_COLUMN, faces[i],
|
||||
FACE_NAME_COLUMN, str,
|
||||
-1);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
@@ -1032,8 +1036,8 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_list_store_insert_with_values (model, &iter, -1,
|
||||
SIZE_COLUMN, font_sizes[i], -1);
|
||||
gtk_list_store_append (model, &iter);
|
||||
gtk_list_store_set (model, &iter, SIZE_COLUMN, font_sizes[i], -1);
|
||||
|
||||
if (font_sizes[i] * PANGO_SCALE == priv->size)
|
||||
set_cursor_to_iter (GTK_TREE_VIEW (priv->size_list), &iter);
|
||||
@@ -1053,8 +1057,7 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
|
||||
found = TRUE;
|
||||
}
|
||||
|
||||
if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter))
|
||||
break;
|
||||
gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter);
|
||||
}
|
||||
|
||||
if (!found)
|
||||
@@ -1182,18 +1185,36 @@ gtk_font_selection_get_font_description (GtkFontSelection *fontsel)
|
||||
return font_desc;
|
||||
}
|
||||
|
||||
/* This sets the font in the preview entry to the selected font.
|
||||
/* This sets the font in the preview entry to the selected font,
|
||||
* and tries to make sure that the preview entry is a reasonable
|
||||
* size, i.e. so that the text can be seen with a bit of space to
|
||||
* spare. But it tries to avoid resizing the entry every time the
|
||||
* font changes. This also used to shrink the preview if the font
|
||||
* size was decreased, but that made it awkward if the user wanted
|
||||
* to resize the window themself.
|
||||
*/
|
||||
static void
|
||||
gtk_font_selection_update_preview (GtkFontSelection *fontsel)
|
||||
{
|
||||
GtkFontSelectionPrivate *priv = fontsel->priv;
|
||||
gint new_height;
|
||||
GtkRequisition old_requisition, new_requisition;
|
||||
GtkWidget *preview_entry = priv->preview_entry;
|
||||
const gchar *text;
|
||||
|
||||
gtk_widget_get_preferred_size (preview_entry, &old_requisition, NULL);
|
||||
|
||||
gtk_widget_override_font (preview_entry,
|
||||
gtk_font_selection_get_font_description (fontsel));
|
||||
|
||||
gtk_widget_get_preferred_size (preview_entry, &new_requisition, NULL);
|
||||
|
||||
/* We don't ever want to be over MAX_PREVIEW_HEIGHT pixels high. */
|
||||
new_height = CLAMP (new_requisition.height, INITIAL_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT);
|
||||
|
||||
if (new_height > old_requisition.height || new_height < old_requisition.height - 30)
|
||||
gtk_widget_set_size_request (preview_entry, -1, new_height);
|
||||
|
||||
/* This sets the preview text, if it hasn't been set already. */
|
||||
text = gtk_entry_get_text (GTK_ENTRY (preview_entry));
|
||||
if (strlen (text) == 0)
|
||||
|
||||
@@ -673,7 +673,7 @@ set_color (GtkStyle *style,
|
||||
break;
|
||||
}
|
||||
|
||||
if (color && color->alpha > 0.01)
|
||||
if (color)
|
||||
{
|
||||
dest->pixel = 0;
|
||||
dest->red = CLAMP ((guint) (color->red * 65535), 0, 65535);
|
||||
|
||||
+4
-5
@@ -352,11 +352,6 @@ static void
|
||||
g_action_muxer_free_group (gpointer data)
|
||||
{
|
||||
Group *group = data;
|
||||
gint i;
|
||||
|
||||
/* 'for loop' or 'four loop'? */
|
||||
for (i = 0; i < 4; i++)
|
||||
g_signal_handler_disconnect (group->group, group->handler_ids[i]);
|
||||
|
||||
g_object_unref (group->group);
|
||||
g_free (group->prefix);
|
||||
@@ -490,6 +485,10 @@ g_action_muxer_remove (GActionMuxer *muxer,
|
||||
g_action_muxer_action_removed (group->group, actions[i], group);
|
||||
g_strfreev (actions);
|
||||
|
||||
/* 'for loop' or 'four loop'? */
|
||||
for (i = 0; i < 4; i++)
|
||||
g_signal_handler_disconnect (group->group, group->handler_ids[i]);
|
||||
|
||||
g_action_muxer_free_group (group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
-1
@@ -149,7 +149,7 @@ gtk_accel_group_class_init (GtkAccelGroupClass *class)
|
||||
* @modifier: the modifier combination of the accelerator
|
||||
* @accel_closure: the #GClosure of the accelerator
|
||||
*
|
||||
* The accel-changed signal is emitted when an entry
|
||||
* The accel-changed signal is emitted when a #GtkAccelGroupEntry
|
||||
* is added to or removed from the accel group.
|
||||
*
|
||||
* Widgets like #GtkAccelLabel which display an associated
|
||||
|
||||
@@ -207,9 +207,6 @@ _gtk_accel_path_is_valid (const gchar *accel_path)
|
||||
* To change the accelerator during runtime programatically, use
|
||||
* gtk_accel_map_change_entry().
|
||||
*
|
||||
* Set @accel_key and @accel_mods to 0 to request a removal of
|
||||
* the accelerator.
|
||||
*
|
||||
* Note that @accel_path string will be stored in a #GQuark. Therefore, if you
|
||||
* pass a static string, you can save some memory by interning it first with
|
||||
* g_intern_static_string().
|
||||
|
||||
@@ -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__ */
|
||||
+40
-39
@@ -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;
|
||||
@@ -255,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);
|
||||
@@ -274,37 +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;
|
||||
|
||||
if (appid == NULL)
|
||||
return g_strdup ("/org/gtk/Application/anonymous");
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -312,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);
|
||||
@@ -322,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)
|
||||
{
|
||||
@@ -532,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
|
||||
@@ -811,7 +784,7 @@ GtkApplication *
|
||||
gtk_application_new (const gchar *application_id,
|
||||
GApplicationFlags flags)
|
||||
{
|
||||
g_return_val_if_fail (application_id == NULL || g_application_id_is_valid (application_id), NULL);
|
||||
g_return_val_if_fail (g_application_id_is_valid (application_id), NULL);
|
||||
|
||||
g_type_init ();
|
||||
|
||||
@@ -904,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -218,6 +218,8 @@ struct _GtkApplicationWindowPrivate
|
||||
GDBusConnection *session;
|
||||
gchar *object_path;
|
||||
guint export_id;
|
||||
|
||||
guint id;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -258,7 +260,7 @@ gtk_application_window_update_menubar (GtkApplicationWindow *window)
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gtk_application_window_get_app_desktop_name ()
|
||||
gtk_application_window_get_app_desktop_name (void)
|
||||
{
|
||||
gchar *retval = NULL;
|
||||
|
||||
@@ -777,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);
|
||||
@@ -809,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),
|
||||
@@ -824,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;
|
||||
}
|
||||
@@ -834,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;
|
||||
@@ -1086,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__ */
|
||||
|
||||
+2
-2
@@ -1005,11 +1005,11 @@ gtk_assistant_init (GtkAssistant *assistant)
|
||||
gtk_button_set_image (GTK_BUTTON (priv->forward),
|
||||
gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON));
|
||||
priv->back = gtk_button_new_with_mnemonic (_("Go _Back"));
|
||||
gtk_button_set_image (GTK_BUTTON (priv->back),
|
||||
gtk_button_set_image (GTK_BUTTON (priv->forward),
|
||||
gtk_image_new_from_stock (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
|
||||
priv->cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
||||
priv->last = gtk_button_new_with_mnemonic (_("_Finish"));
|
||||
gtk_button_set_image (GTK_BUTTON (priv->last),
|
||||
gtk_button_set_image (GTK_BUTTON (priv->forward),
|
||||
gtk_image_new_from_stock (GTK_STOCK_GOTO_LAST, GTK_ICON_SIZE_BUTTON));
|
||||
gtk_widget_set_can_default (priv->close, TRUE);
|
||||
gtk_widget_set_can_default (priv->apply, TRUE);
|
||||
|
||||
+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
-4
@@ -81,11 +81,11 @@
|
||||
#include "gtkboxprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkorientableprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkwidgetpath.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "a11y/gtkboxaccessible.h"
|
||||
|
||||
|
||||
@@ -354,7 +354,6 @@ gtk_box_set_property (GObject *object,
|
||||
{
|
||||
case PROP_ORIENTATION:
|
||||
private->orientation = g_value_get_enum (value);
|
||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
|
||||
gtk_widget_queue_resize (GTK_WIDGET (box));
|
||||
break;
|
||||
case PROP_SPACING:
|
||||
@@ -900,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))
|
||||
{
|
||||
@@ -939,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);
|
||||
}
|
||||
|
||||
|
||||
+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
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
* elements on a #cairo_t. Typically, one cell renderer is used to
|
||||
* draw many cells on the screen. To this extent, it isn't expected that a
|
||||
* CellRenderer keep any permanent state around. Instead, any state is set
|
||||
* just prior to use using #GObjects property system. Then, the
|
||||
* just prior to use using #GObject<!-- -->s property system. Then, the
|
||||
* cell is measured using gtk_cell_renderer_get_size(). Finally, the cell
|
||||
* is rendered in the correct location using gtk_cell_renderer_render().
|
||||
*
|
||||
* There are a number of rules that must be followed when writing a new
|
||||
* #GtkCellRenderer. First and foremost, its important that a certain set
|
||||
* #GtkCellRenderer. First and formost, its important that a certain set
|
||||
* of properties will always yield a cell renderer of the same size,
|
||||
* barring a #GtkStyle change. The #GtkCellRenderer also has a number of
|
||||
* generic properties that are expected to be honored by all children.
|
||||
@@ -60,11 +60,6 @@
|
||||
* To make a cell renderer activatable or editable, you have to
|
||||
* implement the #GtkCellRendererClass.activate or
|
||||
* #GtkCellRendererClass.start_editing virtual functions, respectively.
|
||||
*
|
||||
* Many properties of #GtkCellRenderer and its subclasses have a
|
||||
* corresponding "set" property, e.g. "cell-background-set" corresponds
|
||||
* to "cell-background". These "set" properties reflect whether a property
|
||||
* has been set or not. You should not set them independently.
|
||||
*/
|
||||
|
||||
|
||||
@@ -425,7 +420,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
|
||||
|
||||
ADD_SET_PROP ("cell-background-set", PROP_CELL_BACKGROUND_SET,
|
||||
P_("Cell background set"),
|
||||
P_("Whether the cell background color is set"));
|
||||
P_("Whether this tag affects the cell background color"));
|
||||
|
||||
g_type_class_add_private (class, sizeof (GtkCellRendererPrivate));
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user