Compare commits

..

349 Commits

Author SHA1 Message Date
Matthias Clasen fd8306f340 Remove lies
We forgot the documentation when we simplified the GtkApplication
session api.
2012-05-11 17:42:47 -04:00
Benjamin Otte e12b785653 tests: USE ALL THE WORDS! 2012-05-11 04:46:40 +02:00
Benjamin Otte fe421e1a7d listview: Reduce the amount of widgets we pre-allocate for sizing
This is getting kinda dangerous because we imply that a child is at
least 4px high by now.
2012-05-11 04:46:40 +02:00
Benjamin Otte 3bb8419dff listview: Implement scrolling 2012-05-11 04:46:40 +02:00
Benjamin Otte b5dc516704 iconview: Don't draw unallocated items
This is more a workaround for Clutter-GTK than anything else. Most of
all, it makes gnome-boxes start again.
2012-05-09 14:12:24 +02:00
Benjamin Otte e34702911b listview: Add a scrollbar
The scrollbar doesn't do anything. It's just put in the correct place.
2012-05-09 08:31:26 +02:00
Benjamin Otte 5822782963 listview: Add vfuncs for widget management
No public API yet, I don't have a good one...
2012-05-09 07:49:45 +02:00
Benjamin Otte 02bc5022fa tests: Add testlistview 2012-05-09 05:06:56 +02:00
Benjamin Otte b794cdbb0a listview: Add skeleton
The widget doesn't do very much yet. But at least it prints lots of
"Hello world".
2012-05-09 05:06:22 +02:00
Benjamin Otte d736d06db8 iconview: Only compute item sizes in one place
Code was using different places to compute the icon size when layouting
and when doing size requests. This resulted in non-matching behavior in
obscure cases. And that lead to iconviews that were too small.
2012-05-08 03:58:23 +02:00
Benjamin Otte e31fb77c22 iconview: Bring back per-row contexts
Apparently GtkCellAreaContext is broken enough to not allow multiple
allocations...
2012-05-08 03:58:23 +02:00
Benjamin Otte e8eeb39d98 iconview: Move wrap width adjustment to size request code 2012-05-08 03:58:23 +02:00
Benjamin Otte f51c9d4154 stylecontext: Make queue_invalidate() always work
Handle both the case where a widget is set and also the case where a
widget path is set.
2012-05-08 03:58:23 +02:00
Rui Matos a0f155e839 immulticontext: Always check if the global context id changed
This makes sure that if the gtk-im-module setting changes we update
our internal state immediately on the next event whichever it is.

In particular this fixes the case of the gtk-im-module setting
changing while the user is typing and the slave context remaining the
same, effectively ignoring the setting change.

https://bugzilla.gnome.org/show_bug.cgi?id=675365
2012-05-08 00:35:30 +02:00
Cosimo Cecchi a4d76439e6 infobar: set default border/spacing on action/content areas
Commit cdf473ec10 deprecated the style
properties associated with the container border width and box spacing of
the action and content areas, in favour of using
gtk_container_set_border_width() and gtk_box_set_spacing() on the
widgets themselves, but failed to initialize those values to the
defaults.
2012-05-07 18:06:32 -04:00
John Ralls 985881ffcc [Bug 675501] gtkquartz.h is not in the gtk+-3.5.2.tar.xz archive
Rearrange the gtk_private_h_sources so that they're all added to EXTRA_DIST instead of only the ones included in the current build.
2012-05-07 14:59:06 -07:00
John Ralls b5bcdbc10f Rename gtkquartz-menu to gtkmodelmenu-quartz
Makes name consistent with other quartz-only modules and makes it clear that this works with the GMenuModel system rather than the older GtkMenu system.
2012-05-07 14:59:06 -07:00
Federico Mena Quintero e00847b0d5 bgo#675421 - Set the wm_role on GtkFileChooserDialog
The window's role is 'GtkFileChooserDialog', so that window managers can match it
for positioning.

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
2012-05-07 15:42:32 -05:00
Benjamin Otte 5722f9ab0f sizerequest: Improve warning message
Actually print out the function we're warning about
2012-05-07 17:37:36 +02:00
Benjamin Otte 86cebc9b43 iconview: Fix negative natural size request on empty iconview 2012-05-07 17:19:10 +02:00
Benjamin Otte 78638f798b broadway: Fix vfunc prototype 2012-05-07 04:12:29 +02:00
Benjamin Otte 20583c6d98 build: Don't invoke pkg-config directly
Instead, always use PKG_CHECK_MODULES(). That macro actually gets it
right. In particular the erroring out part when you miss xkbcommon or
wayland-client.
2012-05-07 04:12:26 +02:00
Benjamin Otte e133c6cb71 iconview: Don't expand items to more than natural size
This ensures that items stay left-aligned instead of slowly expanding into
empty space when widening the iconview. It's also what the iconview did
pre-refactoring.

Note that for cases where natural width != minimum width, the cells
might still expand and shrink back.
2012-05-07 01:37:27 +02:00
Benjamin Otte e187cda5e9 tests: Remove unused include
Fixes build
2012-05-07 00:16:45 +02:00
Benjamin Otte d20d7c54d3 iconview: Redo layouting 2012-05-07 00:12:26 +02:00
Benjamin Otte b7385ffcab iconview: Respect item width in size requestr code 2012-05-07 00:12:26 +02:00
Benjamin Otte d406bf96d4 iconview: Reduce complexity of sizing code
Always assume max-columns and min-rows. The old approach was kinda
insane.

As an example, try to write an algorithm that optimizes the minimum size
for infinite (take a reasonably large number like 2520) word-wrapped
Monospace text cells containing the text "XXXXX XXX XXX XXXXX" (keep in
mind that this is the easy problem, because it's assuming equal cell
renderers). There's 4 ways to reasonably lay out this text:
19 glyphs (19x1):
  XXXXX XXX XXX XXXXX
18 glyphs (9x2):
  XXXXX XXX
  XXX XXXXX
21 glyphs (7x3):
  XXXXX
  XXX XXX
  XXXXX
20 glyphs (5x4):
  XXXXX
  XXX
  XXX
  XXXXX
The best thing to do usually is using the 9x2 approach, but that's
neither the one using the natural nor the one using the minimum size.

As a side note, this does not include spacing and padding, which might
also influence the decision. Nor does it include height-for-width
considerations. Look at this table (numbers given in glyphs, not pixels,
as for pixel-sizes it gets even more interesting):
  given  best solution
  width  columns  sizing  glyphs per cell
   6      1       6x4           20
   7      1       7x3           21
   8      1       7x3           24
   9      1       9x2           18
  10      1/2     9x2/5x4       20
  11      1/2     9x2/5x4       22
  12      1/2     9x2/5x4       24
  13      1/2     9x2/5x4       26
  14      2       7x3           21
  15      3       5x4           20
  16      3       5x4           21.3
  17      3       5x4           22.7
  18      2       9x2           18
  19      1/2    19x1/8x2       19
  20      1/2/4  19x1/8x2/5x4   20
  21      1-4     any           21
  22      1-4     any           22
  23      1-4     any           23
  24      1-4     any           24
  25      5       5x4           20
  26      5       5x4           20.8
  27      3       9x2           18
  28      3       9x2           18.7
  29      3       9x2           19.3
  30      3/6     9x2/5x4       20

Now of course, nobody wants the number of columns to randomly change in
inexplicable ways while they enlarge or shrink an iconview, so we not
only have to optimize for smallest or other size measurements, but we
also have to optimize for "most pleasing to the eye".

And last but not least, I'd like to once again remind you - if you kept
up until now - that this discussion was for identically-sized cells
only.
2012-05-07 00:12:26 +02:00
Benjamin Otte 2da7a6d803 tests: Make testcellarea use an iconview 2012-05-07 00:12:26 +02:00
Benjamin Otte 65ad492c24 iconview: Redo size requests
Instead of just returning the last allocated numbers, we now compute the
proper sizes from scratch. This is a bit less trivial, but it results in
proper height-for-width handling.
2012-05-07 00:12:26 +02:00
Benjamin Otte 63ddb3f2c7 iconview: Don't cache iters
This is a huge quest to remove all caching from GtkIconview to simplify
the code. As it turns out, iconview performance is a joke, so the caches
are kinda unnecessary.

If we need caching, we can add it in a useful way later.
2012-05-07 00:12:26 +02:00
Benjamin Otte ee91e272a8 iconview: Remove needless requirement
If we use
  &item->cell_area
instead of
  (GdkRectangle *) item
there is no need anymore to keep the cell_area as the first member of
the the item. And we cget compile-time checks for changes to the item
struct.
2012-05-07 00:12:26 +02:00
José Alburquerque 7604e2d418 gtk_entry_[get|set]_inner_border(): Clarify the deprecation docs. 2012-05-06 15:05:27 -04:00
Paolo Borelli 3b0cd0eb8a [socket]: fix gtk-doc warnings. 2012-05-06 12:37:59 +02:00
Marc-André Lureau 4884a7c1af gdk: do not send leave event on touchpad button release
This is along the changes introduced in
bd55519f7e,
A TOUCHPAD device behaves like a mouse"

https://bugzilla.gnome.org/show_bug.cgi?id=674549
2012-05-05 14:39:37 -04:00
Yaron Shahrabani 321d06117f Updated Hebrew translation. 2012-05-05 18:22:56 +03:00
Fran Diéguez 3ad3a6699a Updated Galician translations 2012-05-05 15:18:26 +02:00
Cosimo Cecchi e5f0e30843 themingengine: don't hardcode the slider lines in the theming engine
It's wrong to hardcode the slider lines here; those should be rendered
as an additional background layer using background-image if the theme
specifies so.

https://bugzilla.gnome.org/show_bug.cgi?id=652304
2012-05-04 16:47:24 -04:00
Cosimo Cecchi 5a8e2b5995 entry-completion: set size request on the toplevel window
Instead of setting it on the child scrolled window. This is needed
because the whole window's allocation must be equal to the one of the
entry (in case the popup-set-width property is TRUE); if we set the size
request on a children of the window, there might be other children with
borders/paddings in between the toplevel and the child we set the size
request too, which will break alignment.

https://bugzilla.gnome.org/show_bug.cgi?id=672947
2012-05-04 15:43:29 -04:00
Cosimo Cecchi 644070b551 entry-completion: don't subtract entry borders from popup allocation
The completion popup should be aligned with the GtkEntry allocation, not
less than that.

https://bugzilla.gnome.org/show_bug.cgi?id=672947
2012-05-04 15:43:27 -04:00
Daniel Mustieles 3f54cf9e78 Updated Spanish translation 2012-05-04 14:16:45 +02:00
Carlos Garcia Campos a18f018d87 cellrenderertext: Add placeholder-text property
It works similar to placeholder text in a GtkEntry, if the cell renderer
is editable and it's empty, the placeholder text is displayed.
https://bugzilla.gnome.org/show_bug.cgi?id=645514
2012-05-03 23:35:34 -04:00
David King 2d10c8844e docs: Improve GtkMessageDialog description
Add mention of default setting of GtkWindow:skip-taskbar-hint.

https://bugzilla.gnome.org/show_bug.cgi?id=587873
2012-05-04 03:09:13 +01:00
David King e6daedae0a docs: Move GtkSelectionData to gtk3-Selections
Put the (albeit empty) documentation for the GtkSelectionData struct
with the gtk_selection_data_*() methods.

https://bugzilla.gnome.org/show_bug.cgi?id=663072
2012-05-04 03:06:47 +01:00
David King da1a90bcaf docs: Correct gtk_tree_row_reference_new() description
Remove the text that mentions listening to tree model signals, and
instead say that any changes are automatically propagated.

https://bugzilla.gnome.org/show_bug.cgi?id=478344
2012-05-04 03:04:58 +01:00
Bastien Nocera c1f01eb929 Add support for disabling middle click paste
Adds a gtk-enable-primary-paste setting that is backed by
and X setting, and make GtkEntry and GtkTextView respect it.

https://bugzilla.gnome.org/show_bug.cgi?id=665243
2012-05-03 21:59:54 -04:00
Ryan Lortie 88c63903a5 printing: Rename GTK_UNIT_PIXEL to GTK_UNIT_NONE
...and document that many functions don't accept "none" as a unit.

https://bugzilla.gnome.org/show_bug.cgi?id=460908
2012-05-03 18:30:48 -07:00
Dan Winship 154ce014a8 gdk: add bindings-friendly alias for GDK_EVENT_2BUTTON_PRESS
GDK_EVENT_2BUTTON_PRESS and GDK_EVENT_3BUTTON_PRESS can't be used from
some bindings because they'd translate to something syntactically
invalid. Add GDK_EVENT_DOUBLE_BUTTON_PRESS and
GDK_EVENT_TRIPLE_BUTTON_PRESS aliases to work around that.

https://bugzilla.gnome.org/show_bug.cgi?id=671025
2012-05-03 21:22:39 -04:00
Rui Matos 4d7c7ec32f window: Remove needless call to ensure_state_flag_backdrop() on map
This call was forcing needless work since gtk_window_map() already
does a gdk_window_show() which initially sets GDK_WINDOW_STATE_FOCUSED
that we then handle regularly on the widget's window state event
handler.

https://bugzilla.gnome.org/show_bug.cgi?id=673237
2012-05-03 17:24:05 -07:00
Michael Biebl 7c038b1b33 build: Fix out-of-tree build of widget-factory demo application
https://bugzilla.gnome.org/show_bug.cgi?id=674192
2012-05-03 17:22:11 -07:00
Reinout van Schouwen 549ec0d190 Updated Dutch po-properties translation by Rachid, reviewed by Reinout
van Schouwen.
2012-05-04 00:23:36 +02:00
Matthias Clasen 823ee6d529 Fix unclosed comments 2012-05-03 16:11:14 -04:00
Cosimo Cecchi b9eb02ebbe colorbutton: don't hardcode a 16px margin around the color sample
Since themes might want different paddings around the color sample
according to where it's being used, don't hardcode a 16px one here.
The theme can specify a padding to get the same effect.

Reported by Christian Persch <chpe@gnome.org>
2012-05-03 15:03:22 -04:00
Christian Persch 4b4ec4472c application: Fix build without x11 2012-05-03 18:47:58 +02:00
Christian Persch ff66d0d8e5 application: Add unique IDs for GtkApplicationWindow
This will allow to refer to specific GtkApplicationWindows remotely by ID.

https://bugzilla.gnome.org/show_bug.cgi?id=674409
2012-05-03 17:45:46 +02:00
Emmanuele Bassi 824776cb02 fontsel: Add a deprecation note in the constructor docs
To match the compiler attribute, otherwise the introspection scanner
will not pick up the deprecation.
2012-05-03 08:07:13 +01:00
Chun-wei Fan 5f61f40601 Bug 670499-gtk/fallback-c89.c: Add fallback for nearbyint()
This adds a C89 implementation for nearbyint() as it is a function that
is only made available in C99.
2012-05-03 11:59:16 +08:00
Chun-wei Fan a5626c489e Bug 670499-gdk/gdkrgba.c: Include fallback-c89.c
Include (gdk/)fallback-c89.c as isnan() and isinf() is used.
2012-05-03 11:55:20 +08:00
Chun-wei Fan 4f56f53ad7 Bug 670499-Add gdk/fallback-c89.c
Add a fallback-c89.c for the gdk/ subdirectory as there is code that uses
functions that are introduced by C99.  This currently adds fallback
implementations for MSVC for isnan() and isinf()

Dist this "new" source file as well
2012-05-03 11:55:11 +08:00
Chun-wei Fan c97f0b660c Bug 670499-configure.ac: Check for nearbyint(), isinf() and isnan()
nearbyint(), isinf() and isnan() are C99 functions, so check for them.

Also clean up configure.ac a little bit as the checks for rint() and
round() can be a bit simpler, according to Matthias' suggestions.
2012-05-03 11:54:41 +08:00
Chun-wei Fan 2969db9993 Bug 670449-gtk/gtksettings.c: Fix build on Windows
On Windows, gtkwin32themeprivate.h is needed as
_gtk_win32_theme_get_default() is called on that platform to avoid C4013
warnings/errors (aka implicit declaration of ... for GCC folks).
2012-05-03 11:54:15 +08:00
Cosimo Cecchi aeb5cb2caa pathbar: fix a copy/paste error from last commit
We need to update the child pointer to the current iterator when going
trough the button list.
2012-05-02 11:49:40 -04:00
Benjamin Otte 0743cef50d stylecontext: Disallow adding/removing GtkSettings style providers
Adding "system" providers like the GtkSettings object shouldn't be
allowed at all, so ensure that it indeed is not.
2012-05-02 17:04:49 +02:00
Benjamin Otte 01b75f19a6 pathbar: Only invalidate styles in allocate if stuff really changed
I still don't like queueing restyles in size_allocate(), but I can't
come up with a better mechanims for the way the pathbar works today.
2012-05-02 17:04:49 +02:00
Dimitris Spingos 532c66df81 Updated Greek translation 2012-05-02 12:21:52 +03:00
Benjamin Otte 793748eadd debug: Add GTK_DEBUG=no-css-cache
See inline comments for what it does. Its main use is figuring out if
something has been caused by GTK's caching of CSS properties or if it's
a different problem.
2012-05-02 02:00:11 +02:00
Benjamin Otte b0317280e7 build: Set G_ENABLE_DEBUG for minimal --enable-debug=minimum
With that flag set, we get GDK_DEBUG and GTK_DEBUG support. And those
provide useful features we want when debugging.
2012-05-02 02:00:11 +02:00
Benjamin Otte d22a632b54 window: Validate style context before first allocation
When we don't do that, we completely botch sizing popups. Not good.

Fixes remaining failing reftests
2012-05-02 02:00:11 +02:00
Benjamin Otte 40915d9a34 reftests: Remove unneeded event boxes
The event boxes break when backgrounds are transparent.

Fixes border-image-repeat.ui reftest.
2012-05-02 02:00:11 +02:00
Benjamin Otte d7992d0f4e reftests: Make reset css include new CSS properties 2012-05-02 02:00:10 +02:00
Cosimo Cecchi fd549e432f cssshadow: plug a memory leak 2012-05-01 15:03:47 -04:00
Matthias Clasen b07e51bfee Bump version 2012-04-30 23:18:49 -04:00
Matthias Clasen c0708f23df Bump to 3.5.2 2012-04-30 23:02:18 -04:00
Matthias Clasen 3be5c09a90 Add some more documentation about GDK_SCROLL_SMOOTH 2012-04-30 22:28:08 -04:00
Benjamin Otte 333a5b4307 cssshadow: Default fallback color is transparent
... not the current color. Fixes unresolvable.ui test.
2012-05-01 03:13:02 +02:00
Benjamin Otte b4195cb408 cssmatcher: Handle case of empty widget path
This is tested by the stylecontext test, but doesn't appear in practice.
2012-05-01 03:13:02 +02:00
Benjamin Otte 6c63842e68 cssprovider: Actually match the state for style properties
Copy/paste error when refactoring.

Caught by stylecontext test.
2012-05-01 03:13:02 +02:00
Benjamin Otte 12846d821c versionmacros: min-require the current stable version
.. instead of the previous stable version.

This ensures that if we use GDK_DEPRECATED_IN_3_6, it will actually emit
a warning in GTK 3.5, and not wait with that until GTK 3.7. This is
particularly useful for stuff that gets deprecated right now. This code
should emit warnings right now, so we know what we're doing while
deprecating.
2012-05-01 03:13:01 +02:00
Benjamin Otte 7bb19b85c2 docs: Fix copy/paste typo 2012-05-01 03:13:01 +02:00
Benjamin Otte 4531da17e4 gtk: Get rid of deprecation warnings 2012-05-01 03:13:01 +02:00
Benjamin Otte de9ffc99c2 tests: Ifdef out unused code
The test using those functions was disabled in
b310ba29d0
2012-05-01 03:13:01 +02:00
Benjamin Otte 23907e1d53 build: Remove now-unused GTK_DISABLE_DEPRECATED undefs 2012-05-01 03:13:01 +02:00
Matthias Clasen e9e557a353 Update reference output for css parser tests
Seems these were not kept up-to-date with the recent
CSS parser changes.
2012-04-30 20:45:46 -04:00
Ryan Lortie af71917015 GtkApplication: adjust to GApplication changes
GApplication now makes the session bus and object path available as a
public API on the application instance.  Use that instead of trying to
guess values for ourselves.

This causes this version of Gtk+ to depend on GLib 2.32.2, so bumping
version dependency accordingly.

https://bugzilla.gnome.org/show_bug.cgi?id=671249
2012-04-30 17:50:45 -04:00
Ryan Lortie babd137e32 GtkApplication: fixes for NULL session bus
We currently have a couple of cases where GtkApplication assumes that
the session bus will be non-NULL causing critical error output or (in
the case of trying to publish menus) an infinite loop.

Three fixes:

 - if the session bus is NULL due to not having registered the
   GtkApplication yet then give a g_critical on the entry point to the
   menu setters instead of going into an infinite loop.  Document this.

 - check for NULL session bus even when calling the menu setters at the
   right time in order to prevent the infinite loop for
   non-programer-error cases (ie: because we had trouble connecting to
   the session bus)

 - check for NULL session bus when publishing the X11 properties on the
   GtkApplicationWindow and skip publishing them if we're not on the bus

https://bugzilla.gnome.org/show_bug.cgi?id=671249
2012-04-30 17:50:45 -04:00
Cosimo Cecchi cdf473ec10 infobar: deprecate broken GtkInfoBar style properties
The way we use these style properties to set regular properties on
containers accessible from the public API is really just broken, and
could lead to undefined values for the spacing and border-width
container properties (since they could be set from public API and then
changed from under in a style_update handler from GTK).

Take this as an occasion to deprecate these style properties, which do
not make a lot of sense anyway, now that GtkInfoBar supports regular CSS
padding and border.
2012-04-30 17:14:44 -04:00
Owen W. Taylor 0aa989ae76 GtkPlug: fix handling of key events for different layouts
GtkPlug directly handles X KeyPress/Release events, instead of using
translation in GDK (which expects XI2 events for XI2). When this
was done, the handling of the group was stubbed out and never replaced.

Export gdk_keymap_x11_group_for_state() and gdk_keymap_x11_is_modifier()
so we can fill out the fields correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=675167
2012-04-30 16:35:10 -04:00
Paolo Borelli 2f81a58573 Fix info-bar reftest
InfoBar must take into account the border and padding when requesting
its allocation, since it is then drawing them. Besides, the border and
background should always be drawn, even when the message type is OTHER.
2012-04-30 21:53:17 +02:00
Paolo Borelli 9af5d89f26 Fix infobar reftest for label background changes
Fix the reftest after previous commit

https://bugzilla.gnome.org/show_bug.cgi?id=670743
2012-04-30 21:53:17 +02:00
Cosimo Cecchi 868b28b503 reftests: fix background-size reftest
We have to be careful and not set the background on the labels
themselves.

https://bugzilla.gnome.org/show_bug.cgi?id=670743
2012-04-30 13:13:46 -04:00
Paolo Borelli 03bf85ba07 Paint label background
Make GtkLabel respect background css properties.

https://bugzilla.gnome.org/show_bug.cgi?id=670743
2012-04-30 13:13:25 -04:00
Cosimo Cecchi 20f8dd2309 themingbackground: fix copy/paste typo
We need to fetch the area value for the origin, not for the clip.
2012-04-30 12:10:45 -04:00
Matthias Clasen b310ba29d0 Disable configuration-dependent keymap tests for now
These need to be made independent of the xkb configuration somehow.
As things are now, they will either fail when run on a naked X
server in make check, or fail when run in my session.
2012-04-30 07:32:33 -04:00
Matthias Clasen 18db64749f Fix build with --enable-debug 2012-04-30 07:07:33 -04:00
Matthias Clasen 328add40ca Updates for 3.5.1 2012-04-30 07:02:01 -04:00
William Jon McCann 922b404091 Mention XDG Base Dir migration in README for 3.6
https://bugzilla.gnome.org/show_bug.cgi?id=646631
2012-04-30 06:50:17 -04:00
William Jon McCann ceb3fecd11 Migrate to XDG config dir for bookmarks
Will read from old location if new location isn't found but will
write it out to the new location.

https://bugzilla.gnome.org/show_bug.cgi?id=646631
2012-04-30 06:42:35 -04:00
William Jon McCann f10176e49f Prefer xdg data directory to legacy .icons directory
https://bugzilla.gnome.org/show_bug.cgi?id=646631
2012-04-30 06:42:34 -04:00
William Jon McCann 9f5e580821 Try to load css themes from the XDG config directory first
Will fall back to previous locations.

https://bugzilla.gnome.org/show_bug.cgi?id=646631
2012-04-30 06:42:33 -04:00
William Jon McCann bbb7b2987e Migrate to XDG config dir for custom papers
Will read from old location if new location isn't found but will
only write to the new location.

https://bugzilla.gnome.org/show_bug.cgi?id=646631
2012-04-30 06:42:31 -04:00
William Jon McCann fa0d6127c3 Don't load binary modules from the home directory by default
We should rely on the module path environment variables being
set correctly for the architecture rather than load from .gtk-3.0

https://bugzilla.gnome.org/show_bug.cgi?id=646631
2012-04-30 06:42:30 -04:00
Richard Hughes bf71b88319 Fix the colord support in GtkPrinterCups when the PPD is loaded async
If the PPD is not available when the printer is loaded then the PPD options are
not available and we can't get the correct qualifier to use with colord.

When the PPD becomes available, refresh the profile title to reflect reality.

https://bugzilla.gnome.org/show_bug.cgi?id=674890
2012-04-30 06:22:12 -04:00
Matthias Clasen 0c6d158373 GtkGrid: Add a note about overlapping children
https://bugzilla.gnome.org/show_bug.cgi?id=669989
2012-04-28 02:19:45 -04:00
Matthias Clasen d44edc1f7d Revert "WIP: make GtkNotebook window-draggable"
This reverts commit b3a66c59ad.
2012-04-28 02:06:37 -04:00
Carlos Garnacho 676441398a treemodelsort: fix iter_previous so it can go back to the first item
It was getting the previous element, then checking whether it was the
first one, that has to be inverted so it doesn't stop on the second
item.

https://bugzilla.gnome.org/show_bug.cgi?id=674587
2012-04-28 02:01:16 -04:00
Diego Escalante Urrelo b3a66c59ad WIP: make GtkNotebook window-draggable
https://bugzilla.gnome.org/show_bug.cgi?id=672427

https://bugzilla.gnome.org/show_bug.cgi?id=674587
2012-04-28 02:01:16 -04:00
Matthias Clasen 22eb687264 Add a 'fine adjustment' mode to ranges
Shift-click in the slider now starts a drag in 'fine adjustment'
mode, where we move the slider 10-times slower than the mouse.

This can be very helpful when scrolling through a very long document
or webpage, and moving the scrollbar even a single pixel already
jumps too far in the content.

https://bugzilla.gnome.org/show_bug.cgi?id=563688
2012-04-27 12:08:16 -04:00
Matthias Clasen 162614aab4 Change button bindings for range widgets around
It seems to be general consensus that button 1 should do the jumping,
so we now jump to the clicked position on primary button clicks and
page on secondary button clicks. Touch behaves like primary.

https://bugzilla.gnome.org/show_bug.cgi?id=563688
2012-04-27 12:08:15 -04:00
Debarshi Ray 1d5ba789d5 stylecontext: Add GTK_STYLE_CLASS_DIM_LABEL
Fixes: https://bugzilla.gnome.org/674468
2012-04-27 14:55:49 +02:00
Matthias Clasen 4e18e5f687 gtk-demo: fix the tool palette demo
The palette was confined to its minimal size, when in horizontal mode.
2012-04-27 08:30:05 -04:00
Benjamin Otte 0cf3791c28 toolpalette: Configure adjustment properly
https://bugzilla.gnome.org/show_bug.cgi?id=673650
2012-04-27 03:33:57 +02:00
Benjamin Otte 145b59b4b1 toolpalette: Rename variable
The variable that holds the total size for all widget allocations
shouldn't be called page_start.
2012-04-27 03:28:22 +02:00
Cosimo Cecchi 271adacfad icontheme: search first in all themes if the requested icon is symbolic
Symbolic icons use a "-symbolic" suffix to distinguish themselves from
highcolor variants. Note that the dash character here has a different
meaning than the specificity level defined in the icon-naming-spec [1],
as it identifies a property of the icon itself.

Since they might be provided by a parent theme (e.g. the HighContrast theme
relies on the gnome icon theme for them), when we are looking up one we
should first escape the generic icon inheritance mechanism defined in the
icon-naming-spec [1], and privilege a symbolic icon, if it exists in a
parent theme, before applying the inheritance evaluation.

This fixes symbolic icons not working properly when used in the
HighContrast theme with the GTK_ICON_LOOKUP_GENERIC_FALLBACK flag set.

[1]
http://standards.freedesktop.org/icon-naming-spec/latest/ar01s03.html

https://bugzilla.gnome.org/show_bug.cgi?id=674806
2012-04-26 13:52:01 -04:00
Cosimo Cecchi 7e917e54a3 themingengine: simplify render_extension() default implementation
Avoid doing useless translations/rotations, since themes will most
likely set different CSS gradients using left/right/top/bottom style
classes, or use a plain color.

https://bugzilla.gnome.org/show_bug.cgi?id=674809
2012-04-26 13:50:20 -04:00
Cosimo Cecchi d12fd1435a themingengine: render a frame in gtk_render_handle()
We already render a background there after all.

https://bugzilla.gnome.org/show_bug.cgi?id=674808
2012-04-26 13:45:24 -04:00
Cosimo Cecchi 5538552ebc spinbutton: port to GtkIconHelper
Instead of doing our own lookup for symbolic icons and rendering the
pixbuf, use GtkIconHelper as other widgets do, which saves a bunch of
code.

https://bugzilla.gnome.org/show_bug.cgi?id=674807
2012-04-26 13:35:54 -04:00
Mark Vender d9eb667776 Regenerate the gdk/gdkkeysyms.h and gdk/gdkkeysyms-compat.h files
https://bugzilla.gnome.org/show_bug.cgi?id=673259
2012-04-25 20:29:36 -04:00
Mark Vender d13740b2ba Fix the gdk/gdkkeysyms-update.pl to reflect new upstream location
https://bugzilla.gnome.org/show_bug.cgi?id=673259
2012-04-25 20:29:29 -04:00
Rob Bradford af8e4ee8e7 wayland: Calculate window position offset to give emulated root coordinates
This allows combo box popup windows to appear in the correct place. This is a
workaround emulating root coordinates by calculating the offset for a chain
of windows that that are relative to each other.
2012-04-25 14:36:08 +01:00
Rob Bradford 568b310eb3 wayland: Only update position if the with_move flag is set
This was causing the combobox popup to be moved to (0,0) when just the
size was asserted.
2012-04-25 12:00:40 +01:00
Rob Bradford 55261f4e3f wayland: Improve error message handling in cursor buffer code 2012-04-25 12:00:40 +01:00
Matthias Clasen 87cd49371a Make page up/down work again in scrolled menus
This was broken since before GTK+ 3.0, when we replaced
a use of requisition by allocation. Fix this by using the
requisition height, that is already cached by the menu code.

The math is not quite right here; if you page all the way
down a long menu, you end up on the second-to-last menuitem.
But at least, page up/down let you move up and down the menu
again.
https://bugzilla.gnome.org/show_bug.cgi?id=668931
2012-04-24 23:34:12 -04:00
Sam Thursfield 2e873e3fdc Fix build with XInput < 2.2
Fixes regression introduced in fa8e6f7857
2012-04-24 12:55:39 +01:00
Cosimo Cecchi 2058ea09a7 docs: add gtk_builder_add_from_resource() to gtk-doc 2012-04-23 17:42:17 -04:00
John Ralls 46385aff03 Remove some more CUPS 1.2 ifdefs. 2012-04-23 12:44:06 -07:00
John Ralls 2c000c8e61 Bug 670373: modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6
Fix up accesses of ipp structures in gtkcupsutils.c
2012-04-23 12:44:06 -07:00
John Ralls 02f57f9642 Bug 670373: modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6
Having refactored cups_request_printer_list_cb so that the cups
version-dependent block size is small enough to be handled in a single ifdef,
make the ifdef HAVE_CUPS_API_1_6 block.
2012-04-23 12:44:06 -07:00
John Ralls 3e354a17ef Move some variable declarations into the scopes in which they're used. 2012-04-23 12:44:06 -07:00
John Ralls 58ca84584a Extract Function cups_create_printer 2012-04-23 12:44:06 -07:00
John Ralls d10d34e0ec Extract function cups_printer_handle_attribute 2012-04-23 12:44:06 -07:00
John Ralls 651f7b4b93 Extract printer setup variables into a struct
So that it can be passed as a single parameter to functions as we extract-function to make cups_request_printer_list_cb more manageable.

Note that not all of the affected variables are changed in this changeset. Those are in extracted functions and will be addressed in the next two changes.
2012-04-23 12:44:06 -07:00
John Ralls 4945b832b2 Create enum PrinterStateLevel
Fixes "magic number" in printer_state_reason_level.
2012-04-23 12:44:06 -07:00
John Ralls 60969ff951 Extract reasons and reasons_desc arrays to file level
So that they can be used from more than one function. Rename them to avoid naming conflicts.
2012-04-23 12:44:06 -07:00
John Ralls bfad99ad52 Bug 670373: modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6
The first, simple changes. Turns off the deprecation warnings and substitutes macros and short ifdef blocks where feasible.
2012-04-23 12:44:06 -07:00
Giovanni Campagna dee341fc35 StyleProviderPrivate: mark internal variable as static
Otherwise, it could conflict with other symbols with the same
name exported by a different shared library, with undefined
effects.

https://bugzilla.gnome.org/show_bug.cgi?id=674577
2012-04-23 19:16:14 +02:00
Yuri Kozlov 9d6811859f Updated Russian translation 2012-04-23 12:14:57 +04:00
Cosimo Cecchi 8bb3a2001f xi2: ignore extraneous events for smooth scroll
Since the event will be ignored anyway after it's translated (slave
devices are disabled), don't let it run in the smooth scroll code path,
as it will burn our caches for the actual event we're interested in.

https://bugzilla.gnome.org/show_bug.cgi?id=673644
2012-04-22 13:06:39 -04:00
Cosimo Cecchi 37149668c0 xi2: fix thinko in variable type
https://bugzilla.gnome.org/show_bug.cgi?id=673644
2012-04-22 13:01:08 -04:00
Matthias Clasen 5a41b74c5c XI2: More logging for smooth scrolling
In addition to the delta, log device information.
This was triggered by
https://bugzilla.gnome.org/show_bug.cgi?id=673644
2012-04-22 13:00:47 -04:00
Matthias Clasen 9107074795 Beginning of keyhash tests
Not very interesting yet
2012-04-22 13:00:46 -04:00
Kristian Rietveld 89f166b542 quartz: fix coordinates for synthesized event
Of course, we must pass coordinates in the NSWindow coordinate system
when creating an NSEvent. This fixes drag icon positioning and makes
the icon slide back to the correct position when the drag is
canceled.
2012-04-22 17:38:52 +02:00
Yaron Shahrabani 88ed04cc37 Updated Hebrew translation. 2012-04-22 11:43:37 +03:00
Alexander Shopov ffc5c214d2 Updated Bulgarian translation 2012-04-22 09:13:05 +03:00
Мирослав Николић 8ede7473de Updated Serbian translation 2012-04-21 09:30:37 +02:00
Ryan Lortie e84809c56a ./configure: fix error output for no -libXext
Due to the way the tests are structured, a missing libXext will give a
warning about a missing libX11 (even if libX11 is installed).  This is
confusing to people who are trying to build Gtk.

https://bugzilla.gnome.org/show_bug.cgi?id=674200
2012-04-20 14:38:47 -04:00
Marek Kasik 2c1839ae5f printing: Localize loaded PPD files
Use ppdLocalize() to localize strings in loaded PPD file (#674326).
2012-04-20 17:09:58 +02:00
Marek Kasik f6e2d0947d printing: Get default number-up value from CUPS
Requests "number-up-default" attribute from CUPS and
uses its value for setting value of "gtk-n-up" option.
(#672993)
2012-04-20 17:04:58 +02:00
Alexander Larsson 516fb89065 gtk-demo: Find gtk-demo-application.exe on win32
We need to append the ".exe" extension when looking for the
application file on windows.
2012-04-20 16:00:48 +02:00
Matthias Clasen aa3d30e256 Fix a cornercase of menu parsing
When a uimanager in a gtkbuilder file contains a menu,
the builder parser was getting confused.

https://bugzilla.gnome.org/show_bug.cgi?id=672789
2012-04-20 01:50:01 -04:00
Matthias Clasen ffafe80f5b Cosmetic 2012-04-19 23:41:53 -04:00
Cosimo Cecchi a94f4a4387 stylecontext: add a define for an OSD style class 2012-04-19 15:10:52 -04:00
Cosimo Cecchi 00440e32a4 stylecontext: reorder style classes defines
A couple of style classes defines ended up mixed with the region
defines.
2012-04-19 15:10:52 -04:00
Rob Bradford 1aa2a7f821 wayland: Improve the error reporting in the Cairo GL surface code path 2012-04-19 17:59:09 +01:00
Rob Bradford b5845514ec wayland: Improve error messages during SHM buffer creation
Use g_critical rather than fprintf and and also grab the error messages from
errno and from Cairo
2012-04-19 17:58:59 +01:00
Murray Cumming d4c1b46a9e GtkAppplication docs: Fix small typo. 2012-04-19 09:26:00 +02:00
Marek Černocký cad8aaadce Updated Czech translation 2012-04-18 22:02:40 +02:00
Cosimo Cecchi 0fc7c92235 messagedialog: also set GtkMisc alignment to zero for dialog labels
Setting xalign to START is not enough to make them left-aligned in every
case. This fixes a regression introduced in commit
cc0be1f949

https://bugzilla.gnome.org/show_bug.cgi?id=674286
2012-04-18 14:42:57 -04:00
Cosimo Cecchi eea0cb3a68 messagedialog: don't use gtk_widget_override_font()
Instead of overriding the font theme settings, just set the Pango
attributes we want on the label. This fixes message dialogs growing on
style_update after recent GTK+ changes.
2012-04-18 13:46:39 -04:00
Cosimo Cecchi 8febbcaf6a gdk: add missing GDK_VERSION_3_6 symbol 2012-04-18 13:23:29 -04:00
Cosimo Cecchi 4118e13596 container: fix wrong branching logic
If the resize mode of the container was GTK_RESIZE_IMMEDIATE we would
also fall trough to the next case in the switch, and always throw an
assertion.
2012-04-18 12:12:32 -04:00
Matej Urbančič 724a985465 Updated Slovenian translation 2012-04-17 21:44:37 +02:00
Fran Diéguez 81121ad271 Updated Galician translations
Signed-off-by: Fran Diéguez <fran.dieguez@mabishu.com>
2012-04-17 20:04:05 +02:00
Rob Bradford cd831b1390 wayland: Expose GdkWaylandDisplayManager as a public GType
This permits a runtime test of whether we are running on the Wayland platform
or not.
2012-04-17 18:40:41 +01:00
Daniel Mustieles 553f516eb7 Updated Spanish translation 2012-04-17 18:03:01 +02:00
Piotr Drąg aa1ff574b5 Updated POTFILES.in 2012-04-17 17:17:21 +02:00
Rob Bradford 6f9ad538d9 wayland: Rename GdkScreenWayland to GdkWaylandScreen
This makes it consistent with the functions in the vtable and also consistent
with other backends.
2012-04-17 14:11:31 +01:00
Rob Bradford fc58ff1e6a wayland: Rename GdkDisplayWayland to GdkWaylandDisplay
This makes it consistent with the functions in the vtable and also consistent
with other backends.
2012-04-17 14:11:31 +01:00
Benjamin Otte 14fb4984ce tests: Add a parsing test for the transition property 2012-04-17 08:59:24 +02:00
Benjamin Otte 04c85a5b3b container: Redo style validation handling
Instead of using 1 global queue for both resizes and style validation,
use 2 queues. This makes the code a lot simpler and fixes a bug where we
could accidentally stop restylying for very delayed restyles.
2012-04-17 08:59:23 +02:00
Benjamin Otte 17ccbe4843 container: needs_resize is a container flag, not a widget flag
The widget flag is alloc_needed, needs_resize is used for "is queued
into the container resize queue".
2012-04-17 08:59:23 +02:00
Benjamin Otte 53e714199a cssvalue: Remove GObject macros
GtkCssValue is not a GObject
2012-04-17 08:59:23 +02:00
Benjamin Otte 35e36b9fe5 stylecontext: Avoid style_context_save() calls
Introduce style_data_lookup_for_state() that does this.
2012-04-17 08:59:23 +02:00
Benjamin Otte 2179580c8e stylecontext: Pull all the animation code together
We now animate the core style information (see comment in
gtk_style_context_save()). A lot of widgets save + set custom style
classes/states during drawing and so can't be animated. It does work for
labels, menus and buttons though.
2012-04-17 08:59:23 +02:00
Benjamin Otte 632a84af8c stylecontext: Add GtkCssAnimatedValues
This is a GtkCssComputedValues subclass. So it's essentially a store for
computed CSS values. But it can be animated by advancing it to a certain
timestamp.
2012-04-17 08:59:23 +02:00
Benjamin Otte 9c57b96f56 animation: Add CSS transition object
This is an implementation of GtkStyleAnimation for CSS transitions.

Again, this doesn't do anything but store the data needed to do the
transition.
2012-04-17 08:59:23 +02:00
Benjamin Otte 7b7027c971 stylecontext: Add new class for animation handling
A StyleAnimation is an immutable object used to track the state of CSS
values. I'd have liked to make it fully immutable - ie not have the
timestamp in there - but couldn't find a place to sanely store the
timestamp.

This is an abstract base class. Implementations for this will be added
later (for both CSS3 transitions and animations, potentially for
animated images).

Actually aplying the information in this object will be done by a
different object commtted later.
2012-04-17 08:59:23 +02:00
Benjamin Otte 8b1385804e button: Remove _gtk_button_paint()
All buttons use the same paint function these days. States are managed
correctly so this was just leftovers from GTK 1 or GTK 2.
2012-04-17 08:59:23 +02:00
Benjamin Otte d8b99d47ea menuitem: Don't set menubar style class randomly
a) We're not a menubar, you can match on the parent if you have to
b) It's not set while getting preferred sizes
2012-04-17 08:59:23 +02:00
Benjamin Otte 1d54e4e867 widget: Set .default class when widget is default
Don't just conditionally set it on buttons.
2012-04-17 08:59:22 +02:00
Benjamin Otte 60eff87d08 stylecontext: Shuffle around code
This has two goals:

1) Move invalidation code out of a nested if branch. Invalidation is
actually the most important thing this function does.

2) Have the changes bitmask available. It will needed for invalidate
calls to children later.
2012-04-17 08:59:22 +02:00
Benjamin Otte 42d2430498 stylecontext: Add style_info_set_data()
.. to take care of the refcounting properly.
2012-04-17 08:59:22 +02:00
Benjamin Otte b8c72a0bdb stylecontext: Make StyleInfo keep the next pointer 2012-04-17 08:59:22 +02:00
Benjamin Otte deefb64661 stylecontext: Make StyleData refcounted
This is needed for animations where we want to keep a custom StyleData
for animations.
2012-04-17 08:59:22 +02:00
Benjamin Otte fe89e710ea stylecontext: Add public API to stop animations
... and use it.

Of course, there still are no animations, so we don't turn anything off
yet.
2012-04-17 08:59:22 +02:00
Benjamin Otte a240808824 stylecontext: Add an animating framework
The design principles were:

- synchronized
If multiple style contexts are animating, they should all do an
animation step at the same time.

- degrades well
Even when there's thousands of style contexts all animating at the same
time, the animation steps don't starve the CPU. This is achieved by
making sure the timeout is really fast. It just sets a bunch of flags.

- no hidden bottlenecks
Turning animatability on or off on a style context is O(1).

So far it is unused.
2012-04-17 08:59:22 +02:00
Benjamin Otte 50fdb6a13f computedvalues: Split out a function 2012-04-17 08:59:22 +02:00
Benjamin Otte b6594d1ac9 stylecontext: Don't queue a resize when none is needed 2012-04-17 08:59:22 +02:00
Benjamin Otte 97dc45f8a5 container: Split out a function 2012-04-17 08:59:22 +02:00
Benjamin Otte 090f30c559 container: Remove duplicated flag
GtkContainer::need_resize and GtkWidget::alloc_needed are the same
thing.
2012-04-17 08:59:22 +02:00
Benjamin Otte 8bda7442c8 container: Simplify code
This code should not have any functional changes and just be simpler.
2012-04-17 08:59:21 +02:00
Benjamin Otte e2f89c0c6a stylecontext: Listen to the new changed signal 2012-04-17 08:59:21 +02:00
Benjamin Otte 6443baadb9 styleprovider: Make all implementors emit the new signal
... and listen to it in the cases where they use other style providers.
2012-04-17 08:59:21 +02:00
Benjamin Otte 74f4c6f6bd styleprovider: Add a private signal for when things change 2012-04-17 08:59:21 +02:00
Benjamin Otte 29fbfcb8f5 stylecontext: Pass time to style_context_validate()
This way, we can ensure that every style context uses the same timestamp
for whatever they do.
2012-04-17 08:59:21 +02:00
Benjamin Otte aaedc7b67f stylecontext: Compute if things changed before invalidating
This is only a small performance boost by itself, but it's necessary
for animations, so we need it.

Benchmark numbers for my Glade benchmark for interested people:
        GTK 3.4.0    last commit  this commit
Raleigh
  real  0m41.879s    0m10.176s    0m9.900s
  user  0m41.394s    0m9.895s     0m9.628s
  sys   0m0.111s     0m0.096s     0m0.102s

Adwaita                                        (*)
  real  0m51.049s    0m13.432s    0m14.848s    0m12.253s
  user  0m50.487s    0m13.034s    0m13.218s    0m11.927s
  sys   0m0.117s     0m0.151s     0m0.147s     0m0.107s

Ambiance (patched to not use private GTK APIs)
  real  0m52.167s    0m13.115s    0m13.117s    0m12.944s
  user  0m51.576s    0m12.739s    0m12.768s    0m12.651s
  sys   0m0.119s     0m0.137s     0m0.136s     0m0.118s

(*) Adwaita and unico currently use custom properties, and
_gtk_css_value_compare() for custom properties always returns FALSE,
which makes this optimization never trigger. So I modified
_gtk_css_value_compare() to return TRUE for these properties instead and
reran the benchmark. Those are the numbers.
2012-04-17 08:59:21 +02:00
Benjamin Otte 95a4b46f8b reftests: Fix reftests for recent changes 2012-04-17 08:59:21 +02:00
Benjamin Otte 33f111a47c widget: Don't cache widget paths all the time
Add an internal API that allows GtkStyleContext to create a widget path
for the widget and with that bypassing gtk_widget_get_path() and that
  function caching the path.
2012-04-17 08:59:21 +02:00
Benjamin Otte 6ac754cdd1 stylecontext: Remove theming_engine cache variable
Instead, look up the variable upon use. This is more correct (for when
the engine changes due to save/restore() shenanigans.

And it removes code that doesn't use the standard code paths.
2012-04-17 08:59:21 +02:00
Benjamin Otte 3ddb104302 stylecontext: Split out a function 2012-04-17 08:59:20 +02:00
Benjamin Otte 2fec112422 styleproperty: Remove equal_func vfunc
Equality tests are done with _gtk_css_value_equal(). There is no need to
do it per-property, equal values will still be equal.

This essentially reverts 24f5d54329e028347bd76af42e86ed190c1229a2 and
92c7a7171e1240b6d961ee5b6f9ab6b596e98904.
2012-04-17 08:59:20 +02:00
Benjamin Otte 40283e7c27 cssvalue: Split out old value handling to new typed value
... and Make this new value be a real GValue, as we don't need to save
performance for these anymore (it's just used for custom properties).
And I'd rather have code work for all values then be optimized for no
reason.
2012-04-17 08:59:20 +02:00
Benjamin Otte 883c871be6 themingengine: Fix outline-width
It's a number, not an int.
2012-04-17 08:59:20 +02:00
Benjamin Otte ba7141b92e shorthand: Fix border query functions
We haven't been using ints there for a while, I wonder why that never
blew up...
2012-04-17 08:59:20 +02:00
Benjamin Otte 0111b9d507 symboliccolor: Treat it as a CssValue
.. now that it is one.
2012-04-17 08:59:20 +02:00
Benjamin Otte 0048c8baf5 tests: Add a test ensuring currentColor is parsed everywhere 2012-04-17 08:59:20 +02:00
Benjamin Otte 505fefbec7 cssprovider: Add an empty line when printing
... between the @define-color statements and the rules.
2012-04-17 08:59:20 +02:00
Benjamin Otte 51da8cb263 symboliccolor: Parse 'currentColor' everywhere 2012-04-17 08:59:20 +02:00
Benjamin Otte 83be7e5dbd symboliccolor: Pass the current color to the resolve function
This way, we can resolve things like
  mix (currentColor, &otherColor);
and therefore parse currentColor as a regular color.
2012-04-17 08:59:19 +02:00
Benjamin Otte 1223d53a82 cssparser: Move symbolic color parser to gtksymboliccolor.c 2012-04-17 08:59:19 +02:00
Benjamin Otte 7606fcb52e symboliccolor: Turn this into a GtkCssValue 2012-04-17 08:59:19 +02:00
Benjamin Otte b403a1b550 css: Add a shorthand 'transition' property 2012-04-17 08:59:19 +02:00
Benjamin Otte c3f46ab5c0 shorthand: Add ',' to value_is_done_parsing() 2012-04-17 08:59:19 +02:00
Benjamin Otte 04c5fdaca6 css: Remove old animation code
Deprecate public API where appropriate and make it no-ops.
Remove all calls to it.
Get rid of the 'transition' css property.

For now, this means spinners don't animate anymore.
2012-04-17 08:59:19 +02:00
Benjamin Otte dcd54e20d1 css: Remove GtkCssNumber
It's completely replaced by GtkCssNumberValue now.
2012-04-17 08:59:19 +02:00
Benjamin Otte 1b69f1d7c2 linear-gradient: Convert from GtkCssNumber to GtkCssValue 2012-04-17 08:59:19 +02:00
Benjamin Otte 1170ecfd2e cssvalue: Convert border-image-width to border value 2012-04-17 08:59:19 +02:00
Benjamin Otte 56f79fecce cssvalue: Add a border value
.. and parse border-image-slice with it.
2012-04-17 08:59:18 +02:00
Benjamin Otte cfc6462730 cssvalue: Add a cssvalue for background-size 2012-04-17 08:59:18 +02:00
Benjamin Otte f785f7177c cssvalue: Add a custom value for repeats
In particular, that's background-repeat and border-image-repeat.

Also, fix up the border-image shorthand to allow any order.
2012-04-17 08:59:18 +02:00
Benjamin Otte 5377169ef3 cssvalue: Add a value for background-position 2012-04-17 08:59:18 +02:00
Benjamin Otte aed7600425 cssvalue: Add a css value for engines 2012-04-17 08:59:18 +02:00
Benjamin Otte 4f63c1c7ca cssstyleproperty: Convert binding sets
Instead of keeping a custom GPtrArray, keep it as a GtkCssArrayValue of
GtkCssStringValue. This way, we gain equality comparisons and print
functions for free.
2012-04-17 08:59:18 +02:00
Benjamin Otte edbc8e4f57 cssvalue: Add a value for border-radius corner properties
... and convert those properties to this value.
2012-04-17 08:59:18 +02:00
Benjamin Otte 05f2249d08 css: Make outline-offset a number property 2012-04-17 08:59:18 +02:00
Benjamin Otte c366b5b8b7 shadow: Add equal and transition support
... and enable transitions for the shadow properties.
2012-04-17 08:59:18 +02:00
Benjamin Otte ac6d61f6bb cssvalue: Add GtkCssShadowsValue
This is necessary because shadows get treated differently from other
lists when transitioning.
2012-04-17 08:59:18 +02:00
Benjamin Otte 8f240275fd tests: Add a parsing test for shadows 2012-04-17 08:59:17 +02:00
Benjamin Otte b8ccda4140 shadow: Rewrite to store contents as values 2012-04-17 08:59:17 +02:00
Benjamin Otte 7bdcba189e shadow: Make color a GtkCssValue 2012-04-17 08:59:17 +02:00
Benjamin Otte ca17270187 cssvalue: Make GtkCssShadowValue only hold one shadow
All the properties now are a GtkCssArrayValue of GtkCssSadowValue.
GtkCssArrayValue already does everything we want, so no need to
duplicate its funtionality.
2012-04-17 08:59:17 +02:00
Benjamin Otte c5878e8f6f themingengine: Make _gtk_theming_engine_paint_spinner() args const 2012-04-17 08:59:17 +02:00
Benjamin Otte b9ebe8c226 cssarrayvalue: Redo parsing arrays
Does 3 things:
1) Introduce a "none" array signleton
2) Get rid of memleaks in error paths
3) Reduce code in parse funcs
2012-04-17 08:59:17 +02:00
Benjamin Otte 580b5e4a83 stylecontext: Don't queue_resize() all the time
When a parent style context exists, there's no need to queue_resize() on
the widget, because the parent widget will call
gtk_style_context_validate() on us and _then_ we can call queue_resize()
if we have to.
2012-04-17 08:59:17 +02:00
Benjamin Otte a8efb784d7 cssstyleproperty: Mark all animatable properties
Only the ones that can be animated are marked of course. So more work is
needed.
This is important for
  transition-property: all;
because it'll just animate all the properties that can be.
2012-04-17 08:59:17 +02:00
Benjamin Otte ed45a3c2f0 cssstyleproperty: Add _gtk_css_style_property_is_animated() 2012-04-17 08:59:17 +02:00
Benjamin Otte 9e4341f730 css: Move enum to the only source file using it 2012-04-17 08:59:17 +02:00
Benjamin Otte e597f4d6a9 cssvalue: Add transition support for images 2012-04-17 08:59:16 +02:00
Benjamin Otte d853a8f2f7 cssimage: Add GtkCssImageCrossFade
Supports the cross-fade() css notation the way the old CSS3 specs did.

The main reason for adding it is supporting image transitions though.
2012-04-17 08:59:16 +02:00
Benjamin Otte 8ad8a4febf cssvalue: Add _gtk_css_value_to_string()
This is a tiny wrapper around _gtk_css_value_print().
It's intended for usage in gdb and printf debugging.
2012-04-17 08:59:16 +02:00
Benjamin Otte 41ce29767c cssstyleproperty: Add transition properties 2012-04-17 08:59:16 +02:00
Benjamin Otte 7511109103 cssvalue: Add GtkCssEaseValue
This is supposed to hold the transition-easing-function and
animation-easing-function values.
2012-04-17 08:59:16 +02:00
Benjamin Otte 2ff47ed26d cssvalue: Add a GtkCssValue for idents 2012-04-17 08:59:16 +02:00
Benjamin Otte 662d6787f3 css: Add <time> type to css number stuff 2012-04-17 08:59:16 +02:00
Benjamin Otte 68b7d3e410 computedvalues: Fix signage error 2012-04-17 08:59:16 +02:00
Benjamin Otte a360e77a7b css: Remove _gtk_css_computed_values_get_value_by_name()
Now that we use an enum for the IDs, we don't need that function
anymore.
2012-04-17 08:59:16 +02:00
Benjamin Otte 31565139ba stylecontext: Convert _gtk_style_context_peek_property()
Take the property id instead of the name.
2012-04-17 08:59:15 +02:00
Benjamin Otte 5d8789680e css: Add an enum for all the style properties
So instead of using
  _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY
        (_gtk_style_property_lookup ("name")))
one can now use
  GTK_CSS_PROPERTY_NAME

Esaier, eh?
2012-04-17 08:59:15 +02:00
Benjamin Otte 1a9dfab825 cssvalue: Add _gtk_css_value_transition()
Returns a value that transitions between start and end or %NULL if the
values cannot be transitioned.

So far, all implementations but numbers and rgba return NULL.
2012-04-17 08:59:15 +02:00
Benjamin Otte bf92f2f7ac cssvalue: Do a hacky conversion of font-size to a number value
Just store the value as px for now.

The font-size property needs a complete makeover anyway.
2012-04-17 08:59:15 +02:00
Benjamin Otte ad05604b3e cssvalue: Convert 'font-family'
It's now a CssArrayValue filled with CssStringValue
2012-04-17 08:59:15 +02:00
Benjamin Otte 7c75611bc2 cssvalue: Add a custom value for strings 2012-04-17 08:59:15 +02:00
Benjamin Otte 0cce3520d3 cssprovider: Store widget style value as string
There's no need to turn it into a GtkCssValue, it's always a string.
2012-04-17 08:59:15 +02:00
Benjamin Otte 4ba9be5b97 cssvalue: Add GtkCssArea to the enum values
... and get rid of its GType.

This makes it non-queryable using gtk_style_context_get() but it used to
be a private struct anyway.
2012-04-17 08:59:15 +02:00
Benjamin Otte 8e17f9c233 switch: Set ACTIVE state flag with is_active property 2012-04-17 08:59:15 +02:00
Benjamin Otte 40982eabbb stylecontext: Keep the main style data around until revalidation 2012-04-17 08:59:15 +02:00
Benjamin Otte 751187aa0c stylecontext: Keep per-styleinfo data
Instead of having one global data structure, keep it per style info.
This means that we can do special tricks on the "global" style data.
2012-04-17 08:59:14 +02:00
Benjamin Otte a737adadf8 stylecontext: Make style_data_lookup() not take a state anymore
Instead, use the current state of the style context.
2012-04-17 08:59:14 +02:00
Benjamin Otte 82b769ddde widget-factory: Add spinners
Doesn't look very well, but if somebody cares about that, he can fix it
(hint hint)
2012-04-17 08:59:14 +02:00
Benjamin Otte 8c49cd97a7 cssvalue: Add a cssvalue for images 2012-04-17 08:59:14 +02:00
Benjamin Otte d63b11e56b cssvalue: Add enum values for the pango enums
And fix the parser to conform to the CSS spec while at it.
2012-04-17 08:59:14 +02:00
Benjamin Otte b65d17dda8 cssvalue: Make border styles be their own value
... and add them via gtkcssenumvalue.[ch] which will be used for all
enums.
2012-04-17 08:59:14 +02:00
Benjamin Otte 58b6d492b8 cssvalue: Add a custom RGBA value
Note: custom CSS properties still use the default GtkCssValue and always
will.
So there is a difference in css values used between those, even though
they both carry a GdkRGBA payload.
2012-04-17 08:59:14 +02:00
Benjamin Otte dcec7a5529 cssstyleproperty: Make assign_value a vfunc 2012-04-17 08:59:14 +02:00
Benjamin Otte 81dfc2776e customproperty: Implement assign vfunc
I'm going to overwrite the GtkCssStyleProperty one, so better keep this
one.
2012-04-17 08:59:14 +02:00
Benjamin Otte 645309e98b shadow: Also rename files 2012-04-17 08:59:14 +02:00
Benjamin Otte ec5c77a552 shadow: Rename to GtkCssShadowValue
I don't want to confuse css values with other stuff, so there.
2012-04-17 08:59:13 +02:00
Benjamin Otte da40ba431d cssvalue: Remove unused function 2012-04-17 08:59:13 +02:00
Benjamin Otte 96948576bd shadow: Move parse function into GtkShadow
This way, we have less public API.
And gtkcssstylepropertyimpl.c looks less scary (only 1624 lines now).
2012-04-17 08:59:13 +02:00
Benjamin Otte ccd443796c shadow: Make this a GtkCssValue 2012-04-17 08:59:13 +02:00
Benjamin Otte 38ac68790e shadow: Remove _gtk_shadow_get_resolved()
It's unused
2012-04-17 08:59:13 +02:00
Benjamin Otte ca4a080c8a stylepropertyimpl: Make shadows unqueryable
Normal APIs couldn't use GtkShadow anyway as the type was private.
2012-04-17 08:59:13 +02:00
Benjamin Otte 281d094b42 theming: Use peek_property() calls to query shadows 2012-04-17 08:59:13 +02:00
Benjamin Otte a33df2d1d6 cssvalue: Split number values into their own class 2012-04-17 08:59:13 +02:00
Benjamin Otte f7c0c7677b cssstyleproperty: Make query func a vfunc
This will be needed soon.
2012-04-17 08:59:13 +02:00
Benjamin Otte 6ef76f4a92 customproperty: Add our own query_value function
I'm about to change the CssStyleProperty one, so better copy things
here.
2012-04-17 08:59:13 +02:00
Benjamin Otte c8e57d63ec cssstyelproperty: Rempove specified-type and computed-type props
This removes the necessity to keep a GType associated with style
properties and code can now make use of GtkCssValue completely.
2012-04-17 08:59:13 +02:00
Benjamin Otte 75a5f04352 styleproperty: Remove default parse function
... and assert every style property brings its own.
2012-04-17 08:59:13 +02:00
Benjamin Otte a5d001b2ba stylepropertyimpl: Add remaining parse functions 2012-04-17 08:59:12 +02:00
Benjamin Otte 0fdc287339 styleproperty: Simplify compute_value function
The compute_value fallback path is only needed for custom properties,
the real style properties have custom compute functions if they need
them already.
2012-04-17 08:59:12 +02:00
Benjamin Otte 7fbc583b88 css: Move shadow parse/print/compute funcs
They don't belong in the style funcs, as those are for custom
properties, and the shadow type is private.
2012-04-17 08:59:12 +02:00
Benjamin Otte dd144c2bad stylepropertyimpl: Add parse funcs for enums 2012-04-17 08:59:12 +02:00
Benjamin Otte 86a387f571 stylepropertyimpl: Add color parsing function
This is in preparation for removing the specified type and computed type
properties from GtkCssStyleProperty, which is in preparation for really
using GtkCssValue classes and not GTypes.
2012-04-17 08:59:12 +02:00
Benjamin Otte b5fc484c99 customproperty: Don't rely on querying style property
This way, we can remove type madness from GtkCssStyleProperty later.
2012-04-17 08:59:12 +02:00
Benjamin Otte bc9060a591 styleproperty: Make gtk_style_property_register() not be valist
Instead, make the caller create a GtkCssValue in advance.
2012-04-17 08:59:12 +02:00
Benjamin Otte ffe50c3b67 cssvalue: Add _gtk_css_value_equal()
For now, we return FALSE for all default css values, so this is not very
useful.

I also think of this as an optimization equal, not a guaranteed equal,
because we don't even have a notion of what "equal" means.

For example, for background-repeat, "repeat, repeat" and "repeat"
are functionally equivalent. But the cssvalue has no idea that it's used
for background-repeat.
As a more complicated example, "repeat, no-repeat" and "repeat" are
equal to what one sees as long as there's only one image listed
background-image-source. But once you start transition'ing to an image
with 2 sources, it's different...
2012-04-17 08:59:12 +02:00
Benjamin Otte 3e601691d9 tests: Change expected errors to conform with output
This change isn't strictly correct, but I can't be bothered until we get
a tokenizer that can really differentiate between allowed values and
invalid syntax.
2012-04-17 08:59:12 +02:00
Benjamin Otte b0e764000f cssparser: Use _gtk_css_parser_error_full() 2012-04-17 08:59:12 +02:00
Benjamin Otte e7acdec220 cssparser: Add _gtk_css_parser_error_full() 2012-04-17 08:59:11 +02:00
Benjamin Otte 9b7640b898 styleproperty: Make _gtk_style_property_parse_value() return a CssValue
Also split out initial/inherit handling into a custom GtkCssValue class.
2012-04-17 08:59:11 +02:00
Benjamin Otte 718ceaec45 css: Remove _gtk_css_style_property_is_specified_type()
That check is going to be refactored away.
2012-04-17 08:59:11 +02:00
Benjamin Otte 04f5c8708a cssvalue: Add a CSS value for arrays
Make the value auto-cycle its child values, so it can be used for
background properties.
2012-04-17 08:59:11 +02:00
Benjamin Otte df45983fcb cssvalue: Remove _gtk_css_value_new_take_gvalue()
Having two constructors from GValues complicates refactorings, so I'd
rather not have them.
2012-04-17 08:59:11 +02:00
Benjamin Otte 8e3e3d582f cssvalue: Get rid of unused functions 2012-04-17 08:59:11 +02:00
Benjamin Otte 5ac9ba714a styleproperty: Make _gtk_style_property_query() take a GValue
... and don't make it return a GtkCssValue. We want to use this for
compat with the old GValue APIs after all...
2012-04-17 08:59:11 +02:00
Benjamin Otte 58e4fdf911 styleproperty: Make print_func take a GtkCssValue
Also, constify GtkCssValue getters, so we can pass a const GtkCssValue
to the print_func.
2012-04-17 08:59:11 +02:00
Benjamin Otte b728cfd3e8 cssvalue: Make the structure vtable-based
Don't use real classes, just a vtable.
2012-04-17 08:59:11 +02:00
Benjamin Otte 3cdb9c91ca styleproperty: Add support for equal_func 2012-04-17 08:59:11 +02:00
Benjamin Otte d5a2392cc7 stylecontext: Don't clear cache when only state changes
This takes more memory, but changes to backdrop or active state are
quite expensive otherwise.
2012-04-17 08:59:11 +02:00
Benjamin Otte 44187ca3b5 cssmatcher: Use quarks for classes 2012-04-17 08:59:10 +02:00
Benjamin Otte 115c34498e styleproperty: Add a function to compare values for equality
and default to never compare them as equal.
2012-04-17 08:59:10 +02:00
Benjamin Otte 5bbf59b519 cssvalue: Constify a bunch of APIs 2012-04-17 08:59:10 +02:00
Benjamin Otte 4a12717e4d cssvalue: Remove unused functions 2012-04-17 08:59:10 +02:00
Benjamin Otte 585a1fae4f stylecontext: Really queue style changes
Instead of instantly applying a new style, just mark the context as
invalid. Only apply the new style at layout time.
2012-04-17 08:59:10 +02:00
Benjamin Otte eb537b60f4 stylecontext: Optimize the common case of "style didn't change" 2012-04-17 08:59:10 +02:00
Benjamin Otte ece9d2fd92 gtk: Make widget only invalidate widget positions
Instead of resetting them completely
2012-04-17 08:59:10 +02:00
Benjamin Otte e7a984b337 window: Set parent context instead of just resetting style
Otherwise the inherit properties won't inherit properly.
2012-04-17 08:59:10 +02:00
Benjamin Otte 27c9352df3 widget: Replace reset_style() calls
... with finer grained _gtk_widget_invalidate_style_context() calls.
2012-04-17 08:59:10 +02:00
Benjamin Otte 969daec353 widget: Don't go via path when resetting style
Instead, invalidate the path when the style context changes. And
invalidate the style context directly.
2012-04-17 08:59:09 +02:00
Benjamin Otte d589566f40 widget: Add _gtk_widget_invalidate_style_context()
This is supposed to replace gtk_widget_reset_style().
2012-04-17 08:59:09 +02:00
Benjamin Otte 48a8ca8bbe widget: Merge function into only caller 2012-04-17 08:59:09 +02:00
Benjamin Otte 257d961a01 widget: Clear broken widget path in constructor
... where it belongs instead of fiddling with it in get_path().
2012-04-17 08:59:09 +02:00
Benjamin Otte 198cf93f0f stylecontext: On failure, exit the loop, don't try again
Because we will fail again. And then we try again. And then we fail
again. Ad infinitum.
2012-04-17 08:59:09 +02:00
Benjamin Otte 15be680540 stylecontext: Invalidate when setting classes/state/regions
... and nobody has called style_context_save().
2012-04-17 08:59:09 +02:00
Benjamin Otte 44d49c900d stylecontext: Use _gtk_style_context_queue_invalidate() on self 2012-04-17 08:59:09 +02:00
Benjamin Otte 39ff874a11 stylecontext: Introduce _gtk_style_context_queue_invalidate()
This is for only queueing invalidations instead of doing a full
invalidation cycle.
2012-04-17 08:59:09 +02:00
Benjamin Otte 1a51ea3ea3 stylecontext: Keep track of children 2012-04-17 08:59:09 +02:00
Benjamin Otte 7f511f2b33 widget: Don't set widget path on style context
Instead, make the style context use the widget's path. Saves a bunch of
memory.
2012-04-17 08:59:09 +02:00
Benjamin Otte e5ab48ac59 stylecontext: Notify widget directly of changes
This way, we don't need to g_signal_connect(), which saves a bunch of
memory and performance.
2012-04-17 08:59:08 +02:00
Benjamin Otte 1aa4a196dc stylecontext: Add setter for widget
... and actually set the widget on the style context. Note that this
function does not take a reference on the widget, which is a very good
reason to keep it private.
2012-04-17 08:59:08 +02:00
Benjamin Otte 102d10016f matcher: Add a superset matcher
This matcher always matches only on some relvant things and ignores the
rest. This allows you to match only on name and class, but ignore state
and parents/siblings for example.
2012-04-17 08:59:08 +02:00
Benjamin Otte 5f5bf27287 matcher: Add a matcher that matches anything
Lesson learned: Adwaita uses all possible selector types and all of
those for parents, too. But so far no siblings.
2012-04-17 08:59:08 +02:00
Benjamin Otte d115441a57 reftests: Add a reftest for nth-child
Prime numbers are fun.
2012-04-17 08:59:08 +02:00
Benjamin Otte cbe40f27e1 tests: Add a parsing test for nth-child()
Now that we support the an+b notation, make sure we really do.
Maybe my generating script went a bit overboard with the space
possibilities though...
2012-04-17 08:59:08 +02:00
Benjamin Otte 3bdde54aaf selector: Rewrite position tracking
We now track the position as a (type,a,b) tuple where the numbers make
up the an + b formula from CSS3 nth-child.

Also, the get_sibling() and get_sibling_index() vfuncs were replaced by
a has_position() vfunc. This is mostly so that the matcher can always
return TRUE. And I need that for the everything matcher.
2012-04-17 08:59:08 +02:00
Benjamin Otte 8dbe8c8349 syleprovider: Add a vfunc to get the changes
This way we can check what changes are even interesting for our matcher.
2012-04-17 08:59:08 +02:00
Benjamin Otte b0b6c8ad4b selector: Rename selector class
It's a 'position' pseudoclass, not a 'region' pseudoclass.
2012-04-17 08:59:08 +02:00
Benjamin Otte 2d01f7786d css: Add selector change types
This allows querying selectors for which changes would change their
"matchingness".
2012-04-17 08:59:07 +02:00
Benjamin Otte 53317aed55 matcher: Turn GtkCssMatcher into a union
That way, we can add more matchers as we need them.
2012-04-17 08:59:07 +02:00
Benjamin Otte b368c5f10a matcher: Use a vtable
Now we can do lots of fancy matchers, yay!
2012-04-17 08:59:07 +02:00
Benjamin Otte a94b85d375 css: Make the style provider take a matcher as an input argument 2012-04-17 08:59:07 +02:00
Benjamin Otte c0b7c3321d css: Add GtkCssMatcher
This is so we can later do matching with other things than
GtkWidgetPath.
In particular, this is a requirement for getting rid of GtkWidgetPath.
2012-04-17 08:59:07 +02:00
Benjamin Otte a2ded8b72a styleprovider: Add a custom object for a list of style providers
This way, we don't have to do magic inside GtkStyleContext, but have a
real API.
As a cute bonus, this object implements GtkStyleProvider itself. So we
can just pretend there's only one provider.
2012-04-17 08:59:07 +02:00
Benjamin Otte 015e3a768f stylecontext: Stop querying style providers for icon factories
Nobody implements this feature and I don't wanna maintain it. If it
turns out somebody is using it, we gotta invent something.
2012-04-17 08:59:07 +02:00
Benjamin Otte a52336bedc gdk: Add deprecation/availability macros for 3.6 2012-04-17 08:59:07 +02:00
Mario Blättermann 1de2e3ce00 [l10n] Updated German translation 2012-04-16 21:42:14 +02:00
Kristian Høgsberg ea78bcb7c5 wayland: Prefer X11 backend over Wayland
https://bugzilla.gnome.org/show_bug.cgi?id=674102
2012-04-16 18:53:54 +02:00
Kalev Lember 234c7fcf28 application-window: Move desktop file handling code to separate function
https://bugzilla.gnome.org/show_bug.cgi?id=674118
2012-04-16 18:33:50 +03:00
Rob Bradford ba81a3a14c build: Add an enable flag to allow enabling Cairo GL backend
This change adds --enable-wayland-cairo-gl which turns on the define used in
the Wayland backend to determine whether to use EGL surfaces with Cairo GL or
whether to use the Cairo image backend with an SHM surface (the default).

Part of the fix for: https://bugzilla.gnome.org/show_bug.cgi?id=672361
2012-04-16 16:05:51 +01:00
Rob Bradford 71ca53993e wayland: Use an ARGB buffer for the Cairo and SHM surface 2012-04-16 15:09:14 +01:00
Rob Bradford cddfcf1418 wayland: Force an expose for the whole area when scrolling 2012-04-16 15:09:14 +01:00
Rob Bradford cdf5c2af62 wayland: Add support for rendering into an SHM buffer with Cairo image backend
The first version of this change included a bug that meant that if you don't
compile for any other backend then it wouldn't search for cairo. Credit for
identifying the bug goes to darxus@chaosreigns.com.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=672361
2012-04-16 15:09:14 +01:00
Rob Bradford 6977ea0bd1 wayland: Move the buffer creation to the cairo surface creation 2012-04-16 14:12:51 +01:00
Rob Bradford d9ca1a8636 wayland: Move the finalize function to allow a clear logical block of code 2012-04-16 14:12:51 +01:00
Rob Bradford a8d03c9970 wayland: Remove unused member from struct 2012-04-16 14:12:51 +01:00
Reşat SABIQ a820962b2b Updated Crimean Tatar (Crimean Turkish) translation 2012-04-16 01:56:55 -05:00
Reşat SABIQ 49abf425a4 Updated Crimean Tatar (Crimean Turkish) translation 2012-04-16 01:54:47 -05:00
Yinghua Wang 872d170fd1 update Simplified Chinese (zh_CN) translation 2012-04-16 14:14:33 +08:00
Michael Vogt 19e55d620f GtkImage: Move g_clear_object() to gtk_image_finalize()
This moves the freeing of the icon_helper from the destory to the finalize
function to avoid segfaults when trying to access a destroyed object before it
is disposed. This often happens in signal handlers which get called
asynchronously after destroy.

https://bugzilla.gnome.org/show_bug.cgi?id=674050
2012-04-16 06:51:43 +02:00
Kjartan Maraas 298ba51d31 Updated Norwegian bokmål translation 2012-04-15 19:38:20 +02:00
Matthias Clasen 158784f66b Bump version 2012-04-13 21:26:43 -04:00
278 changed files with 49862 additions and 26530 deletions
+52
View File
@@ -1,3 +1,55 @@
Overview of Changes in GTK+ 3.5.1
=================================
* Wayland:
- Allow the wayland backend to be used without cairo-gl
- Expose GdkWaylandDisplayManager for runtime checks
* Theming:
- Optimizations to style invalidation
- Support CSS animatable properties
* Bugs fixed
563688 GtkScale (GtkRange) should jump to clicked position
668931 Scrolling down via PageDown/PageUp keys impossible ...
669989 gtk_grid_attach(): Documentation doesn't mention mu...
670373 modules/printing/cups/gtkprintbackendcups.c won't b...
672361 Remove cairo-gl dependency from wayland backend
672789 gtk_builder_add_objects_from_file() crashes on GtkU...
672993 print dialog overrides default cups number-up settings
673259 The gdk/gdkkeysyms-update.pl script and the keysym ...
673644 Scroll not working in document overview
673650 Evince 3.4: adding new annotation is not possible (...
674050 Free image->priv->icon_helper in gtk_image_finalize...
674102 Defaults to wayland over x11 backend
674118 application-window: Desktop file handling improvements
674200 ./configure gives wrong error message if -lXext is ...
674286 "Delete confirmation" dialog has wrong padding
674326 Use localizations of option names and values contai...
674468 Add GTK_STYLE_CLASS_DIM_LABEL
674577 Non static variable in GtkStyleProviderPrivate
674587 treemodelsort: allow iter_previous() to go past the...
674806 icontheme: search first in all themes if the reques...
674807 spinbutton: port to GtkIconHelper
674808 themingengine: render a frame in gtk_render_handle()
674809 themingengine: simplify render_extension() default ...
674890 Fix the colord support in GtkPrinterCups when the P...
646631 GTK should use XDG base dir spec instead of home
* Translation updates
Bulgarian
Crimean Tatar
Czech
Galician
German
Hebrew
Norwegian bokmål
Russian
Serbian
Simplified Chinese
Slovenian
Overview of Changes in GTK+ 3.4.1
=================================
+22 -1
View File
@@ -72,13 +72,34 @@ and attach the patch to that bug report.
Patches should be in unified diff form. (The -up option to GNU diff.)
Release notes for 3.6
=====================
* Now follows the XDG Base Directory specification for user
configuration and data files. In detail,
* $XDG_CONFIG_HOME/gtk-3.0/custom-papers is the new location
for $HOME/.gtk-custom-papers
* $XDG_CONFIG_HOME/gtk-3.0/bookmarks is the new location
for $HOME/.gtk-bookmarks
* $XDG_DATA_HOME/themes is preferred over $HOME/.themes
* $XDG_DATA_HOME/icons is preferred over $HOME/.icons.
Existing files from the old location will still be read
if the new location does not exist.
* $HOME/.gtk-3.0 is no longer in the default module load path.
If you want to load modules from there, add it to the GTK_PATH
environment variable.
Release notes for 3.4
=====================
* Scroll events have been separated from button events, and smooth
scrolling has been added with a separate event mask. Widgets now
need to have either GDK_SCROLL_MASK or GDK_SMOOTH_SCROLL_MASK in
their event mask to receive scroll events.
their event mask to receive scroll events. In addition, the
GdkScrollDirection enumeration has gained a new member,
GDK_SCROLL_SMOOTH, so switch statements will have to be amended
to cover this case.
* GTK+ now uses <Primary> instead of <Control> in keyboard accelerators,
for improved cross-platform handling. This should not affect
+41 -48
View File
@@ -9,9 +9,9 @@
# set GTK_BINARY_AGE and GTK_INTERFACE_AGE to 0.
m4_define([gtk_major_version], [3])
m4_define([gtk_minor_version], [4])
m4_define([gtk_micro_version], [1])
m4_define([gtk_interface_age], [1])
m4_define([gtk_minor_version], [5])
m4_define([gtk_micro_version], [3])
m4_define([gtk_interface_age], [0])
m4_define([gtk_binary_age],
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
m4_define([gtk_version],
@@ -39,7 +39,7 @@ AC_CONFIG_AUX_DIR([build-aux])
m4_define([gtk_binary_version], [3.0.0])
# required versions of other packages
m4_define([glib_required_version], [2.32.0])
m4_define([glib_required_version], [2.33.1])
m4_define([pango_required_version], [1.30.0])
m4_define([atk_required_version], [2.2.0])
m4_define([cairo_required_version], [1.10.0])
@@ -316,6 +316,12 @@ AC_ARG_ENABLE(quartz-relocation,
[enable bundle-based relocation functions])],
[quartz_relocation=yes])
AC_ARG_ENABLE(wayland-cairo-gl,
AS_HELP_STRING([--enable-wayland-cairo-gl],
[enable the use of Cairo GL in the Wayland backend]),
[enable_wayland_cairo_gl=yes])
cairo_backends=
backend_immodules=
have_gio_unix=no
@@ -379,13 +385,22 @@ else
fi
if test "x$enable_wayland_backend" == "xyes"; then
# Wayland uses cairo-gl
cairo_backends="$cairo_backends cairo-gl"
if test "x$enable_wayland_cairo_gl" == "xyes"; then
# Wayland can use cairo-gl
cairo_backends="$cairo_backends cairo-gl"
AC_DEFINE(GDK_WAYLAND_USE_EGL, [1], [Whether to use EGL in Wayland backend])
else
# For the cairo image backend
cairo_backends="$cairo_backends cairo"
fi
GDK_BACKENDS="$GDK_BACKENDS wayland"
have_gio_unix=yes
GDK_WINDOWING="$GDK_WINDOWING
#define GDK_WINDOWING_WAYLAND"
WAYLAND_PACKAGES="wayland-client xkbcommon wayland-egl egl"
WAYLAND_PACKAGES="wayland-client xkbcommon "
if test "x$enable_wayland_cairo_gl" == "xyes"; then
WAYLAND_PACKAGES="$WAYLAND_PACKAGES wayland-egl egl"
fi
AM_CONDITIONAL(USE_WAYLAND, true)
else
AM_CONDITIONAL(USE_WAYLAND, false)
@@ -407,7 +422,7 @@ else
if test "x$enable_debug" = "xno"; then
GTK_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
else
GTK_DEBUG_FLAGS="-DG_DISABLE_CAST_CHECKS"
GTK_DEBUG_FLAGS="-DG_ENABLE_DEBUG -DG_DISABLE_CAST_CHECKS"
fi
fi
@@ -734,17 +749,9 @@ AC_CHECK_FUNCS(mallinfo)
AC_CHECK_FUNCS(getresuid)
AC_TYPE_UID_T
# Check for round()
AC_CHECK_LIB(m,round,have_round=yes,have_round=no)
if test $have_round = yes; then
AC_DEFINE(HAVE_ROUND, 1, [Define to 1 if round() is available])
fi
# Check for rint()
AC_CHECK_LIB(m,rint,have_rint=yes,have_rint=no)
if test $have_rint = yes; then
AC_DEFINE(HAVE_RINT, 1, [Define to 1 if rint() is available])
fi
# Check for round(), rint(), isnan(), isinf() and nearbyint()
AC_CHECK_LIB(m,round,,)
AC_CHECK_FUNCS(round rint isnan isinf nearbyint)
# Checks for gdkspawn
AC_CHECK_HEADERS(crt_externs.h)
@@ -961,9 +968,9 @@ if test "x$enable_x11_backend" = xyes; then
# Xext is optional, the chances a system has *none* of these things is so
# small that we just unconditionally require it.
AC_CHECK_FUNC(XOpenDisplay, :,
AC_MSG_ERROR([*** libX11 not found. Check 'config.log' for more details.]))
AC_MSG_ERROR([*** libX11 and libXext not found. Check 'config.log' for more details.]))
AC_CHECK_FUNC(XextFindDisplay, :,
AC_MSG_ERROR([*** libXext not found. Check 'config.log' for more details.]))
AC_MSG_ERROR([*** libX11 and libXext not found. Check 'config.log' for more details.]))
# Check for xReply
@@ -1240,8 +1247,9 @@ if test "x$enable_x11_backend" = xyes; then
GDK_PRIVATE_PACKAGES="$GDK_PRIVATE_PACKAGES pangoft2"
fi
GDK_DEP_LIBS="$GDK_EXTRA_LIBS `$PKG_CONFIG --libs $GDK_PACKAGES $GDK_PRIVATE_PACKAGES` $MATH_LIB"
GDK_DEP_CFLAGS="`$PKG_CONFIG --cflags $GDK_PACKAGES $GDK_PRIVATE_PACKAGES` $GDK_EXTRA_CFLAGS"
PKG_CHECK_MODULES(GDK_DEP, $GDK_PACKAGES $GDK_PRIVATE_PACKAGES)
GDK_DEP_LIBS="$GDK_EXTRA_LIBS $GDK_DEP_LIBS $MATH_LIB"
GDK_DEP_CFLAGS="$GDK_DEP_CFLAGS $GDK_EXTRA_CFLAGS"
#
# If we aren't writing explicit dependencies, then don't put the extra libraries we need
# into the pkg-config files
@@ -1263,29 +1271,7 @@ AC_SUBST(GDK_DEP_CFLAGS)
########################################
ATK_PACKAGES=atk
AC_MSG_CHECKING(ATK flags)
if $PKG_CONFIG --exists $ATK_PACKAGES ; then
ATK_CFLAGS=`$PKG_CONFIG --cflags $ATK_PACKAGES`
ATK_LIBS=`$PKG_CONFIG --libs $ATK_PACKAGES`
AC_MSG_RESULT($ATK_CFLAGS $ATK_LIBS)
else
AC_MSG_ERROR([
*** Accessibility Toolkit not found. Accessibility Toolkit is required
*** to build GTK+.
])
fi
if $PKG_CONFIG --uninstalled $ATK_PACKAGES; then
:
else
gtk_save_LIBS="$LIBS"
LIBS="$ATK_LIBS $LIBS"
AC_TRY_LINK_FUNC(atk_object_get_type, : , AC_MSG_ERROR([
*** Cannot link to Accessibility Toolkit. Accessibility Toolkit is required
*** to build GTK+]))
LIBS="$gtk_save_LIBS"
fi
PKG_CHECK_MODULES(ATK, $ATK_PACKAGES)
GTK_PACKAGES="atk cairo cairo-gobject gdk-pixbuf-2.0 gio-2.0"
GTK_PRIVATE_PACKAGES=""
@@ -1298,8 +1284,9 @@ fi
GTK_EXTRA_LIBS=
GTK_EXTRA_CFLAGS=
GTK_DEP_LIBS="$GDK_EXTRA_LIBS $GTK_DEP_LIBS_FOR_X `$PKG_CONFIG --libs $PANGO_PACKAGES $GTK_PACKAGES_FOR_X $GTK_PACKAGES $GTK_PRIVATE_PACKAGES` $GTK_EXTRA_LIBS $MATH_LIB"
GTK_DEP_CFLAGS="`$PKG_CONFIG --cflags $GDK_PACKAGES $GTK_PACKAGES $GTK_PRIVATE_PACKAGES` $GDK_EXTRA_CFLAGS $GTK_EXTRA_CFLAGS"
PKG_CHECK_MODULES(GTK_DEP, $PANGO_PACKAGES $GTK_PACKAGES_FOR_X $GTK_PACKAGES $GTK_PRIVATE_PACKAGES)
GTK_DEP_LIBS="$GDK_EXTRA_LIBS $GTK_DEP_LIBS_FOR_X $GTK_DEP_LIBS $GTK_EXTRA_LIBS $MATH_LIB"
GTK_DEP_CFLAGS="$GTK_DEP_CFLAGS $GDK_EXTRA_CFLAGS $GTK_EXTRA_CFLAGS"
if test x"$os_win32" = xyes; then
GTK_EXTRA_CFLAGS="$msnative_struct"
@@ -1394,6 +1381,12 @@ else
$CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -lt 2; then
AC_MSG_ERROR([CUPS >= 1.2 not found])
fi
if test $CUPS_API_MAJOR -gt 1 -o \
$CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 6; then
AC_DEFINE(HAVE_CUPS_API_1_6, 1,
[Define to 1 if CUPS 1.6 API is available])
fi
AC_SUBST(CUPS_API_MAJOR)
AC_SUBST(CUPS_API_MINOR)
+8 -2
View File
@@ -427,6 +427,12 @@ on_name_vanished (GDBusConnection *connection,
}
}
#ifdef G_OS_WIN32
#define APP_EXTENSION ".exe"
#else
#define APP_EXTENSION
#endif
GtkWidget *
do_application (GtkWidget *toplevel)
{
@@ -445,8 +451,8 @@ do_application (GtkWidget *toplevel)
const gchar *command;
GError *error = NULL;
if (g_file_test ("./gtk3-demo-application", G_FILE_TEST_IS_EXECUTABLE))
command = "./gtk3-demo-application";
if (g_file_test ("./gtk3-demo-application" APP_EXTENSION, G_FILE_TEST_IS_EXECUTABLE))
command = "./gtk3-demo-application" APP_EXTENSION;
else
command = "gtk3-demo-application";
+1
View File
@@ -522,6 +522,7 @@ do_toolpalette (GtkWidget *do_widget)
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_container_set_border_width (GTK_CONTAINER (palette_scroller), 6);
gtk_widget_set_hexpand (palette_scroller, TRUE);
gtk_container_add (GTK_CONTAINER (palette_scroller), palette);
gtk_container_add (GTK_CONTAINER (hbox), palette_scroller);
+1 -1
View File
@@ -22,7 +22,7 @@ gtk3_widget_factory_LDADD = \
$(top_builddir)/gtk/libgtk-3.la \
$(GTK_DEP_LIBS)
widget_factory_resources.c: widget-factory.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies $(srcdir)/widget-factory.gresource.xml)
widget_factory_resources.c: widget-factory.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/widget-factory.gresource.xml)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $<
EXTRA_DIST += \
+53
View File
@@ -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>
+4
View File
@@ -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>
+2
View File
@@ -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
+5 -1
View File
@@ -526,6 +526,7 @@ GtkBuilderConnectFunc
GtkBuilderError
gtk_builder_new
gtk_builder_add_from_file
gtk_builder_add_from_resource
gtk_builder_add_from_string
gtk_builder_add_objects_from_file
gtk_builder_add_objects_from_string
@@ -5029,7 +5030,6 @@ GtkWidgetClass
GtkCallback
GtkRequisition
GtkAllocation
GtkSelectionData
GtkWidgetAuxInfo
GtkWidgetHelpType
gtk_widget_new
@@ -5678,6 +5678,7 @@ GTK_STYLE_CLASS_LEFT
GTK_STYLE_CLASS_RIGHT
GTK_STYLE_CLASS_LINKED
GTK_STYLE_CLASS_ARROW
GTK_STYLE_CLASS_OSD
GTK_STYLE_REGION_COLUMN
GTK_STYLE_REGION_COLUMN_HEADER
GTK_STYLE_REGION_ROW
@@ -5999,6 +6000,7 @@ GtkRcContext
<SECTION>
<FILE>gtkselection</FILE>
<TITLE>Selections</TITLE>
GtkSelectionData
GtkTargetEntry
GtkTargetList
GtkTargetPair
@@ -7018,6 +7020,7 @@ gtk_application_new
gtk_application_add_window
gtk_application_remove_window
gtk_application_get_windows
gtk_application_get_window_by_id
<SUBSECTION>
GtkApplicationInhibitFlags
@@ -7051,6 +7054,7 @@ GtkApplicationWindow
gtk_application_window_new
gtk_application_window_set_show_menubar
gtk_application_window_get_show_menubar
gtk_application_window_get_id
<SUBSECTION Standard>
GtkApplicationWindowClass
@@ -31,18 +31,18 @@
</thead>
<tbody>
<row><entry>EggSMClient::quit-requested</entry><entry>instead of calling will_quit (FALSE,...) in response to this signal, install an inhibitor</entry></row>
<row><entry>EggSMClient::quit</entry><entry>the #GtkApplication::quit signal</entry></row>
<row><entry>EggSMClient::quit-cancelled</entry><entry></entry></row>
<row><entry>EggSMClient::quit</entry><entry>the #GApplication::shutdown signal</entry></row>
<row><entry>EggSMClient::quit-cancelled</entry><entry>-</entry></row>
<row><entry>egg_sm_client_will_quit</entry><entry>instead of calling will_quit (FALSE,...), install an inhibitor</entry></row>
<row><entry>egg_sm_client_end_session</entry><entry>gtk_application_end_session()</entry></row>
<row><entry>egg_sm_client_end_session</entry><entry>-</entry></row>
</tbody>
</tgroup>
</table>
<para>
At this point, GtkApplication has no special support for state saving.
Applications can use GSettings or GKeyFile and save as much state as
they see fit in response to #GtkApplication::quit or whenever they
consider appropriate.
At this point, GtkApplication has no special support for state saving
and restarting. Applications can use GSettings or GKeyFile and save as
much state as they see fit in response to #GApplication::shutdown or
whenever they consider appropriate.
</para>
</chapter>
+11 -3
View File
@@ -58,8 +58,8 @@ warning that occurs.
<para>
A list of <link linkend="GTK-Debug-Options">debug options</link>
to turn on in addition to those specified in the <envar>GTK_DEBUG</envar>
environment variable. This option is only available if GTK+ has been
configured with <option>--enable-debug=yes</option>.
environment variable. This option is not available if GTK+ has been
configured with <option>--enable-debug=no</option>.
</para>
</formalpara>
@@ -134,7 +134,7 @@ additional environment variables.
<title><envar>GTK_DEBUG</envar></title>
<para>
If GTK+ has been configured with <option>--enable-debug=yes</option>,
Unless GTK+ has been configured with <option>--enable-debug=no</option>,
this variable can be set to a list of debug options, which cause GTK+
to print out different types of debugging information.
<variablelist>
@@ -186,6 +186,14 @@ additional environment variables.
<term>builder</term>
<listitem><para>GtkBuilder support</para></listitem>
</varlistentry>
<varlistentry>
<term>size-request</term>
<listitem><para>Size requests</para></listitem>
</varlistentry>
<varlistentry>
<term>no-css-cache</term>
<listitem><para>Bypass caching for CSS style properties.</para></listitem>
</varlistentry>
</variablelist>
The special value <literal>all</literal> can be used to turn on all
+3 -1
View File
@@ -306,7 +306,9 @@ endif
lib_LTLIBRARIES = libgdk-3.la
MAINTAINERCLEANFILES = $(gdk_built_sources) stamp-gdkenumtypes.h
EXTRA_DIST += $(gdk_built_sources)
EXTRA_DIST += \
$(gdk_built_sources) \
fallback-c89.c
install-exec-hook:
if DISABLE_EXPLICIT_DEPS
+13 -13
View File
@@ -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
+44
View File
@@ -0,0 +1,44 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 Chun-wei Fan <fanc999@yahoo.com.tw>
*
* Author: Chun-wei Fan <fanc999@yahoo.com.tw>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <float.h>
#ifndef HAVE_ISNAN
/* it seems of the supported compilers only
* MSVC does not have isnan(), but it does
* have _isnan() which does the same as isnan()
*/
static inline gboolean
isnan (double x)
{
return _isnan (x);
}
#endif
#ifndef HAVE_ISINF
/* Unfortunately MSVC does not have finite()
* but it does have _finite() which is the same
* as finite() except when x is a NaN
*/
static inline gboolean
isinf (double x)
{
return (!_finite (x) && !_isnan (x));
}
#endif
+2
View File
@@ -561,6 +561,8 @@ gdk_x11_get_xatom_name
gdk_x11_get_xatom_name_for_display
gdk_x11_grab_server
gdk_x11_keymap_get_type
gdk_x11_keymap_get_group_for_state
gdk_x11_keymap_key_is_modifier
gdk_x11_lookup_xdisplay
gdk_x11_register_standard_event_type
gdk_x11_screen_get_monitor_output
+1 -2
View File
@@ -970,8 +970,7 @@ switch_to_pointer_grab (GdkDisplay *display,
* synthesized when needed.
*/
if (source_device &&
(gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN ||
gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHPAD))
(gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN))
info->need_touch_press_enter = TRUE;
pointer_window = NULL;
+5 -5
View File
@@ -244,16 +244,16 @@ gdk_display_manager_get (void)
manager = g_object_new (gdk_win32_display_manager_get_type (), NULL);
else
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (backend == NULL || strcmp (backend, "wayland") == 0)
manager = g_object_new (gdk_wayland_display_manager_get_type (), NULL);
else
#endif
#ifdef GDK_WINDOWING_X11
if (backend == NULL || strcmp (backend, "x11") == 0)
manager = g_object_new (gdk_x11_display_manager_get_type (), NULL);
else
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (backend == NULL || strcmp (backend, "wayland") == 0)
manager = g_object_new (gdk_wayland_display_manager_get_type (), NULL);
else
#endif
#ifdef GDK_WINDOWING_BROADWAY
if (backend == NULL || strcmp (backend, "broadway") == 0)
manager = g_object_new (gdk_broadway_display_manager_get_type (), NULL);
+18 -1
View File
@@ -225,8 +225,10 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
* @GDK_2BUTTON_PRESS: a mouse button has been double-clicked (clicked twice
* within a short period of time). Note that each click also generates a
* %GDK_BUTTON_PRESS event.
* @GDK_DOUBLE_BUTTON_PRESS: alias for %GDK_2BUTTON_PRESS, added in 3.6.
* @GDK_3BUTTON_PRESS: a mouse button has been clicked 3 times in a short period
* of time. Note that each click also generates a %GDK_BUTTON_PRESS event.
* @GDK_TRIPLE_BUTTON_PRESS: alias for %GDK_3BUTTON_PRESS, added in 3.6.
* @GDK_BUTTON_RELEASE: a mouse button has been released.
* @GDK_KEY_PRESS: a key has been pressed.
* @GDK_KEY_RELEASE: a key has been released.
@@ -280,6 +282,13 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
* Do not confuse these events with the signals that GTK+ widgets emit.
* Although many of these events result in corresponding signals being emitted,
* the events are often transformed or filtered along the way.
*
* In some language bindings, the values %GDK_2BUTTON_PRESS and
* %GDK_3BUTTON_PRESS would translate into something syntactically
* invalid (eg <literal>Gdk.EventType.2ButtonPress</literal>, where a
* symbol is not allowed to start with a number). In that case, the
* aliases %GDK_DOUBLE_BUTTON_PRESS and %GDK_TRIPLE_BUTTON_PRESS can
* be used instead.
*/
typedef enum
{
@@ -290,7 +299,9 @@ typedef enum
GDK_MOTION_NOTIFY = 3,
GDK_BUTTON_PRESS = 4,
GDK_2BUTTON_PRESS = 5,
GDK_DOUBLE_BUTTON_PRESS = GDK_2BUTTON_PRESS,
GDK_3BUTTON_PRESS = 6,
GDK_TRIPLE_BUTTON_PRESS = GDK_3BUTTON_PRESS,
GDK_BUTTON_RELEASE = 7,
GDK_KEY_PRESS = 8,
GDK_KEY_RELEASE = 9,
@@ -736,7 +747,8 @@ struct _GdkEventTouch
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
* @direction: the direction to scroll to (one of %GDK_SCROLL_UP,
* %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT and %GDK_SCROLL_RIGHT).
* %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT, %GDK_SCROLL_RIGHT or
* %GDK_SCROLL_SMOOTH).
* @device: the device where the event originated.
* @x_root: the x coordinate of the pointer relative to the root of the
* screen.
@@ -746,6 +758,11 @@ struct _GdkEventTouch
* Generated from button presses for the buttons 4 to 7. Wheel mice are
* usually configured to generate button press events for buttons 4 and 5
* when the wheel is turned.
*
* Some GDK backends can also generate 'smooth' scroll events, which
* can be recognized by the %GDK_SCROLL_SMOOTH scroll direction. For
* these, the scroll deltas can be obtained with
* gdk_event_get_scroll_deltas().
*/
struct _GdkEventScroll
{
+108 -14
View File
@@ -286,6 +286,7 @@
#define GDK_dead_U 0xfe89
#define GDK_dead_small_schwa 0xfe8a
#define GDK_dead_capital_schwa 0xfe8b
#define GDK_dead_greek 0xfe8c
#define GDK_First_Virtual_Screen 0xfed0
#define GDK_Prev_Virtual_Screen 0xfed1
#define GDK_Next_Virtual_Screen 0xfed2
@@ -332,6 +333,12 @@
#define GDK_Pointer_Accelerate 0xfefa
#define GDK_Pointer_DfltBtnNext 0xfefb
#define GDK_Pointer_DfltBtnPrev 0xfefc
#define GDK_ch 0xfea0
#define GDK_Ch 0xfea1
#define GDK_CH 0xfea2
#define GDK_c_h 0xfea3
#define GDK_C_h 0xfea4
#define GDK_C_H 0xfea5
#define GDK_3270_Duplicate 0xfd01
#define GDK_3270_FieldMark 0xfd02
#define GDK_3270_Right2 0xfd03
@@ -611,9 +618,9 @@
#define GDK_nacute 0x1f1
#define GDK_ncaron 0x1f2
#define GDK_odoubleacute 0x1f5
#define GDK_udoubleacute 0x1fb
#define GDK_rcaron 0x1f8
#define GDK_uring 0x1f9
#define GDK_udoubleacute 0x1fb
#define GDK_tcedilla 0x1fe
#define GDK_abovedot 0x1ff
#define GDK_Hstroke 0x2a1
@@ -674,32 +681,32 @@
#define GDK_uogonek 0x3f9
#define GDK_utilde 0x3fd
#define GDK_umacron 0x3fe
#define GDK_Wcircumflex 0x1000174
#define GDK_wcircumflex 0x1000175
#define GDK_Ycircumflex 0x1000176
#define GDK_ycircumflex 0x1000177
#define GDK_Babovedot 0x1001e02
#define GDK_babovedot 0x1001e03
#define GDK_Dabovedot 0x1001e0a
#define GDK_Wgrave 0x1001e80
#define GDK_Wacute 0x1001e82
#define GDK_dabovedot 0x1001e0b
#define GDK_Ygrave 0x1001ef2
#define GDK_Fabovedot 0x1001e1e
#define GDK_fabovedot 0x1001e1f
#define GDK_Mabovedot 0x1001e40
#define GDK_mabovedot 0x1001e41
#define GDK_Pabovedot 0x1001e56
#define GDK_wgrave 0x1001e81
#define GDK_pabovedot 0x1001e57
#define GDK_wacute 0x1001e83
#define GDK_Sabovedot 0x1001e60
#define GDK_ygrave 0x1001ef3
#define GDK_sabovedot 0x1001e61
#define GDK_Tabovedot 0x1001e6a
#define GDK_tabovedot 0x1001e6b
#define GDK_Wgrave 0x1001e80
#define GDK_wgrave 0x1001e81
#define GDK_Wacute 0x1001e82
#define GDK_wacute 0x1001e83
#define GDK_Wdiaeresis 0x1001e84
#define GDK_wdiaeresis 0x1001e85
#define GDK_sabovedot 0x1001e61
#define GDK_Wcircumflex 0x1000174
#define GDK_Tabovedot 0x1001e6a
#define GDK_Ycircumflex 0x1000176
#define GDK_wcircumflex 0x1000175
#define GDK_tabovedot 0x1001e6b
#define GDK_ycircumflex 0x1000177
#define GDK_Ygrave 0x1001ef2
#define GDK_ygrave 0x1001ef3
#define GDK_OE 0x13bc
#define GDK_oe 0x13bd
#define GDK_Ydiaeresis 0x13be
@@ -1194,6 +1201,7 @@
#define GDK_leftdoublequotemark 0xad2
#define GDK_rightdoublequotemark 0xad3
#define GDK_prescription 0xad4
#define GDK_permille 0xad5
#define GDK_minutes 0xad6
#define GDK_seconds 0xad7
#define GDK_latincross 0xad9
@@ -1627,6 +1635,8 @@
#define GDK_obarred 0x1000275
#define GDK_SCHWA 0x100018f
#define GDK_schwa 0x1000259
#define GDK_EZH 0x10001b7
#define GDK_ezh 0x1000292
#define GDK_Lbelowdot 0x1001e36
#define GDK_lbelowdot 0x1001e37
#define GDK_Abelowdot 0x1001ea0
@@ -2032,6 +2042,86 @@
#define GDK_braille_dots_1345678 0x10028fd
#define GDK_braille_dots_2345678 0x10028fe
#define GDK_braille_dots_12345678 0x10028ff
#define GDK_Sinh_ng 0x1000d82
#define GDK_Sinh_h2 0x1000d83
#define GDK_Sinh_a 0x1000d85
#define GDK_Sinh_aa 0x1000d86
#define GDK_Sinh_ae 0x1000d87
#define GDK_Sinh_aee 0x1000d88
#define GDK_Sinh_i 0x1000d89
#define GDK_Sinh_ii 0x1000d8a
#define GDK_Sinh_u 0x1000d8b
#define GDK_Sinh_uu 0x1000d8c
#define GDK_Sinh_ri 0x1000d8d
#define GDK_Sinh_rii 0x1000d8e
#define GDK_Sinh_lu 0x1000d8f
#define GDK_Sinh_luu 0x1000d90
#define GDK_Sinh_e 0x1000d91
#define GDK_Sinh_ee 0x1000d92
#define GDK_Sinh_ai 0x1000d93
#define GDK_Sinh_o 0x1000d94
#define GDK_Sinh_oo 0x1000d95
#define GDK_Sinh_au 0x1000d96
#define GDK_Sinh_ka 0x1000d9a
#define GDK_Sinh_kha 0x1000d9b
#define GDK_Sinh_ga 0x1000d9c
#define GDK_Sinh_gha 0x1000d9d
#define GDK_Sinh_ng2 0x1000d9e
#define GDK_Sinh_nga 0x1000d9f
#define GDK_Sinh_ca 0x1000da0
#define GDK_Sinh_cha 0x1000da1
#define GDK_Sinh_ja 0x1000da2
#define GDK_Sinh_jha 0x1000da3
#define GDK_Sinh_nya 0x1000da4
#define GDK_Sinh_jnya 0x1000da5
#define GDK_Sinh_nja 0x1000da6
#define GDK_Sinh_tta 0x1000da7
#define GDK_Sinh_ttha 0x1000da8
#define GDK_Sinh_dda 0x1000da9
#define GDK_Sinh_ddha 0x1000daa
#define GDK_Sinh_nna 0x1000dab
#define GDK_Sinh_ndda 0x1000dac
#define GDK_Sinh_tha 0x1000dad
#define GDK_Sinh_thha 0x1000dae
#define GDK_Sinh_dha 0x1000daf
#define GDK_Sinh_dhha 0x1000db0
#define GDK_Sinh_na 0x1000db1
#define GDK_Sinh_ndha 0x1000db3
#define GDK_Sinh_pa 0x1000db4
#define GDK_Sinh_pha 0x1000db5
#define GDK_Sinh_ba 0x1000db6
#define GDK_Sinh_bha 0x1000db7
#define GDK_Sinh_ma 0x1000db8
#define GDK_Sinh_mba 0x1000db9
#define GDK_Sinh_ya 0x1000dba
#define GDK_Sinh_ra 0x1000dbb
#define GDK_Sinh_la 0x1000dbd
#define GDK_Sinh_va 0x1000dc0
#define GDK_Sinh_sha 0x1000dc1
#define GDK_Sinh_ssha 0x1000dc2
#define GDK_Sinh_sa 0x1000dc3
#define GDK_Sinh_ha 0x1000dc4
#define GDK_Sinh_lla 0x1000dc5
#define GDK_Sinh_fa 0x1000dc6
#define GDK_Sinh_al 0x1000dca
#define GDK_Sinh_aa2 0x1000dcf
#define GDK_Sinh_ae2 0x1000dd0
#define GDK_Sinh_aee2 0x1000dd1
#define GDK_Sinh_i2 0x1000dd2
#define GDK_Sinh_ii2 0x1000dd3
#define GDK_Sinh_u2 0x1000dd4
#define GDK_Sinh_uu2 0x1000dd6
#define GDK_Sinh_ru2 0x1000dd8
#define GDK_Sinh_e2 0x1000dd9
#define GDK_Sinh_ee2 0x1000dda
#define GDK_Sinh_ai2 0x1000ddb
#define GDK_Sinh_o2 0x1000ddc
#define GDK_Sinh_oo2 0x1000ddd
#define GDK_Sinh_au2 0x1000dde
#define GDK_Sinh_lu2 0x1000ddf
#define GDK_Sinh_ruu2 0x1000df2
#define GDK_Sinh_luu2 0x1000df3
#define GDK_Sinh_kunddaliya 0x1000df4
#define GDK_ModeLock 0x1008ff01
#define GDK_MonBrightnessUp 0x1008ff02
#define GDK_MonBrightnessDown 0x1008ff03
@@ -2186,6 +2276,8 @@
#define GDK_Suspend 0x1008ffa7
#define GDK_Hibernate 0x1008ffa8
#define GDK_TouchpadToggle 0x1008ffa9
#define GDK_TouchpadOn 0x1008ffb0
#define GDK_TouchpadOff 0x1008ffb1
#define GDK_Switch_VT_1 0x1008fe01
#define GDK_Switch_VT_2 0x1008fe02
#define GDK_Switch_VT_3 0x1008fe03
@@ -2202,5 +2294,7 @@
#define GDK_ClearGrab 0x1008fe21
#define GDK_Next_VMode 0x1008fe22
#define GDK_Prev_VMode 0x1008fe23
#define GDK_LogWindowTree 0x1008fe24
#define GDK_LogGrabInfo 0x1008fe25
#endif /* __GDK_KEYSYMS_COMPAT_H__ */
+18 -18
View File
@@ -1,15 +1,15 @@
#!/usr/bin/env perl
# Updates http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms.h from upstream (X.org 7.x),
# from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
# Updates http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h from upstream (X.org 7.x),
# from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
#
# Author : Simos Xenitellis <simos at gnome dot org>.
# Authos : Bastien Nocera <hadess@hadess.net>
# Version : 1.2
#
# Input : http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
# Input : http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h
# Output : http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms.h
# Input : http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
# Input : http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
# Output : http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h
#
# Notes : It downloads keysymdef.h from the Internet, if not found locally,
# Notes : and creates an updated gdkkeysyms.h
@@ -23,31 +23,31 @@ my @keysymelements;
if ( ! -f "keysymdef.h" )
{
print "Trying to download keysymdef.h from\n";
print "http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\n";
die "Unable to download keysymdef.h from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\n"
unless system("wget -c -O keysymdef.h \"http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\"") == 0;
print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n";
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n"
unless system("wget -c -O keysymdef.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\"") == 0;
print " done.\n\n";
}
else
{
print "We are using existing keysymdef.h found in this directory.\n";
print "It is assumed that you took care and it is a recent version\n";
print "as found at http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=keysymdef.h\n\n";
print "as found at http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n\n";
}
if ( ! -f "XF86keysym.h" )
{
print "Trying to download XF86keysym.h from\n";
print "http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h\n";
die "Unable to download keysymdef.h from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h\n"
unless system("wget -c -O XF86keysym.h \"http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h\"") == 0;
print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n";
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n"
unless system("wget -c -O XF86keysym.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\"") == 0;
print " done.\n\n";
}
else
{
print "We are using existing XF86keysym.h found in this directory.\n";
print "It is assumed that you took care and it is a recent version\n";
print "as found at http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=XF86keysym.h\n\n";
print "as found at http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n\n";
}
if ( -f "gdkkeysyms.h" )
@@ -57,7 +57,7 @@ if ( -f "gdkkeysyms.h" )
die "Exiting...\n\n";
}
# Source: http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=keysymdef.h
# Source: http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
die "Could not open file keysymdef.h: $!\n" unless open(IN_KEYSYMDEF, "<:utf8", "keysymdef.h");
# Output: gtk+/gdk/gdkkeysyms.h
@@ -93,11 +93,11 @@ print OUT_GDKKEYSYMS_COMPAT $LICENSE_HEADER;
print OUT_GDKKEYSYMS<<EOF;
/*
* File auto-generated from script http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms-update.pl
* File auto-generated from script http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms-update.pl
* using the input file
* http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
* and
* http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
*/
/*
@@ -154,7 +154,7 @@ close IN_KEYSYMDEF;
#$gdksyms{"0"} = "0000";
# Source: http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=XF86keysym.h
# Source: http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
die "Could not open file XF86keysym.h: $!\n" unless open(IN_XF86KEYSYM, "<:utf8", "XF86keysym.h");
while (<IN_XF86KEYSYM>)
+29 -17
View File
@@ -18,11 +18,11 @@
/*
* File auto-generated from script http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms-update.pl
* File auto-generated from script http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms-update.pl
* using the input file
* http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
* and
* http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
*/
/*
@@ -295,6 +295,7 @@
#define GDK_KEY_dead_U 0xfe89
#define GDK_KEY_dead_small_schwa 0xfe8a
#define GDK_KEY_dead_capital_schwa 0xfe8b
#define GDK_KEY_dead_greek 0xfe8c
#define GDK_KEY_First_Virtual_Screen 0xfed0
#define GDK_KEY_Prev_Virtual_Screen 0xfed1
#define GDK_KEY_Next_Virtual_Screen 0xfed2
@@ -341,6 +342,12 @@
#define GDK_KEY_Pointer_Accelerate 0xfefa
#define GDK_KEY_Pointer_DfltBtnNext 0xfefb
#define GDK_KEY_Pointer_DfltBtnPrev 0xfefc
#define GDK_KEY_ch 0xfea0
#define GDK_KEY_Ch 0xfea1
#define GDK_KEY_CH 0xfea2
#define GDK_KEY_c_h 0xfea3
#define GDK_KEY_C_h 0xfea4
#define GDK_KEY_C_H 0xfea5
#define GDK_KEY_3270_Duplicate 0xfd01
#define GDK_KEY_3270_FieldMark 0xfd02
#define GDK_KEY_3270_Right2 0xfd03
@@ -620,9 +627,9 @@
#define GDK_KEY_nacute 0x1f1
#define GDK_KEY_ncaron 0x1f2
#define GDK_KEY_odoubleacute 0x1f5
#define GDK_KEY_udoubleacute 0x1fb
#define GDK_KEY_rcaron 0x1f8
#define GDK_KEY_uring 0x1f9
#define GDK_KEY_udoubleacute 0x1fb
#define GDK_KEY_tcedilla 0x1fe
#define GDK_KEY_abovedot 0x1ff
#define GDK_KEY_Hstroke 0x2a1
@@ -683,32 +690,32 @@
#define GDK_KEY_uogonek 0x3f9
#define GDK_KEY_utilde 0x3fd
#define GDK_KEY_umacron 0x3fe
#define GDK_KEY_Wcircumflex 0x1000174
#define GDK_KEY_wcircumflex 0x1000175
#define GDK_KEY_Ycircumflex 0x1000176
#define GDK_KEY_ycircumflex 0x1000177
#define GDK_KEY_Babovedot 0x1001e02
#define GDK_KEY_babovedot 0x1001e03
#define GDK_KEY_Dabovedot 0x1001e0a
#define GDK_KEY_Wgrave 0x1001e80
#define GDK_KEY_Wacute 0x1001e82
#define GDK_KEY_dabovedot 0x1001e0b
#define GDK_KEY_Ygrave 0x1001ef2
#define GDK_KEY_Fabovedot 0x1001e1e
#define GDK_KEY_fabovedot 0x1001e1f
#define GDK_KEY_Mabovedot 0x1001e40
#define GDK_KEY_mabovedot 0x1001e41
#define GDK_KEY_Pabovedot 0x1001e56
#define GDK_KEY_wgrave 0x1001e81
#define GDK_KEY_pabovedot 0x1001e57
#define GDK_KEY_wacute 0x1001e83
#define GDK_KEY_Sabovedot 0x1001e60
#define GDK_KEY_ygrave 0x1001ef3
#define GDK_KEY_sabovedot 0x1001e61
#define GDK_KEY_Tabovedot 0x1001e6a
#define GDK_KEY_tabovedot 0x1001e6b
#define GDK_KEY_Wgrave 0x1001e80
#define GDK_KEY_wgrave 0x1001e81
#define GDK_KEY_Wacute 0x1001e82
#define GDK_KEY_wacute 0x1001e83
#define GDK_KEY_Wdiaeresis 0x1001e84
#define GDK_KEY_wdiaeresis 0x1001e85
#define GDK_KEY_sabovedot 0x1001e61
#define GDK_KEY_Wcircumflex 0x1000174
#define GDK_KEY_Tabovedot 0x1001e6a
#define GDK_KEY_Ycircumflex 0x1000176
#define GDK_KEY_wcircumflex 0x1000175
#define GDK_KEY_tabovedot 0x1001e6b
#define GDK_KEY_ycircumflex 0x1000177
#define GDK_KEY_Ygrave 0x1001ef2
#define GDK_KEY_ygrave 0x1001ef3
#define GDK_KEY_OE 0x13bc
#define GDK_KEY_oe 0x13bd
#define GDK_KEY_Ydiaeresis 0x13be
@@ -1203,6 +1210,7 @@
#define GDK_KEY_leftdoublequotemark 0xad2
#define GDK_KEY_rightdoublequotemark 0xad3
#define GDK_KEY_prescription 0xad4
#define GDK_KEY_permille 0xad5
#define GDK_KEY_minutes 0xad6
#define GDK_KEY_seconds 0xad7
#define GDK_KEY_latincross 0xad9
@@ -1636,6 +1644,8 @@
#define GDK_KEY_obarred 0x1000275
#define GDK_KEY_SCHWA 0x100018f
#define GDK_KEY_schwa 0x1000259
#define GDK_KEY_EZH 0x10001b7
#define GDK_KEY_ezh 0x1000292
#define GDK_KEY_Lbelowdot 0x1001e36
#define GDK_KEY_lbelowdot 0x1001e37
#define GDK_KEY_Abelowdot 0x1001ea0
@@ -2293,5 +2303,7 @@
#define GDK_KEY_ClearGrab 0x1008fe21
#define GDK_KEY_Next_VMode 0x1008fe22
#define GDK_KEY_Prev_VMode 0x1008fe23
#define GDK_KEY_LogWindowTree 0x1008fe24
#define GDK_KEY_LogGrabInfo 0x1008fe25
#endif /* __GDK_KEYSYMS_H__ */
+2
View File
@@ -28,6 +28,8 @@
#include <errno.h>
#include <math.h>
#include "fallback-c89.c"
/**
* SECTION:rgba_colors
* @Short_description: RGBA colors
+26 -2
View File
@@ -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__ */
+25 -18
View File
@@ -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));
+6 -6
View File
@@ -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;
+36 -25
View File
@@ -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));
+24 -14
View File
@@ -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__ */
+1 -11
View File
@@ -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;
+6 -6
View File
@@ -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)
+43 -43
View File
@@ -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)
{
}
+10
View File
@@ -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
View File
@@ -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);
+2 -2
View File
@@ -145,7 +145,7 @@ translate_key_event (GdkDisplay *display,
gdk_event_set_device (event, device_manager->core_keyboard);
event->key.state = (GdkModifierType) xevent->xkey.state;
event->key.group = _gdk_x11_get_group_for_state (display, xevent->xkey.state);
event->key.group = gdk_x11_keymap_get_group_for_state (keymap, xevent->xkey.state);
event->key.hardware_keycode = xevent->xkey.keycode;
event->key.keyval = GDK_KEY_VoidSymbol;
@@ -161,7 +161,7 @@ translate_key_event (GdkDisplay *display,
_gdk_x11_keymap_add_virt_mods (keymap, &state);
event->key.state |= state;
event->key.is_modifier = _gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
_gdk_x11_event_translate_keyboard_string (&event->key);
+25 -12
View File
@@ -1062,7 +1062,7 @@ scroll_valuators_changed (GdkX11DeviceXI2 *device,
gdouble *dx,
gdouble *dy)
{
gdouble has_scroll_valuators = FALSE;
gboolean has_scroll_valuators = FALSE;
GdkScrollDirection direction;
guint n_axes, i, n_val;
gdouble *vals;
@@ -1160,10 +1160,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->key.time = xev->time;
event->key.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
event->key.group = _gdk_x11_get_group_for_state (display, event->key.state);
event->key.group = xev->group.effective;
event->key.hardware_keycode = xev->detail;
event->key.is_modifier = _gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->deviceid));
@@ -1305,20 +1305,37 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
case XI_Motion:
{
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
GdkDevice *source_device;
GdkDevice *source_device, *device;
gdouble delta_x, delta_y;
source_device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->sourceid));
device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->deviceid));
if (scroll_valuators_changed (GDK_X11_DEVICE_XI2 (source_device),
/* When scrolling, X might send events twice here; once with both the
* device and the source device set to the physical device, and once
* with the device set to the master device.
* Since we are only interested in the latter, and
* scroll_valuators_changed() updates the valuator cache for the
* source device, we need to explicitly ignore the first event in
* order to get the correct delta for the second.
*/
if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE &&
scroll_valuators_changed (GDK_X11_DEVICE_XI2 (source_device),
&xev->valuators, &delta_x, &delta_y))
{
event->scroll.type = GDK_SCROLL;
event->scroll.direction = GDK_SCROLL_SMOOTH;
GDK_NOTE(EVENTS,
g_message ("smooth scroll:\twindow %ld\n\tdeltas: %f %f",
g_message ("smooth scroll: %s\n\tdevice: %u\n\tsource device: %u\n\twindow %ld\n\tdeltas: %f %f",
#ifdef XINPUT_2_2
(xev->flags & XIPointerEmulated) ? "emulated" : "",
#else
"",
#endif
xev->deviceid, xev->sourceid,
xev->event, delta_x, delta_y));
@@ -1331,9 +1348,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->scroll.delta_x = delta_x;
event->scroll.delta_y = delta_y;
event->scroll.device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->deviceid));
event->scroll.device = device;
gdk_event_set_source_device (event, source_device);
event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
@@ -1348,9 +1363,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->motion.x_root = (gdouble) xev->root_x;
event->motion.y_root = (gdouble) xev->root_y;
event->motion.device = g_hash_table_lookup (device_manager->id_table,
GINT_TO_POINTER (xev->deviceid));
event->motion.device = device;
gdk_event_set_source_device (event, source_device);
event->motion.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
+42 -5
View File
@@ -1429,11 +1429,30 @@ _gdk_x11_display_manager_keyval_convert_case (GdkDisplayManager *manager,
*upper = xupper;
}
/**
* gdk_x11_keymap_get_group_for_state:
* @keymap: a #GdkX11Keymap
* @state: raw state returned from X
*
* Extracts the group from the state field sent in an X Key event.
* This is only needed for code processing raw X events, since #GdkEventKey
* directly includes an is_modifier field.
*
* Returns: the index of the active keyboard group for the event
*
* Since: 3.6
*/
gint
_gdk_x11_get_group_for_state (GdkDisplay *display,
GdkModifierType state)
gdk_x11_keymap_get_group_for_state (GdkKeymap *keymap,
guint state)
{
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
GdkDisplay *display;
GdkX11Display *display_x11;
g_return_val_if_fail (GDK_IS_X11_KEYMAP (keymap), 0);
display = keymap->display;
display_x11 = GDK_X11_DISPLAY (display);
#ifdef HAVE_XKB
if (display_x11->use_xkb)
@@ -1498,13 +1517,31 @@ gdk_x11_keymap_add_virtual_modifiers (GdkKeymap *keymap,
}
}
/**
* gdk_x11_keymap_key_is_modifier:
* @keymap: a #GdkX11Keymap
* @keycode: the hardware keycode from a key event
*
* Determines whether a particular key code represents a key that
* is a modifier. That is, it's a key that normally just affects
* the keyboard state and the behavior of other keys rather than
* producing a direct effect itself. This is only needed for code
* processing raw X events, since #GdkEventKey directly includes
* an is_modifier field.
*
* Returns: %TRUE if the hardware keycode is a modifier key
*
* Since: 3.6
*/
gboolean
_gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
guint keycode)
gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
guint keycode)
{
GdkX11Keymap *keymap_x11 = GDK_X11_KEYMAP (keymap);
gint i;
g_return_val_if_fail (GDK_IS_X11_KEYMAP (keymap), FALSE);
update_keyrange (keymap_x11);
if (keycode < keymap_x11->min_keycode ||
keycode > keymap_x11->max_keycode)
-4
View File
@@ -155,12 +155,8 @@ gboolean _gdk_x11_moveresize_configure_done (GdkDisplay *display,
void _gdk_x11_keymap_state_changed (GdkDisplay *display,
XEvent *event);
void _gdk_x11_keymap_keys_changed (GdkDisplay *display);
gint _gdk_x11_get_group_for_state (GdkDisplay *display,
GdkModifierType state);
void _gdk_x11_keymap_add_virt_mods (GdkKeymap *keymap,
GdkModifierType *modifiers);
gboolean _gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
guint keycode);
void _gdk_x11_windowing_init (void);
+5 -2
View File
@@ -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 }
};
+7
View File
@@ -42,6 +42,13 @@ typedef struct _GdkX11KeymapClass GdkX11KeymapClass;
GType gdk_x11_keymap_get_type (void);
GDK_AVAILABLE_IN_3_6
gint gdk_x11_keymap_get_group_for_state (GdkKeymap *keymap,
guint state);
GDK_AVAILABLE_IN_3_6
gboolean gdk_x11_keymap_key_is_modifier (GdkKeymap *keymap,
guint keycode);
G_END_DECLS
#endif /* __GDK_X11_KEYMAP_H__ */
+75 -19
View File
@@ -267,6 +267,7 @@ gtk_public_h_sources = \
gtklayout.h \
gtklinkbutton.h \
gtkliststore.h \
gtklistview.h \
gtklockbutton.h \
gtkmain.h \
gtkmenu.h \
@@ -405,7 +406,6 @@ gtk_private_h_sources = \
gtkaccelgroupprivate.h \
gtkaccelmapprivate.h \
gtkallocatedbitmaskprivate.h \
gtkanimationdescription.h \
gtkappchooserprivate.h \
gtkappchoosermodule.h \
gtkappchooseronline.h \
@@ -423,21 +423,43 @@ gtk_private_h_sources = \
gtkcolorscaleprivate.h \
gtkcolorchooserprivate.h \
gtkcontainerprivate.h \
gtkcssanimatedvaluesprivate.h \
gtkcssarrayvalueprivate.h \
gtkcssbgsizevalueprivate.h \
gtkcssbordervalueprivate.h \
gtkcsscomputedvaluesprivate.h \
gtkcsscornervalueprivate.h \
gtkcsscustompropertyprivate.h \
gtkcsseasevalueprivate.h \
gtkcssenginevalueprivate.h \
gtkcssenumvalueprivate.h \
gtkcssimagecrossfadeprivate.h \
gtkcssimagegradientprivate.h \
gtkcssimagelinearprivate.h \
gtkcssimageprivate.h \
gtkcssimageurlprivate.h \
gtkcssimagevalueprivate.h \
gtkcssimagewin32private.h \
gtkcssinheritvalueprivate.h \
gtkcssinitialvalueprivate.h \
gtkcsslookupprivate.h \
gtkcssmatcherprivate.h \
gtkcssnumbervalueprivate.h \
gtkcssparserprivate.h \
gtkcsspositionvalueprivate.h \
gtkcssproviderprivate.h \
gtkcssrepeatvalueprivate.h \
gtkcssrgbavalueprivate.h \
gtkcsssectionprivate.h \
gtkcssselectorprivate.h \
gtkcssshadowsvalueprivate.h \
gtkcssshadowvalueprivate.h \
gtkcssshorthandpropertyprivate.h \
gtkcssstringvalueprivate.h \
gtkcssstylefuncsprivate.h \
gtkcssstylepropertyprivate.h \
gtkcsstransitionprivate.h \
gtkcsstypedvalueprivate.h \
gtkcssvalueprivate.h \
gtkcustompaperunixdialog.h \
gtkentryprivate.h \
@@ -487,9 +509,10 @@ gtk_private_h_sources = \
gtksearchenginesimple.h \
gtkselectionprivate.h \
gtksettingsprivate.h \
gtkshadowprivate.h \
gtksizegroup-private.h \
gtksocketprivate.h \
gtkstyleanimationprivate.h \
gtkstylecascadeprivate.h \
gtkstylecontextprivate.h \
gtkstylepropertiesprivate.h \
gtkstylepropertyprivate.h \
@@ -506,7 +529,6 @@ gtk_private_h_sources = \
gtktextutil.h \
gtkthemingbackgroundprivate.h \
gtkthemingengineprivate.h \
gtktimeline.h \
gtktoolpaletteprivate.h \
gtktreedatalist.h \
gtktreeprivate.h \
@@ -572,7 +594,6 @@ gtk_base_c_sources = \
gtkappchooseronline.c \
gtkapplication.c \
gtkapplicationwindow.c \
gtkanimationdescription.c \
gtkarrow.c \
gtkaspectframe.c \
gtkassistant.c \
@@ -618,23 +639,45 @@ gtk_base_c_sources = \
gtkcombobox.c \
gtkcomboboxtext.c \
gtkcontainer.c \
gtkcssanimatedvalues.c \
gtkcssarrayvalue.c \
gtkcssbgsizevalue.c \
gtkcssbordervalue.c \
gtkcsscomputedvalues.c \
gtkcsscornervalue.c \
gtkcsscustomproperty.c \
gtkcsseasevalue.c \
gtkcssenumvalue.c \
gtkcssenginevalue.c \
gtkcssimage.c \
gtkcssimagecrossfade.c \
gtkcssimagegradient.c \
gtkcssimagelinear.c \
gtkcssimageurl.c \
gtkcssimagevalue.c \
gtkcssimagewin32.c \
gtkcssinheritvalue.c \
gtkcssinitialvalue.c \
gtkcsslookup.c \
gtkcssmatcher.c \
gtkcssnumbervalue.c \
gtkcssparser.c \
gtkcsspositionvalue.c \
gtkcssprovider.c \
gtkcssrepeatvalue.c \
gtkcssrgbavalue.c \
gtkcsssection.c \
gtkcssselector.c \
gtkcssstringvalue.c \
gtkcssshadowsvalue.c \
gtkcssshadowvalue.c \
gtkcssshorthandproperty.c \
gtkcssshorthandpropertyimpl.c \
gtkcssstylefuncs.c \
gtkcssstyleproperty.c \
gtkcssstylepropertyimpl.c \
gtkcsstransition.c \
gtkcsstypedvalue.c \
gtkcssvalue.c \
gtkcsstypes.c \
gtkdialog.c \
@@ -684,6 +727,7 @@ gtk_base_c_sources = \
gtklayout.c \
gtklinkbutton.c \
gtkliststore.c \
gtklistview.c \
gtklockbutton.c \
gtkmain.c \
gtkmarshalers.c \
@@ -748,13 +792,14 @@ gtk_base_c_sources = \
gtksettings.c \
gtksizegroup.c \
gtksizerequest.c \
gtkshadow.c \
gtkshow.c \
gtkspinbutton.c \
gtkspinner.c \
gtkstatusbar.c \
gtkstatusicon.c \
gtkstock.c \
gtkstyleanimation.c \
gtkstylecascade.c \
gtkstylecontext.c \
gtkstyleproperties.c \
gtkstyleproperty.c \
@@ -781,7 +826,6 @@ gtk_base_c_sources = \
gtktextview.c \
gtkthemingbackground.c \
gtkthemingengine.c \
gtktimeline.c \
gtktoggleaction.c \
gtktogglebutton.c \
gtktoggletoolbutton.c \
@@ -865,34 +909,46 @@ gtk_use_win32_c_sources = \
gtk_use_quartz_c_sources = \
gtksearchenginequartz.c \
gtkmountoperation-stub.c \
gtkquartz-menu.h \
gtkquartz-menu.c \
gtkmodelmenu-quartz.c \
gtkquartz.c
gtk_use_stub_c_sources = \
gtkmountoperation-stub.c
gtk_all_c_sources += $(gtk_use_x11_c_sources) $(gtk_use_win32_c_sources) $(gtk_use_quartz_c_sources) $(gtk_use_stub_c_sources)
if USE_X11
gtk_private_h_sources += \
gtk_use_x11_private_h_sources = \
gtkxembed.h \
gtktrayicon.h \
xembed.h
if USE_X11
gtk_c_sources += $(gtk_use_x11_c_sources)
else
if USE_WIN32
gtk_private_h_sources += \
gtk_private_h_sources += $(gtk_use_x11_private_h_sources)
endif
gtk_use_win32_private_h_sources = \
gtkwin32embed.h \
gtkwin32embedwidget.h
if USE_WIN32
gtk_c_sources += $(gtk_use_win32_c_sources)
else
if USE_QUARTZ
gtk_private_h_sources += \
gtk_private_h_sources += $(gtk_use_win32_private_h_sources)
endif
gtk_use_quartz_private_h_sources = \
gtksearchenginequartz.h \
gtkmenuquartz.h \
gtkmodelmenu-quartz.h \
gtkquartz.h
if USE_QUARTZ
gtk_c_sources += $(gtk_use_quartz_c_sources)
libgtk_3_la_CFLAGS = "-xobjective-c"
gtk_private_h_sources += $(gtk_use_quartz_private_h_sources)
endif
else
gtk_all_private_h_sources = \
$(gtk_use_x11_private_h_sources) \
$(gtk_use_win32_private_h_sources) \
$(gtk_use_quartz_private_h_sources)
if !USE_X11
if !USE_WIN32
if !USE_QUARTZ
gtk_c_sources += $(gtk_use_stub_c_sources)
endif
endif
@@ -976,7 +1032,7 @@ MAINTAINERCLEANFILES = \
stock-icons/icon-theme.cache
EXTRA_HEADERS =
EXTRA_DIST += $(gtk_private_h_sources) $(gtk_extra_sources)
EXTRA_DIST += $(gtk_all_private_h_sources) $(gtk_extra_sources)
EXTRA_DIST += $(gtk_built_sources)
EXTRA_DIST += $(STOCK_ICONS)
+1 -1
View File
@@ -226,7 +226,7 @@ get_pixbuf_box (GtkIconView *icon_view,
_gtk_icon_view_set_cell_data (icon_view, item);
gtk_cell_area_foreach_alloc (icon_view->priv->cell_area, context,
GTK_WIDGET (icon_view),
(GdkRectangle *)item, (GdkRectangle *)item,
&item->cell_area, &item->cell_area,
(GtkCellAllocCallback)get_pixbuf_foreach, &data);
return data.pixbuf_found;
+3 -1
View File
@@ -610,7 +610,9 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
*
* Creates a new #GtkFontSelection.
*
* Return value: a n ew #GtkFontSelection
* Return value: a new #GtkFontSelection
*
* Deprecated: 3.2: Use #GtkFontChooserWidget instead
*/
GtkWidget *
gtk_font_selection_new (void)
+12 -1
View File
@@ -53,4 +53,15 @@ rint (double x)
return ceil (x - 0.5);
}
}
#endif
#endif
#ifndef HAVE_NEARBYINT
/* Workaround for nearbyint() for non-GCC/non-C99 compilers */
/* This is quite similar to rint() in most respects */
static inline double
nearbyint (double x)
{
return floor (x + 0.5);
}
#endif
-8
View File
@@ -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;
+1 -5
View File
@@ -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);
}
*/
*/
+1
View File
@@ -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>
+2
View File
@@ -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
-175
View File
@@ -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;
}
-49
View File
@@ -1,49 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ANIMATION_DESCRIPTION_H__
#define __GTK_ANIMATION_DESCRIPTION_H__
#include "gtktimeline.h"
G_BEGIN_DECLS
/* Dummy typedefs */
typedef struct GtkAnimationDescription GtkAnimationDescription;
#define GTK_TYPE_ANIMATION_DESCRIPTION (_gtk_animation_description_get_type ())
GType _gtk_animation_description_get_type (void) G_GNUC_CONST;
GtkAnimationDescription * _gtk_animation_description_new (gdouble duration,
GtkTimelineProgressType progress_type,
gboolean loop);
gdouble _gtk_animation_description_get_duration (GtkAnimationDescription *desc);
GtkTimelineProgressType _gtk_animation_description_get_progress_type (GtkAnimationDescription *desc);
gboolean _gtk_animation_description_get_loop (GtkAnimationDescription *desc);
GtkAnimationDescription * _gtk_animation_description_ref (GtkAnimationDescription *desc);
void _gtk_animation_description_unref (GtkAnimationDescription *desc);
GtkAnimationDescription * _gtk_animation_description_from_string (const gchar *str);
void _gtk_animation_description_print (GtkAnimationDescription *desc,
GString *string);
G_END_DECLS
#endif /* __GTK_ANIMATION_DESCRIPTION_H__ */
+55 -40
View File
@@ -37,7 +37,7 @@
#include "gtkintl.h"
#ifdef GDK_WINDOWING_QUARTZ
#include "gtkquartz-menu.h"
#include "gtkmodelmenu-quartz.h"
#import <Cocoa/Cocoa.h>
#include <Carbon/Carbon.h>
#include "gtkmessagedialog.h"
@@ -149,7 +149,7 @@ struct _GtkApplicationPrivate
#ifdef GDK_WINDOWING_X11
GDBusConnection *session_bus;
const gchar *application_id;
gchar *object_path;
const gchar *object_path;
gchar *app_menu_path;
guint app_menu_id;
@@ -185,6 +185,9 @@ gtk_application_x11_publish_menu (GtkApplication *application,
{
gint i;
if (application->priv->session_bus == NULL)
return;
/* unexport any existing menu */
if (*id)
{
@@ -252,8 +255,8 @@ gtk_application_window_added_x11 (GtkApplication *application,
guint window_id;
window_id = application->priv->next_id++;
window_path = g_strdup_printf ("%s/window/%d", application->priv->object_path, window_id);
success = gtk_application_window_publish (app_window, application->priv->session_bus, window_path);
window_path = g_strdup_printf ("%s/window/%u", application->priv->object_path, window_id);
success = gtk_application_window_publish (app_window, application->priv->session_bus, window_path, window_id);
g_free (window_path);
}
while (!success);
@@ -271,34 +274,13 @@ gtk_application_window_removed_x11 (GtkApplication *application,
gtk_application_window_unpublish (GTK_APPLICATION_WINDOW (window));
}
static gchar *
object_path_from_appid (const gchar *appid)
{
gchar *appid_path, *iter;
appid_path = g_strconcat ("/", appid, NULL);
for (iter = appid_path; *iter; iter++)
{
if (*iter == '.')
*iter = '/';
if (*iter == '-')
*iter = '_';
}
return appid_path;
}
static void gtk_application_startup_session_dbus (GtkApplication *app);
static void
gtk_application_startup_x11 (GtkApplication *application)
{
const gchar *application_id;
application_id = g_application_get_application_id (G_APPLICATION (application));
application->priv->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
application->priv->object_path = object_path_from_appid (application_id);
application->priv->session_bus = g_application_get_dbus_connection (G_APPLICATION (application));
application->priv->object_path = g_application_get_dbus_object_path (G_APPLICATION (application));
gtk_application_startup_session_dbus (GTK_APPLICATION (application));
}
@@ -306,9 +288,8 @@ gtk_application_startup_x11 (GtkApplication *application)
static void
gtk_application_shutdown_x11 (GtkApplication *application)
{
g_free (application->priv->object_path);
application->priv->session_bus = NULL;
application->priv->object_path = NULL;
g_clear_object (&application->priv->session_bus);
g_clear_object (&application->priv->sm_proxy);
g_clear_object (&application->priv->client_proxy);
@@ -316,12 +297,6 @@ gtk_application_shutdown_x11 (GtkApplication *application)
g_free (application->priv->client_path);
}
const gchar *
gtk_application_get_dbus_object_path (GtkApplication *application)
{
return application->priv->object_path;
}
const gchar *
gtk_application_get_app_menu_object_path (GtkApplication *application)
{
@@ -526,6 +501,10 @@ gtk_application_init (GtkApplication *application)
application->priv = G_TYPE_INSTANCE_GET_PRIVATE (application,
GTK_TYPE_APPLICATION,
GtkApplicationPrivate);
#ifdef GDK_WINDOWING_X11
application->priv->next_id = 1;
#endif
}
static void
@@ -820,7 +799,7 @@ gtk_application_new (const gchar *application_id,
* @application: a #GtkApplication
* @window: a #GtkWindow
*
* Adds a window from @application.
* Adds a window to @application.
*
* This call is equivalent to setting the #GtkWindow:application
* property of @window to @application.
@@ -898,6 +877,34 @@ gtk_application_get_windows (GtkApplication *application)
return application->priv->windows;
}
/**
* gtk_application_get_window_by_id:
* @application: a #GtkApplication
* @id: an identifier number
*
* Returns: (transfer none): the #GtkApplicationWindow with ID @id, or
* %NULL if there is no window with this ID
*
* Since: 3.6
*/
GtkWindow *
gtk_application_get_window_by_id (GtkApplication *application,
guint id)
{
GList *l;
g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
for (l = application->priv->windows; l != NULL; l = l->next)
{
if (GTK_IS_APPLICATION_WINDOW (l->data) &&
gtk_application_window_get_id (GTK_APPLICATION_WINDOW (l->data)) == id)
return l->data;
}
return NULL;
}
/**
* gtk_application_add_accelerator:
* @application: a #GtkApplication
@@ -999,6 +1006,10 @@ gtk_application_remove_accelerator (GtkApplication *application,
*
* Sets or unsets the application menu for @application.
*
* This can only be done in the primary instance of the application,
* after it has been registered. #GApplication:startup is a good place
* to call this.
*
* The application menu is a single menu containing items that typically
* impact the application as a whole, rather than acting on a specific
* window or document. For example, you would expect to see
@@ -1008,8 +1019,6 @@ gtk_application_remove_accelerator (GtkApplication *application,
* If supported, the application menu will be rendered by the desktop
* environment.
*
* You might call this method in your #GApplication:startup signal handler.
*
* Use the base #GActionMap interface to add actions, to respond to the user
* selecting these menu items.
*
@@ -1020,6 +1029,8 @@ gtk_application_set_app_menu (GtkApplication *application,
GMenuModel *app_menu)
{
g_return_if_fail (GTK_IS_APPLICATION (application));
g_return_if_fail (g_application_get_is_registered (G_APPLICATION (application)));
g_return_if_fail (!g_application_get_is_remote (G_APPLICATION (application)));
if (app_menu != application->priv->app_menu)
{
@@ -1069,6 +1080,10 @@ gtk_application_get_app_menu (GtkApplication *application)
*
* This is a menubar in the traditional sense.
*
* This can only be done in the primary instance of the application,
* after it has been registered. #GApplication:startup is a good place
* to call this.
*
* Depending on the desktop environment, this may appear at the top of
* each window, or at the top of the screen. In some environments, if
* both the application menu and the menubar are set, the application
@@ -1077,8 +1092,6 @@ gtk_application_get_app_menu (GtkApplication *application)
* example, the application menu may be rendered by the desktop shell
* while the menubar (if set) remains in each individual window.
*
* You might call this method in your #GApplication:startup signal handler.
*
* Use the base #GActionMap interface to add actions, to respond to the user
* selecting these menu items.
*
@@ -1089,6 +1102,8 @@ gtk_application_set_menubar (GtkApplication *application,
GMenuModel *menubar)
{
g_return_if_fail (GTK_IS_APPLICATION (application));
g_return_if_fail (g_application_get_is_registered (G_APPLICATION (application)));
g_return_if_fail (!g_application_get_is_remote (G_APPLICATION (application)));
if (menubar != application->priv->menubar)
{
+4
View File
@@ -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__ */
+2 -3
View File
@@ -27,7 +27,8 @@
G_GNUC_INTERNAL
gboolean gtk_application_window_publish (GtkApplicationWindow *window,
GDBusConnection *session,
const gchar *object_path);
const gchar *object_path,
guint object_id);
G_GNUC_INTERNAL
void gtk_application_window_unpublish (GtkApplicationWindow *window);
@@ -43,8 +44,6 @@ GActionObservable * gtk_application_window_get_observable (GtkAppl
G_GNUC_INTERNAL
GtkAccelGroup * gtk_application_window_get_accel_group (GtkApplicationWindow *window);
G_GNUC_INTERNAL
const gchar * gtk_application_get_dbus_object_path (GtkApplication *application);
G_GNUC_INTERNAL
const gchar * gtk_application_get_app_menu_object_path (GtkApplication *application);
G_GNUC_INTERNAL
+71 -26
View File
@@ -218,6 +218,8 @@ struct _GtkApplicationWindowPrivate
GDBusConnection *session;
gchar *object_path;
guint export_id;
guint id;
};
static void
@@ -257,6 +259,32 @@ gtk_application_window_update_menubar (GtkApplicationWindow *window)
}
}
static gchar *
gtk_application_window_get_app_desktop_name (void)
{
gchar *retval = NULL;
#ifdef HAVE_GIO_UNIX
GDesktopAppInfo *app_info;
const gchar *app_name = NULL;
gchar *desktop_file;
desktop_file = g_strconcat (g_get_prgname (), ".desktop", NULL);
app_info = g_desktop_app_info_new (desktop_file);
g_free (desktop_file);
if (app_info != NULL)
app_name = g_app_info_get_name (G_APP_INFO (app_info));
if (app_name != NULL)
retval = g_strdup (app_name);
g_clear_object (&app_info);
#endif /* HAVE_GIO_UNIX */
return retval;
}
static void
gtk_application_window_update_shell_shows_app_menu (GtkApplicationWindow *window,
GtkSettings *settings)
@@ -282,33 +310,25 @@ gtk_application_window_update_shell_shows_app_menu (GtkApplicationWindow *window
if (app_menu != NULL)
{
const gchar *name;
GDesktopAppInfo *app_info = NULL;
const gchar *app_name;
gchar *name;
name = g_get_application_name ();
if (name == g_get_prgname ())
app_name = g_get_application_name ();
if (app_name != g_get_prgname ())
{
const gchar *app_name = NULL;
#ifdef HAVE_GIO_UNIX
gchar *desktop_name;
desktop_name = g_strconcat (name, ".desktop", NULL);
app_info = g_desktop_app_info_new (desktop_name);
if (app_info != NULL)
app_name = g_app_info_get_name (G_APP_INFO (app_info));
g_free (desktop_name);
#endif /* HAVE_GIO_UNIX */
if (app_name != NULL &&
g_strcmp0 (app_name, name) != 0)
name = app_name;
else
name = _("Application");
/* the app has set its application name, use it */
name = g_strdup (app_name);
}
else
{
/* get the name from .desktop file */
name = gtk_application_window_get_app_desktop_name ();
if (name == NULL)
name = g_strdup (_("Application"));
}
g_menu_append_submenu (window->priv->app_menu_section, name, app_menu);
g_clear_object (&app_info);
g_free (name);
}
}
}
@@ -750,7 +770,7 @@ gtk_application_window_real_realize (GtkWidget *widget)
gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
if (GDK_IS_X11_WINDOW (gdkwindow))
if (GDK_IS_X11_WINDOW (gdkwindow) && window->priv->session)
{
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_ID",
g_application_get_application_id (G_APPLICATION (application)));
@@ -759,7 +779,7 @@ gtk_application_window_real_realize (GtkWidget *widget)
g_dbus_connection_get_unique_name (window->priv->session));
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_OBJECT_PATH",
gtk_application_get_dbus_object_path (application));
g_application_get_dbus_object_path (G_APPLICATION (application)));
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_WINDOW_OBJECT_PATH",
window->priv->object_path);
@@ -791,11 +811,13 @@ gtk_application_window_real_unrealize (GtkWidget *widget)
gboolean
gtk_application_window_publish (GtkApplicationWindow *window,
GDBusConnection *session,
const gchar *object_path)
const gchar *object_path,
guint object_id)
{
g_assert (window->priv->session == NULL);
g_assert (window->priv->export_id == 0);
g_assert (window->priv->object_path == NULL);
g_assert (window->priv->id == 0);
window->priv->export_id = g_dbus_connection_export_action_group (session, object_path,
G_ACTION_GROUP (window->priv->actions),
@@ -806,6 +828,7 @@ gtk_application_window_publish (GtkApplicationWindow *window,
window->priv->session = session;
window->priv->object_path = g_strdup (object_path);
window->priv->id = object_id;
return TRUE;
}
@@ -816,10 +839,12 @@ gtk_application_window_unpublish (GtkApplicationWindow *window)
g_assert (window->priv->session != NULL);
g_assert (window->priv->export_id != 0);
g_assert (window->priv->object_path != NULL);
g_assert (window->priv->id != 0);
g_dbus_connection_unexport_action_group (window->priv->session, window->priv->export_id);
window->priv->session = NULL;
window->priv->export_id = 0;
window->priv->id = 0;
g_free (window->priv->object_path);
window->priv->object_path = NULL;
@@ -1068,3 +1093,23 @@ gtk_application_window_get_accel_group (GtkApplicationWindow *window)
{
return window->priv->accels;
}
/**
* gtk_application_window_get_id:
* @window: a #GtkApplicationWindow
*
* Returns the unique ID of the window. If the window has not yet been added to
* a #GtkApplication, returns <literal>0</literal>.
*
* Returns: the unique ID for @window, or <literal>0</literal> if the window
* has not yet been added to a #GtkApplication
*
* Since: 3.6
*/
guint
gtk_application_window_get_id (GtkApplicationWindow *window)
{
g_return_val_if_fail (GTK_IS_APPLICATION_WINDOW (window), 0);
return window->priv->id;
}
+3
View File
@@ -67,6 +67,9 @@ void gtk_application_window_set_show_menubar (GtkApplicationWindow *windo
GDK_AVAILABLE_IN_3_4
gboolean gtk_application_window_get_show_menubar (GtkApplicationWindow *window);
GDK_AVAILABLE_IN_3_6
guint gtk_application_window_get_id (GtkApplicationWindow *window);
G_END_DECLS
#endif /* __GTK_APPLICATION_WINDOW_H__ */
+51 -38
View File
@@ -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);
}
+4 -5
View File
@@ -24,8 +24,8 @@
#include "gtkborder.h"
#include "gtkcssimageprivate.h"
#include "gtkcssvalueprivate.h"
#include "gtkthemingengine.h"
#include "gtkcsstypesprivate.h"
G_BEGIN_DECLS
@@ -34,10 +34,9 @@ typedef struct _GtkBorderImage GtkBorderImage;
struct _GtkBorderImage {
GtkCssImage *source;
GtkBorder slice;
gboolean has_width;
GtkBorder width;
GtkCssBorderImageRepeat repeat;
GtkCssValue *slice;
GtkCssValue *width;
GtkCssValue *repeat;
};
gboolean _gtk_border_image_init (GtkBorderImage *image,
+9 -2
View File
@@ -85,6 +85,7 @@
#include "gtktypebuiltins.h"
#include "gtksizerequest.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "a11y/gtkboxaccessible.h"
@@ -898,7 +899,7 @@ gtk_box_get_path_for_child (GtkContainer *container,
box = GTK_BOX (container);
private = box->priv;
path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
path = _gtk_widget_create_path (GTK_WIDGET (container));
if (gtk_widget_get_visible (child))
{
@@ -937,11 +938,17 @@ gtk_box_get_path_for_child (GtkContainer *container,
return path;
}
static void
gtk_box_invalidate_order_foreach (GtkWidget *widget)
{
_gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
}
static void
gtk_box_invalidate_order (GtkBox *box)
{
gtk_container_foreach (GTK_CONTAINER (box),
(GtkCallback) gtk_widget_reset_style,
(GtkCallback) gtk_box_invalidate_order_foreach,
NULL);
}
+4 -4
View File
@@ -963,15 +963,15 @@ end_element (GMarkupParseContext *context,
else if (strcmp (element_name, "interface") == 0)
{
}
else if (strcmp (element_name, "menu") == 0)
{
_gtk_builder_menu_end (data);
}
else if (data->requested_objects && !data->inside_requested_object)
{
/* If outside a requested object, simply ignore this tag */
return;
}
else if (strcmp (element_name, "menu") == 0)
{
_gtk_builder_menu_end (data);
}
else if (strcmp (element_name, "object") == 0)
{
ObjectInfo *object_info = state_pop_info (data, ObjectInfo);
+9 -27
View File
@@ -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;
-5
View File
@@ -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
-1
View File
@@ -38,7 +38,6 @@
#undef GDK_DEPRECATED_FOR
#define GDK_DEPRECATED
#define GDK_DEPRECATED_FOR(f)
#undef GTK_DISABLE_DEPRECATED
#include "deprecated/gtkstyle.h"
+59 -5
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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)
{
+3 -3
View File
@@ -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);
+307
View File
@@ -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;
}
+64
View File
@@ -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__ */
+206
View File
@@ -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 = { &GTK_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 (&GTK_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 == &GTK_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 == &GTK_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 == &GTK_CSS_VALUE_ARRAY, 0);
return value->n_values;
}
+46
View File
@@ -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__ */
+258
View File
@@ -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 = { &GTK_CSS_VALUE_BG_SIZE, 1, FALSE, FALSE, NULL, NULL };
static GtkCssValue cover_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, NULL, NULL };
static GtkCssValue contain_singleton = { &GTK_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, &GTK_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 == &GTK_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 == &GTK_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);
}
+45
View File
@@ -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__ */
+235
View File
@@ -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, &GTK_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 == &GTK_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 == &GTK_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 == &GTK_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 == &GTK_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 == &GTK_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;
}
+49
View File
@@ -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
View File
@@ -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;
}
+3 -2
View File
@@ -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
+170
View File
@@ -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, &GTK_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 == &GTK_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 == &GTK_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 == &GTK_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);
}
+42
View File
@@ -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
View File
@@ -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;
+370
View File
@@ -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, &GTK_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, &GTK_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 == &GTK_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;
}
}
+41
View File
@@ -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__ */
+127
View File
@@ -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, &GTK_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 == &GTK_CSS_VALUE_ENGINE, NULL);
return value->engine;
}
+37
View File
@@ -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__ */
+323
View File
@@ -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[] = {
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_NONE, "none" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_INSET, "inset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_OUTSET, "outset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_HIDDEN, "hidden" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_DOTTED, "dotted" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_DASHED, "dashed" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, GTK_BORDER_STYLE_GROOVE, "groove" },
{ &GTK_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 == &GTK_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[] = {
{ &GTK_CSS_VALUE_FONT_STYLE, 1, PANGO_STYLE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, PANGO_STYLE_OBLIQUE, "oblique" },
{ &GTK_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 == &GTK_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[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT, 1, PANGO_VARIANT_NORMAL, "normal" },
{ &GTK_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 == &GTK_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[] = {
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_THIN, "100" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_ULTRALIGHT, "200" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_LIGHT, "300" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_MEDIUM, "500" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_SEMIBOLD, "600" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_BOLD, "bold" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, PANGO_WEIGHT_ULTRABOLD, "800" },
{ &GTK_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 == &GTK_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[] = {
{ &GTK_CSS_VALUE_AREA, 1, GTK_CSS_AREA_BORDER_BOX, "border-box" },
{ &GTK_CSS_VALUE_AREA, 1, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
{ &GTK_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 == &GTK_CSS_VALUE_AREA, GTK_CSS_AREA_BORDER_BOX);
return value->value;
}
+52
View File
@@ -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
View File
@@ -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;
+269
View File
@@ -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);
}
+59
View File
@@ -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__ */
+2 -1
View File
@@ -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
View File
@@ -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 (&copy->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);
}
+4 -7
View File
@@ -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;
};
+96
View File
@@ -0,0 +1,96 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcssimagevalueprivate.h"
#include "gtkcssimagecrossfadeprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
GtkCssImage *image;
};
static void
gtk_css_value_image_free (GtkCssValue *value)
{
g_object_unref (value->image);
g_slice_free (GtkCssValue, value);
}
static gboolean
gtk_css_value_image_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
return value1->image == value2->image;
}
static GtkCssValue *
gtk_css_value_image_transition (GtkCssValue *start,
GtkCssValue *end,
double progress)
{
GtkCssImage *fade;
fade = _gtk_css_image_cross_fade_new (_gtk_css_image_value_get_image (start),
_gtk_css_image_value_get_image (end),
progress);
return _gtk_css_image_value_new (fade);
}
static void
gtk_css_value_image_print (const GtkCssValue *value,
GString *string)
{
if (value->image)
_gtk_css_image_print (value->image, string);
else
g_string_append (string, "none");
}
static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
gtk_css_value_image_free,
gtk_css_value_image_equal,
gtk_css_value_image_transition,
gtk_css_value_image_print
};
GtkCssValue *
_gtk_css_image_value_new (GtkCssImage *image)
{
static GtkCssValue none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, NULL };
GtkCssValue *value;
if (image == NULL)
return _gtk_css_value_ref (&none_singleton);
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_IMAGE);
value->image = image;
return value;
}
GtkCssImage *
_gtk_css_image_value_get_image (const GtkCssValue *value)
{
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_IMAGE, NULL);
return value->image;
}
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Alexander Larsson <alexl@gnome.org>
*/
#ifndef __GTK_CSS_IMAGE_VALUE_PRIVATE_H__
#define __GTK_CSS_IMAGE_VALUE_PRIVATE_H__
#include "gtkcssimageprivate.h"
#include "gtkcssvalueprivate.h"
G_BEGIN_DECLS
GtkCssValue * _gtk_css_image_value_new (GtkCssImage *image);
GtkCssImage * _gtk_css_image_value_get_image (const GtkCssValue *image);
G_END_DECLS
#endif /* __GTK_CSS_IMAGE_VALUE_PRIVATE_H__ */
+76
View File
@@ -0,0 +1,76 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcssinheritvalueprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
};
static void
gtk_css_value_inherit_free (GtkCssValue *value)
{
/* Can only happen if the unique value gets unreffed too often */
g_assert_not_reached ();
}
static gboolean
gtk_css_value_inherit_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
return TRUE;
}
static GtkCssValue *
gtk_css_value_inherit_transition (GtkCssValue *start,
GtkCssValue *end,
double progress)
{
return NULL;
}
static void
gtk_css_value_inherit_print (const GtkCssValue *value,
GString *string)
{
g_string_append (string, "inherit");
}
static const GtkCssValueClass GTK_CSS_VALUE_INHERIT = {
gtk_css_value_inherit_free,
gtk_css_value_inherit_equal,
gtk_css_value_inherit_transition,
gtk_css_value_inherit_print
};
static GtkCssValue inherit = { &GTK_CSS_VALUE_INHERIT, 1 };
GtkCssValue *
_gtk_css_inherit_value_new (void)
{
return _gtk_css_value_ref (&inherit);
}
gboolean
_gtk_css_value_is_inherit (const GtkCssValue *value)
{
g_return_val_if_fail (value != NULL, FALSE);
return value == &inherit;
}
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Alexander Larsson <alexl@gnome.org>
*/
#ifndef __GTK_CSS_INHERIT_VALUE_PRIVATE_H__
#define __GTK_CSS_INHERIT_VALUE_PRIVATE_H__
#include "gtkcssvalueprivate.h"
G_BEGIN_DECLS
GtkCssValue * _gtk_css_inherit_value_new (void);
gboolean _gtk_css_value_is_inherit (const GtkCssValue *value);
G_END_DECLS
#endif /* __GTK_CSS_INHERIT_VALUE_PRIVATE_H__ */
+76
View File
@@ -0,0 +1,76 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcssinitialvalueprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
};
static void
gtk_css_value_initial_free (GtkCssValue *value)
{
/* Can only happen if the unique value gets unreffed too often */
g_assert_not_reached ();
}
static gboolean
gtk_css_value_initial_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
return TRUE;
}
static GtkCssValue *
gtk_css_value_initial_transition (GtkCssValue *start,
GtkCssValue *end,
double progress)
{
return NULL;
}
static void
gtk_css_value_initial_print (const GtkCssValue *value,
GString *string)
{
g_string_append (string, "initial");
}
static const GtkCssValueClass GTK_CSS_VALUE_INITIAL = {
gtk_css_value_initial_free,
gtk_css_value_initial_equal,
gtk_css_value_initial_transition,
gtk_css_value_initial_print
};
static GtkCssValue initial = { &GTK_CSS_VALUE_INITIAL, 1 };
GtkCssValue *
_gtk_css_initial_value_new (void)
{
return _gtk_css_value_ref (&initial);
}
gboolean
_gtk_css_value_is_initial (const GtkCssValue *value)
{
g_return_val_if_fail (value != NULL, FALSE);
return value == &initial;
}
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Alexander Larsson <alexl@gnome.org>
*/
#ifndef __GTK_CSS_INITIAL_VALUE_PRIVATE_H__
#define __GTK_CSS_INITIAL_VALUE_PRIVATE_H__
#include "gtkcssvalueprivate.h"
G_BEGIN_DECLS
GtkCssValue * _gtk_css_initial_value_new (void);
gboolean _gtk_css_value_is_initial (const GtkCssValue *value);
G_END_DECLS
#endif /* __GTK_CSS_INITIAL_VALUE_PRIVATE_H__ */
+423
View File
@@ -0,0 +1,423 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcssmatcherprivate.h"
#include "gtkwidgetpath.h"
/* GTK_CSS_MATCHER_WIDGET_PATH */
static gboolean
gtk_css_matcher_widget_path_get_parent (GtkCssMatcher *matcher,
const GtkCssMatcher *child)
{
if (child->path.index == 0)
return FALSE;
matcher->path.klass = child->path.klass;
matcher->path.path = child->path.path;
matcher->path.state_flags = 0;
matcher->path.index = child->path.index - 1;
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index);
return TRUE;
}
static gboolean
gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher,
const GtkCssMatcher *next)
{
if (next->path.sibling_index == 0)
return FALSE;
matcher->path.klass = next->path.klass;
matcher->path.path = next->path.path;
matcher->path.state_flags = 0;
matcher->path.index = next->path.index;
matcher->path.sibling_index = next->path.sibling_index - 1;
return TRUE;
}
static GtkStateFlags
gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher)
{
return matcher->path.state_flags;
}
static gboolean
gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher,
const char *name)
{
const GtkWidgetPath *siblings;
GType type;
type = g_type_from_name (name);
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
return g_type_is_a (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index), type);
else
return g_type_is_a (gtk_widget_path_iter_get_object_type (matcher->path.path, matcher->path.index), type);
}
static gboolean
gtk_css_matcher_widget_path_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
const GtkWidgetPath *siblings;
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
return gtk_widget_path_iter_has_qclass (siblings, matcher->path.sibling_index, class_name);
else
return gtk_widget_path_iter_has_qclass (matcher->path.path, matcher->path.index, class_name);
}
static gboolean
gtk_css_matcher_widget_path_has_id (const GtkCssMatcher *matcher,
const char *id)
{
const GtkWidgetPath *siblings;
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
return gtk_widget_path_iter_has_name (siblings, matcher->path.sibling_index, id);
else
return gtk_widget_path_iter_has_name (matcher->path.path, matcher->path.index, id);
}
static gboolean
gtk_css_matcher_widget_path_has_regions (const GtkCssMatcher *matcher)
{
const GtkWidgetPath *siblings;
GSList *regions;
gboolean result;
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
regions = gtk_widget_path_iter_list_regions (siblings, matcher->path.sibling_index);
else
regions = gtk_widget_path_iter_list_regions (matcher->path.path, matcher->path.index);
result = regions != NULL;
g_slist_free (regions);
return result;
}
static gboolean
gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher,
const char *region,
GtkRegionFlags flags)
{
const GtkWidgetPath *siblings;
GtkRegionFlags region_flags;
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
{
if (!gtk_widget_path_iter_has_region (siblings, matcher->path.sibling_index, region, &region_flags))
return FALSE;
}
else
{
if (!gtk_widget_path_iter_has_region (matcher->path.path, matcher->path.index, region, &region_flags))
return FALSE;
}
if ((flags & region_flags) != flags)
return FALSE;
return TRUE;
}
static gboolean
gtk_css_matcher_widget_path_has_position (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b)
{
const GtkWidgetPath *siblings;
int x;
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (!siblings)
return FALSE;
if (forward)
x = matcher->path.sibling_index + 1;
else
x = gtk_widget_path_length (siblings) - matcher->path.sibling_index;
x -= b;
if (a == 0)
return x == 0;
if (x % a)
return FALSE;
return x / a > 0;
}
static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
gtk_css_matcher_widget_path_get_parent,
gtk_css_matcher_widget_path_get_previous,
gtk_css_matcher_widget_path_get_state,
gtk_css_matcher_widget_path_has_name,
gtk_css_matcher_widget_path_has_class,
gtk_css_matcher_widget_path_has_id,
gtk_css_matcher_widget_path_has_regions,
gtk_css_matcher_widget_path_has_region,
gtk_css_matcher_widget_path_has_position,
};
gboolean
_gtk_css_matcher_init (GtkCssMatcher *matcher,
const GtkWidgetPath *path,
GtkStateFlags state)
{
if (gtk_widget_path_length (path) == 0)
return FALSE;
matcher->path.klass = &GTK_CSS_MATCHER_WIDGET_PATH;
matcher->path.path = path;
matcher->path.state_flags = state;
matcher->path.index = gtk_widget_path_length (path) - 1;
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->path.index);
return TRUE;
}
/* GTK_CSS_MATCHER_WIDGET_ANY */
static gboolean
gtk_css_matcher_any_get_parent (GtkCssMatcher *matcher,
const GtkCssMatcher *child)
{
_gtk_css_matcher_any_init (matcher);
return TRUE;
}
static gboolean
gtk_css_matcher_any_get_previous (GtkCssMatcher *matcher,
const GtkCssMatcher *next)
{
_gtk_css_matcher_any_init (matcher);
return TRUE;
}
static GtkStateFlags
gtk_css_matcher_any_get_state (const GtkCssMatcher *matcher)
{
/* XXX: This gets tricky when we implement :not() */
return GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED
| GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT
| GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_BACKDROP;
}
static gboolean
gtk_css_matcher_any_has_name (const GtkCssMatcher *matcher,
const char *name)
{
return TRUE;
}
static gboolean
gtk_css_matcher_any_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
return TRUE;
}
static gboolean
gtk_css_matcher_any_has_id (const GtkCssMatcher *matcher,
const char *id)
{
return TRUE;
}
static gboolean
gtk_css_matcher_any_has_regions (const GtkCssMatcher *matcher)
{
return TRUE;
}
static gboolean
gtk_css_matcher_any_has_region (const GtkCssMatcher *matcher,
const char *region,
GtkRegionFlags flags)
{
return TRUE;
}
static gboolean
gtk_css_matcher_any_has_position (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b)
{
return TRUE;
}
static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = {
gtk_css_matcher_any_get_parent,
gtk_css_matcher_any_get_previous,
gtk_css_matcher_any_get_state,
gtk_css_matcher_any_has_name,
gtk_css_matcher_any_has_class,
gtk_css_matcher_any_has_id,
gtk_css_matcher_any_has_regions,
gtk_css_matcher_any_has_region,
gtk_css_matcher_any_has_position,
};
void
_gtk_css_matcher_any_init (GtkCssMatcher *matcher)
{
matcher->klass = &GTK_CSS_MATCHER_ANY;
}
/* GTK_CSS_MATCHER_WIDGET_SUPERSET */
static gboolean
gtk_css_matcher_superset_get_parent (GtkCssMatcher *matcher,
const GtkCssMatcher *child)
{
_gtk_css_matcher_any_init (matcher);
return TRUE;
}
static gboolean
gtk_css_matcher_superset_get_previous (GtkCssMatcher *matcher,
const GtkCssMatcher *next)
{
_gtk_css_matcher_any_init (matcher);
return TRUE;
}
static GtkStateFlags
gtk_css_matcher_superset_get_state (const GtkCssMatcher *matcher)
{
/* XXX: This gets tricky when we implement :not() */
if (matcher->superset.relevant & GTK_CSS_CHANGE_STATE)
return _gtk_css_matcher_get_state (matcher->superset.subset);
else
return GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED
| GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT
| GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_BACKDROP;
}
static gboolean
gtk_css_matcher_superset_has_name (const GtkCssMatcher *matcher,
const char *name)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
return _gtk_css_matcher_has_name (matcher->superset.subset, name);
else
return TRUE;
}
static gboolean
gtk_css_matcher_superset_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_CLASS)
return _gtk_css_matcher_has_class (matcher->superset.subset, class_name);
else
return TRUE;
}
static gboolean
gtk_css_matcher_superset_has_id (const GtkCssMatcher *matcher,
const char *id)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
return _gtk_css_matcher_has_id (matcher->superset.subset, id);
else
return TRUE;
}
static gboolean
gtk_css_matcher_superset_has_regions (const GtkCssMatcher *matcher)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
return _gtk_css_matcher_has_regions (matcher->superset.subset);
else
return TRUE;
}
static gboolean
gtk_css_matcher_superset_has_region (const GtkCssMatcher *matcher,
const char *region,
GtkRegionFlags flags)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_POSITION)
return _gtk_css_matcher_has_region (matcher->superset.subset, region, flags);
else
return _gtk_css_matcher_has_region (matcher->superset.subset, region, 0);
}
else
return TRUE;
}
static gboolean
gtk_css_matcher_superset_has_position (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_POSITION)
return _gtk_css_matcher_has_position (matcher->superset.subset, forward, a, b);
else
return TRUE;
}
static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
gtk_css_matcher_superset_get_parent,
gtk_css_matcher_superset_get_previous,
gtk_css_matcher_superset_get_state,
gtk_css_matcher_superset_has_name,
gtk_css_matcher_superset_has_class,
gtk_css_matcher_superset_has_id,
gtk_css_matcher_superset_has_regions,
gtk_css_matcher_superset_has_region,
gtk_css_matcher_superset_has_position,
};
void
_gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
const GtkCssMatcher *subset,
GtkCssChange relevant)
{
g_return_if_fail (subset != NULL);
g_return_if_fail ((relevant & ~(GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_STATE)) == 0);
matcher->superset.klass = &GTK_CSS_MATCHER_SUPERSET;
matcher->superset.subset = subset;
matcher->superset.relevant = relevant;
}
+152
View File
@@ -0,0 +1,152 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_MATCHER_PRIVATE_H__
#define __GTK_CSS_MATCHER_PRIVATE_H__
#include <gtk/gtkenums.h>
#include <gtk/gtktypes.h>
#include "gtk/gtkcsstypesprivate.h"
G_BEGIN_DECLS
typedef union _GtkCssMatcher GtkCssMatcher;
typedef struct _GtkCssMatcherSuperset GtkCssMatcherSuperset;
typedef struct _GtkCssMatcherWidgetPath GtkCssMatcherWidgetPath;
typedef struct _GtkCssMatcherClass GtkCssMatcherClass;
struct _GtkCssMatcherClass {
gboolean (* get_parent) (GtkCssMatcher *matcher,
const GtkCssMatcher *child);
gboolean (* get_previous) (GtkCssMatcher *matcher,
const GtkCssMatcher *next);
GtkStateFlags (* get_state) (const GtkCssMatcher *matcher);
gboolean (* has_name) (const GtkCssMatcher *matcher,
const char *name);
gboolean (* has_class) (const GtkCssMatcher *matcher,
GQuark class_name);
gboolean (* has_id) (const GtkCssMatcher *matcher,
const char *id);
gboolean (* has_regions) (const GtkCssMatcher *matcher);
gboolean (* has_region) (const GtkCssMatcher *matcher,
const char *region,
GtkRegionFlags flags);
gboolean (* has_position) (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b);
};
struct _GtkCssMatcherWidgetPath {
const GtkCssMatcherClass *klass;
const GtkWidgetPath *path;
GtkStateFlags state_flags;
guint index;
guint sibling_index;
};
struct _GtkCssMatcherSuperset {
const GtkCssMatcherClass *klass;
const GtkCssMatcher *subset;
GtkCssChange relevant;
};
union _GtkCssMatcher {
const GtkCssMatcherClass *klass;
GtkCssMatcherWidgetPath path;
GtkCssMatcherSuperset superset;
};
gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher,
const GtkWidgetPath *path,
GtkStateFlags state) G_GNUC_WARN_UNUSED_RESULT;
void _gtk_css_matcher_any_init (GtkCssMatcher *matcher);
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
const GtkCssMatcher *subset,
GtkCssChange relevant);
static inline gboolean
_gtk_css_matcher_get_parent (GtkCssMatcher *matcher,
const GtkCssMatcher *child)
{
return child->klass->get_parent (matcher, child);
}
static inline gboolean
_gtk_css_matcher_get_previous (GtkCssMatcher *matcher,
const GtkCssMatcher *next)
{
return next->klass->get_previous (matcher, next);
}
static inline GtkStateFlags
_gtk_css_matcher_get_state (const GtkCssMatcher *matcher)
{
return matcher->klass->get_state (matcher);
}
static inline gboolean
_gtk_css_matcher_has_name (const GtkCssMatcher *matcher,
const char *name)
{
return matcher->klass->has_name (matcher, name);
}
static inline gboolean
_gtk_css_matcher_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
return matcher->klass->has_class (matcher, class_name);
}
static inline gboolean
_gtk_css_matcher_has_id (const GtkCssMatcher *matcher,
const char *id)
{
return matcher->klass->has_id (matcher, id);
}
static inline gboolean
_gtk_css_matcher_has_regions (const GtkCssMatcher *matcher)
{
return matcher->klass->has_regions (matcher);
}
static inline gboolean
_gtk_css_matcher_has_region (const GtkCssMatcher *matcher,
const char *region,
GtkRegionFlags flags)
{
return matcher->klass->has_region (matcher, region, flags);
}
static inline guint
_gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b)
{
return matcher->klass->has_position (matcher, forward, a, b);
}
G_END_DECLS
#endif /* __GTK_CSS_MATCHER_PRIVATE_H__ */
+211
View File
@@ -0,0 +1,211 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkstylepropertyprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
GtkCssUnit unit;
double value;
};
static void
gtk_css_value_number_free (GtkCssValue *value)
{
g_slice_free (GtkCssValue, value);
}
static gboolean
gtk_css_value_number_equal (const GtkCssValue *number1,
const GtkCssValue *number2)
{
return number1->unit == number2->unit &&
number1->value == number2->value;
}
static GtkCssValue *
gtk_css_value_number_transition (GtkCssValue *start,
GtkCssValue *end,
double progress)
{
/* FIXME: This needs to be supported at least for percentages,
* but for that we kinda need to support calc(5px + 50%) */
if (start->unit != end->unit)
return NULL;
return _gtk_css_number_value_new (start->value + (end->value - start->value) * progress,
start->unit);
}
static void
gtk_css_value_number_print (const GtkCssValue *number,
GString *string)
{
char buf[G_ASCII_DTOSTR_BUF_SIZE];
const char *names[] = {
/* [GTK_CSS_NUMBER] = */ "",
/* [GTK_CSS_PERCENT] = */ "%",
/* [GTK_CSS_PX] = */ "px",
/* [GTK_CSS_PT] = */ "pt",
/* [GTK_CSS_EM] = */ "em",
/* [GTK_CSS_EX] = */ "ex",
/* [GTK_CSS_PC] = */ "pc",
/* [GTK_CSS_IN] = */ "in",
/* [GTK_CSS_CM] = */ "cm",
/* [GTK_CSS_MM] = */ "mm",
/* [GTK_CSS_RAD] = */ "rad",
/* [GTK_CSS_DEG] = */ "deg",
/* [GTK_CSS_GRAD] = */ "grad",
/* [GTK_CSS_TURN] = */ "turn",
/* [GTK_CSS_S] = */ "s",
/* [GTK_CSS_MS] = */ "ms",
};
g_ascii_dtostr (buf, sizeof (buf), number->value);
g_string_append (string, buf);
if (number->value != 0.0)
g_string_append (string, names[number->unit]);
}
static const GtkCssValueClass GTK_CSS_VALUE_NUMBER = {
gtk_css_value_number_free,
gtk_css_value_number_equal,
gtk_css_value_number_transition,
gtk_css_value_number_print
};
GtkCssValue *
_gtk_css_number_value_new (double value,
GtkCssUnit unit)
{
static GtkCssValue zero_singleton = { &GTK_CSS_VALUE_NUMBER, 1, GTK_CSS_NUMBER, 0 };
static GtkCssValue px_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 0 },
{ &GTK_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 1 },
{ &GTK_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 2 },
{ &GTK_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 3 },
{ &GTK_CSS_VALUE_NUMBER, 1, GTK_CSS_PX, 4 },
};
GtkCssValue *result;
if (unit == GTK_CSS_NUMBER && value == 0)
return _gtk_css_value_ref (&zero_singleton);
if (unit == GTK_CSS_PX &&
(value == 0 ||
value == 1 ||
value == 2 ||
value == 3 ||
value == 4))
{
return _gtk_css_value_ref (&px_singletons[(int) value]);
}
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_NUMBER);
result->unit = unit;
result->value = value;
return result;
}
GtkCssUnit
_gtk_css_number_value_get_unit (const GtkCssValue *value)
{
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_NUMBER, GTK_CSS_NUMBER);
return value->unit;
}
double
_gtk_css_number_value_get (const GtkCssValue *number,
double one_hundred_percent)
{
g_return_val_if_fail (number != NULL, 0.0);
g_return_val_if_fail (number->class == &GTK_CSS_VALUE_NUMBER, 0.0);
if (number->unit == GTK_CSS_PERCENT)
return number->value * one_hundred_percent / 100;
else
return number->value;
}
GtkCssValue *
_gtk_css_number_value_compute (GtkCssValue *number,
GtkStyleContext *context)
{
g_return_val_if_fail (number->class == &GTK_CSS_VALUE_NUMBER, NULL);
switch (number->unit)
{
default:
g_assert_not_reached();
/* fall through */
case GTK_CSS_PERCENT:
case GTK_CSS_NUMBER:
case GTK_CSS_PX:
case GTK_CSS_DEG:
case GTK_CSS_S:
return _gtk_css_value_ref (number);
case GTK_CSS_PT:
return _gtk_css_number_value_new (number->value * 96.0 / 72.0,
GTK_CSS_PX);
case GTK_CSS_PC:
return _gtk_css_number_value_new (number->value * 96.0 / 72.0 * 12.0,
GTK_CSS_PX);
break;
case GTK_CSS_IN:
return _gtk_css_number_value_new (number->value * 96.0,
GTK_CSS_PX);
break;
case GTK_CSS_CM:
return _gtk_css_number_value_new (number->value * 96.0 * 0.39370078740157477,
GTK_CSS_PX);
break;
case GTK_CSS_MM:
return _gtk_css_number_value_new (number->value * 96.0 * 0.039370078740157477,
GTK_CSS_PX);
break;
case GTK_CSS_EM:
return _gtk_css_number_value_new (number->value *
_gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
GTK_CSS_PX);
break;
case GTK_CSS_EX:
/* for now we pretend ex is half of em */
return _gtk_css_number_value_new (number->value * 0.5 *
_gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
GTK_CSS_PX);
case GTK_CSS_RAD:
return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),
GTK_CSS_DEG);
case GTK_CSS_GRAD:
return _gtk_css_number_value_new (number->value * 360.0 / 400.0,
GTK_CSS_DEG);
case GTK_CSS_TURN:
return _gtk_css_number_value_new (number->value * 360.0,
GTK_CSS_DEG);
case GTK_CSS_MS:
return _gtk_css_number_value_new (number->value / 1000.0,
GTK_CSS_S);
}
}

Some files were not shown because too many files have changed in this diff Show More