Compare commits

..

177 Commits

Author SHA1 Message Date
Juan Pablo Ugarte 1cffd1de56 Added parent property to external-object tag 2013-02-13 19:05:02 -03:00
Juan Pablo Ugarte 6b141bff77 Updated to new external-object/template syntaxt 2012-12-10 11:38:49 -03:00
Juan Pablo Ugarte 13870e733c Renamed <template> tag with <external-object> and keep <template> tag for new inline type definitions 2012-12-10 11:24:47 -03:00
Juan Pablo Ugarte e0ce659f34 Removed return value of gtk_builder_expose_object()
and added check to notify when the object exist
2012-12-10 11:24:47 -03:00
Juan Pablo Ugarte dc78589ce2 Added inline template creation support. Now builder creates new types dinamically when needed.
that is when it finds a template element without an asociated external object.
2012-12-10 11:24:47 -03:00
Juan Pablo Ugarte e6007f10ac Added template_id parameter to gtk_container_class_set_template_from_*() functions
This way you can call your template "this" or "that" or as you wish.
2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte 2b422848a3 Added return value to gtk_builder_expose_object() and made it ignore if the object id is in use. 2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte b39ae75a0e Merge external object namespace with builder built objects 2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte 828338fbf8 Added signal data test to test_expose_object() 2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte 329335132c Removed gtk_builder_add_to_parent_*() functions, instead you can use gtk_builder_expose_object()
to expose the template object and simply call gtk_builder_add_from_*()

Added test_expose_object() test case
2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte 7d53df8ccb Removed bogus lines changes like spaces and such. 2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte bfdf7571b1 Added gtk_builder_add_to_parent() test case. 2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte 976b14cb63 Added template_id parameter to gtk_builder_add_to_parent_*() functions
This makes it more consistent since now you have to name the template
and let you have more than one template in a file.
2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte af394406f7 gtk_container_class_set_template() Clear list of classes with templates since
this function in rare occacions can be called more than once. (Glade)
2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte a6685346f1 Revert "Implemented GtkDialog and GtkMessageDialog using new template API."
This reverts commit a095cc6ac56876a55614a5fbb57548fefcc66191.
2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte 0f257f1892 Added gtk_container_class_set_template_from_string() 2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte 04444664a4 Implemented GtkDialog and GtkMessageDialog using new template API. 2012-12-10 11:24:46 -03:00
Juan Pablo Ugarte a3b93112bb Composite Widgets using GtkBuilder scripts
Added new API to enable composite widget implementations using builder scripts
  gtk_container_class_set_template_from_resource()
  gtk_container_class_declare_internal_child()
  gtk_container_class_set_connect_func()
2012-12-10 11:24:46 -03:00
Tristan Van Berkom 4d2bf8ef4a Added gtk_builder_expose_object(), gtk_builder_add_to_parent_from_file() and gtk_builder_add_to_parent_from_string().
Adding the needed GtkBuilder framework for composite containers. First the
expose_object() api is based on the work Marco Diego Aurélio Mesquita did
in bug 447972 with some bugs fixed and things cleared up. Next the
gtk_builder_add_to_parent_from_[file/string]() variants are used to extend
containers inline by adding themselves and letting the builder add the
children defined in a template file.

Added semantics to build composite children automatically from an assigned template.

This patch adds gtk_container_class_set_template[_file](),
gtk_container_class_set_connect_func() and the GtkParamSpecComposite
type. Setting the class template will result in GtkContainer building
the instance's children from the template at construct time, composite
properties will be assigned to their composite children by matching
the property names with the child GtkBuildable ids. The exposed connect
function is there to allow language bindings to automatically assign
methods for the interface callbacks when they assign templates to classes.

Made GtkDialog and GtkMessageDialog composite widgets using gtk_container_class_set_template().

Enhanced documentation for gtk_container_class_set_template()

Fixing dialog separator property to be construct-only

Implemented gtk_container_buildable_get_internal_child() and removed GSEAL macros

Added missing parameter to _gtk_builder_parser_parse_buffer() calls

Fixed composite implementation

Added gtk_builder_add_to_parent_from_resource()
Used gtk_builder_add_to_parent_from_* as gtk_builder_add_from_* implementation.

Removed GtkParamSpecComposite
Added GtkContainerClassPrivate
Added gtk_container_class_declare_internal_child() funtion to make internal children declaration explicit
Added GtkContainerTemplateType type parameter to gtk_container_class_set_template()

Updated GtkDialog and GtkMessageDialog implementation to new GtkContainer template API

Reworked GtkDialog and GtkMessageDialog xml template into a GResource

Fixed property setting and signal connection for parent objects (ie: gtk_builder_add_to_parent_*())
Use intern strings for properties and signal names and a GType instead of a class name in GtkBuilder
Added new private function _gtk_builder_object_get_name()

Removed gtk_container_get_composite_child()
Get a reference to every internal object declared with gtk_container_class_declare_internal_child() which gets dropped on GtkContainer::destroy signal
Implemented "template" tag, this allow us to also build anarchist objects

Replaced GtkDialog and GtkMessageDialog template file extension with .ui

Implemented id tag for template and added cheack for id to be 'this'

Cleaned up template API, we only provided a function to set a resource as a template

Fixed identation
2012-12-10 11:24:46 -03:00
Alexander Larsson d8fae21b1c css: Avoid looking up the GtkCssStyleProperty class a lot
Instead of constantly looking up the class we just stash it away in
class_init.
2012-12-10 14:49:51 +01:00
Alexander Larsson a1ee2b7b82 css: Speed up name matching
We use the new g_type_get_type_registration_serial() so that we can
cache and properly invalidate the result of g_type_from_name().

This bumps the glib requirement to 2.35.3 to get the new function.

https://bugzilla.gnome.org/show_bug.cgi?id=689847
2012-12-10 12:57:10 +01:00
Alexander Larsson 089eafb468 css: Clean up tree_match implementations
A bunch of repeated code is broken out into the helper
gtk_css_selector_tree_match_previous().
2012-12-10 12:28:44 +01:00
Alexander Larsson eb4667b6e1 css: Do get_change directly on the tree without matching first
Rather than first collecting matches and then getting the change
for them we do the change collection directly on the tree. This
is about twice as fast.
2012-12-10 12:11:02 +01:00
Alexander Larsson 03c626bb15 css: Factor out some of the position matching code 2012-12-10 12:11:02 +01:00
Mario Sanchez Prada 57e1e0de94 Add missing NULL-check in GtkEntryAccessible
Only call to atk_object_set_name if gtk_entry_get_icon_name() is not NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=689923
2012-12-09 11:52:11 +01:00
Daniel Mustieles fb312af979 Updated Spanish translation 2012-12-08 19:50:40 +01:00
Colin Walters 549a0af12b Fix build by un-translating org.gtk.Settings.FileChooser
At the moment, gtk+ doesn't depend on intltool, which is the program
that knows how to translate schemas.  Attempting to translate them
causes a build failure, so for now, let's leave them in en_US.

https://bugzilla.gnome.org/show_bug.cgi?id=689584
2012-12-07 14:05:58 -05:00
Timothy Arceri f1532993eb Add summary and description to "show-hidden" key
https://bugzilla.gnome.org/show_bug.cgi?id=689584
2012-12-07 11:57:45 -06:00
Cosimo Cecchi 26ea8e710a scale: render scale mark lines with separator style class
So that the theme can distinguish them from the mark text.
2012-12-07 11:41:03 -05:00
Cosimo Cecchi b855e91f7a build: fix some GCC warnings 2012-12-07 11:35:06 -05:00
Michael Natterer 9d31a04d12 quartz: fix crash in the recent clipboard "fix", and really fix it
We must not release the GtkClipboardOwner in pasteboardChangedOwner
becaue we don't own a reference to ourselves (NSPasteboard does).
Instead, release the owner right after setting it, transferring
ownership to NSPasteboard

Also, fix repeated setting of the same owner by keeping the
owner around in GtkCLipboard, and re-use it if "user_data"
doesn't change. To avoid clipboard_unset()ting our own contents
in the process, add an ugly "setting_same_owner" boolean to
GtkClipboardOwner, set it during re-setting the same owner,
and avoid calling clipboard_unset() from pasteboardChangedOwner
if it's TRUE.
(cherry picked from commit 4a8df7a33c)
2012-12-07 12:30:15 +01:00
Jasper St. Pierre 34318b9163 gtkcssselector: Fix build
destroy vs. free strikes again
2012-12-06 17:48:15 -05:00
Jasper St. Pierre 736ccb6ce1 gtkcssselector: Don't leak the hash table
We should probably free the memory we allocate. Sounds like a winning
strategy.
2012-12-06 17:39:09 -05:00
Alexander Larsson 4ca293e006 treeview: Don't invalidate whole tree unless needed
We currently invalidate the whole tree every time the style state
changes in the tree view. The primary reason for this is to catch
default font changes as that may affect text cell renderers. But
cell renderers could *potentially* also read other style properties
(although that seems weird and unlikely).

We handle this by invalidating only when some state that affects sizes
is changed. This includes all the font properties.
2012-12-06 22:28:11 +01:00
Alexander Larsson fd964ca178 textview: Only clear the layout in style_update if the font actually changes 2012-12-06 21:16:19 +01:00
Alexander Larsson 6dfee46cdb css: Add _gtk_css_style_property_affects_font
This checks if a style_update affects the font.
2012-12-06 21:14:02 +01:00
Alexander Larsson e6de45964d entry: No need to reset layouts on style_updated
With pango handling changes to the PangoLayout there now is no
style changes that can affect the layout for the entry, so we don't
have to reset the layout whenever the style is updated.
2012-12-06 19:54:05 +01:00
Alexander Larsson bf35c2f044 GtkLabel: Rely on the new pango support for context change tracking
Now that Pango tracks changes to the context automatically there is
no need to do it manually in e.g. style-updated or direction-changed,
in fact the only case we have to care about is when we re-create
the PangoContext due to a screen change, so we only have to clear
the layouts in GtkLabel in screen-changed.

This means we're not clearing all the layouts whenever the state changes,
which happens to every widget when the window is unfocused, which helps
performance a lot.

https://bugzilla.gnome.org/show_bug.cgi?id=340066
2012-12-06 19:54:05 +01:00
Alexander Larsson 53e08b58aa Require new pango with automatic tracking of PangoContext changes
Pango 1.32.4 has a feature where any PangoLayout automatically handles
the case where a PangoContext is changed. We want to rely on this to
avoid having to clear layouts too often, so we make this a hard dep.
2012-12-06 19:54:05 +01:00
Benjamin Otte 9ae9649188 stylecontext: Deprecate gtk_style_context_get_font()
This is for a very simple reason: The getter is returning a const value
and the font isn't const anymore. So we need to store the font
description somewhere but we can't reuse it as it's changing all the
time (yay animations, yay inherited values). Sucks.

So keep the hack in here but deprecate the function.
2012-12-06 02:57:19 +01:00
Benjamin Otte 82a6106920 switch: Remove hack to change text size
The same effect can now be achieved via
  .switch { font-size: smaller; }
so there is no need to hardcode things.
2012-12-06 02:57:18 +01:00
Benjamin Otte 1b1f4da5c7 gtk: Query font size directly
... instead of calling gtk_style_context_get_font() and then
pango_font_description_get_size().
2012-12-06 02:57:18 +01:00
Benjamin Otte 055b5d83d5 gtk: Use gtk_style_context_get()
... instead of soon-to-be-deprecated gtk_style_context_get_font().
2012-12-06 02:57:18 +01:00
Benjamin Otte 7747910b9d gtk: Use context's font
Instead of using gtk_style_context_get_font() in
pango_context_get_metrics(), use pango_context_get_font_description().
The context contains the font description we are about to use after all.
2012-12-06 02:57:18 +01:00
Benjamin Otte a405c9917c tests: Don't call to-be-deprecated function 2012-12-06 02:57:18 +01:00
Benjamin Otte fbbb66ae7d aboutdialog: Add text tag to get small text
This is to get rid of gtk_widget_override_font() and
gtk_style_context_get_font().

FIXME: This should probably be done by the theme somehow?
2012-12-06 02:57:18 +01:00
Benjamin Otte 732e89e4f3 stylecontext: Always recompute font
This is necessary  because values in a GtkCssComputedValues can change
now. So if the font-size is inherited or animated, the cached value will
be outdated.

Fixes the fontchooser preview not updating.
2012-12-06 02:57:18 +01:00
Daniel Mustieles f79cd24937 Updated Spanish translation 2012-12-05 20:10:39 +01:00
Daniel Mustieles 6e2dec0344 Updated Spanish translation 2012-12-05 20:10:27 +01:00
Jasper St. Pierre 7ee5e7af70 treemodelfilter: Make the constructor binding friendly
This means reffing the root in the set property implementation,
rather than in the constructor. We don't need to unref the root
on set, as it's a CONSTRUCT_ONLY property.

https://bugzilla.gnome.org/show_bug.cgi?id=680065
2012-12-05 13:43:19 -05:00
Aleksander Morgado a61b359498 GdkBroadwayDisplay: include proper port number in error trace 2012-12-05 11:23:35 +01:00
Aleksander Morgado 4dabc8ba84 GdkBroadwayDisplay: initialize GError before using it 2012-12-05 11:23:28 +01:00
Alexander Larsson cd016ef8e3 Revert "Don't queue resize for hidden widgets without a size group"
This seems to break redraw of the middle pane in glade.

This reverts commit faaae520c9.
2012-12-04 21:30:04 +01:00
Alexander Larsson d3377e9d7a Don't unnecessarily queue resize in GtkWindow.style_updated
GtkWindow always queues a resize on style updates if there is
a grip, because it may have been the grip size style properties
that changed. However, even if it *were*, and it likely wasn't
that would not affect the windows size request, so no need
to queue a resize.
2012-12-04 21:24:24 +01:00
Alexander Larsson faaae520c9 Don't queue resize for hidden widgets without a size group
queue_resize basically tells the parent widget that it may need
to pick a different size/layout. However, for a hidden child widget
that should never be needed. It may be that the widget is in a
sizegroup that has ignore_hidden == FALSE though, so it may
affect the size group calculations.

However, if a widget is not visible and not in a size group then
its safe to avoid the resize, as the widget will be resized on
becoming visible anyway.

This avoids a lot of size allocation for hidden things like menus
and tooltips.
2012-12-04 20:16:44 +01:00
Alexander Larsson 47714f55ee css: Avoid queue_resize in _gtk_widget_style_context_invalidated
We've already emitted style_updated, and the handler for that queues
a resize if necessary.
2012-12-04 20:16:44 +01:00
Alexander Larsson c3e9112f7f css: Avoid allocations in gtk_css_value_array_compute
Almost all array computations lead to no changes (99% in nautilus)
so we avoid the upfront allocation and delay it until we know its
needed. This drops the allocate/free from the profile.
2012-12-04 20:16:44 +01:00
Alexander Larsson 7ec33e63c0 css: Start array allocation with a better size
All computed values will compute all normal properties at least, so
we might as well allocate these upfront, which leads to a lot less
reallocations.
2012-12-04 20:16:44 +01:00
Alexander Larsson afc1a143a4 css: Use internal return_if_fail in some commonly called code
These are internal apis, and any external issues should have been
caught by checks at public API points. We use the internal checks
here because these checks show up in a non-neglible way on profiles.
2012-12-04 20:16:44 +01:00
Alexander Larsson 5833b8495e Add internal versions of g_return_[val_]_if_fail
These are only enabled on debug=yes, so not by default
in released tarballs.
2012-12-04 20:16:44 +01:00
Rico Tzschichholz b4767ea9da po: Fix xgettext failing on unicode strings
It is needed to use -from-code=utf-8 to override the ASCII default

Caused by ceb866dfe6
2012-12-04 20:06:19 +01:00
Benjamin Otte 85d8f3c51e reftests: Fix wrong name in test
Typo in d8306aaeb3
2012-12-04 20:02:36 +01:00
Alexander Larsson c1e9d46c64 css: Return 0 as change for the GtkSettingsStyleProvider 2012-12-04 19:56:18 +01:00
Marek Kasik 6f69a0fef6 printing: Call mark_printer_active() with correct parameters
Revert the second part of the commit
6ad6f719c6. mark_printer_active()
was called without its second parameter in g_list_free_full().
2012-12-04 15:48:08 +01:00
Michael Natterer f08fc12741 Bug 626499 - GtkClipboard unnotified on change of OS X pasteboard owner
pasteboardChangedOwner is not called as reliably as we'd want to get it,
so keep track of [pasteboard changeCount] and drop clipboard ownership
when a change happened. Also better unset the clipboard content redundantly
in a few places rather than missing one, and reorder the code in
gtk_clipboard_set_contents() so that the new aggressive unsetting
won't unset the clipboard under our feet when we call
[pasteboard declareTypes].
(cherry picked from commit f2b74db5dc)
2012-12-04 14:42:08 +01:00
Pierre-Yves Luyten c74d79bb55 Ensure GtkColorButton has a dialog when adding a palette
https://bugzilla.gnome.org/show_bug.cgi?id=132333
2012-12-03 23:46:18 +01:00
Kalev Lember 907447c72d gtkroundedbox: Fix a compiler warning
Use the correct enum type.
2012-12-02 19:47:54 +01:00
Piotr Drąg 9bf091e2ac Updated POTFILES.skip 2012-12-01 21:22:00 +01:00
Benjamin Otte 1460487635 css: Fix order of enum
We switched around the order in gtkcssenumvalue.h, we need to switch
this order, too. Otherwise the parsing code will go bonkers.
2012-12-01 18:01:39 +01:00
Benjamin Otte d8306aaeb3 reftests: Add a test for the new font size names 2012-12-01 16:27:45 +01:00
Benjamin Otte 1688403ae6 cssvalue: Fix the scaling factors for 'smaller' and 'larger'
They were reversed. Looks like a bad case of copy/paste failure.
2012-12-01 16:27:45 +01:00
Benjamin Otte 5942099f00 cssvalue: Parse font sizes properly
As the last CSS property, font-size now is a proper number (when it's
not a keyword).
2012-12-01 16:27:45 +01:00
Benjamin Otte 891a4ab347 cssvalue: Change order of values
This is necessary so that the (rather stupid) parsing code doesn't parse
"small" and then is happy when it should instead parse "smaller".
2012-12-01 16:27:45 +01:00
Benjamin Otte a23bc88557 css: Fix dependencies for font lookup
'larger' and 'smaller' depend on the parent value. D'oh.
2012-12-01 16:27:28 +01:00
Kalev Lember 1a61e1ea23 gtkliststore: Add explicit braces to avoid dangling else
Otherwise the following else becomes attached to the wrong if.
2012-12-01 14:02:50 +01:00
Benjamin Otte 0d9d576172 css: Add more features to font-size code
We now support the keywords (like xx-small, medium, larger, smaller...)
and I've changed the default value to be "medium".

This required some shuffling of the "get default font size" code. But
all is well now.
2012-12-01 14:00:24 +01:00
Benjamin Otte 1dd3ee6b59 css: Move default font handling
The default font is no longer handled like a custom style sheet that
overrides everything, but as the initial value. This is the same
behavior as in web browsers.

And it allows the theme to actually use the 'font-family' and
'font-size' properties. Of course, a well behaved theme will respect the
setting as much as possible and for example use relative font sizes
(which aren't yet supported, but will be soon).
2012-12-01 01:49:06 +01:00
Benjamin Otte 3ff7f1fd43 style: Add _gtk_style_provider_private_get_settings()
This gives a GtkSettings object for resolving system-dependant things -
like the default font family and font size.
No code does this yet, but we have an API.

Only GtkSettings implements this.
2012-12-01 01:24:12 +01:00
Benjamin Otte 41f8ba3c35 settings: Implement StyleProvider interface without StyleProperties
I want to deprecate GtkStyleProperties.
2012-12-01 00:56:12 +01:00
Benjamin Otte fe61e6b3fe settings: Never override some font properties
According to the CSS specification, everything but font-size and
font-family are defined by CSS. So we don't override them anymore.
2012-12-01 00:18:01 +01:00
Benjamin Otte be53513954 API: Deprecate functions to register custom CSS properties
We should slowly transition code to using the GTK-provided CSS. So here
we go.
2012-11-30 22:45:20 +01:00
Benjamin Otte fc67f0d4f8 stylecontext: Remove unused private functions 2012-11-30 22:41:22 +01:00
Benjamin Otte 0c12a6ffcb cssstyleproperty: Don't mark border width properties as NO_RESIZE
I was to overeager when marking properties in
66d22f101d apparently.
2012-11-30 20:41:58 +01:00
Benjamin Otte 35362337ec widget: Optimize away unndeeded redraws
If only styles were updated that don't require resizes, don't queue one.
2012-11-30 20:40:18 +01:00
Benjamin Otte 8560ff88cd styleproperty: Add _gtk_css_style_property_changes_affect_size()
This gives fast access to the question of wether a style update requires
a resize.
2012-11-30 20:37:46 +01:00
Benjamin Otte e0586e3680 stylecontext: Expose a function to get at the current changes 2012-11-30 20:36:57 +01:00
Benjamin Otte 66d22f101d styleproperty: Mark properties as not needing resizes 2012-11-30 20:10:23 +01:00
Benjamin Otte a5770cef36 styleproperty: Add an affects-size property
This property will be used to avoid gtk_widget_queue_resize() calls in
favor of gtk_widget_queue_draw().
2012-11-30 20:10:23 +01:00
Benjamin Otte 4ccb8e5d33 stylecontext: Pass a bitmask to the changed values 2012-11-30 20:10:23 +01:00
Benjamin Otte cc0b493216 reftests: Fix a reftest
Recent Adwaita changes caused diffs. We don't want that, so we run this
test against the default settings.
2012-11-30 20:10:23 +01:00
Alexander Larsson 3c279b1492 icon cache: Fix double free
The symbolic icon cache code free crashed with a double free
due to a missing ->next in the loop.
2012-11-30 16:19:13 +01:00
Michael Natterer 9eea724e3b gtk: convert keyvals to unicode before committing to the imcontext
(cherry picked from commit 1eb0d98d73)
2012-11-30 15:10:51 +01:00
Michael Natterer f619f91a8f gtk: add more OSX special casing for the deadacute and deaddoubleacute keys
So " plus foo prduces foo-with-diaereses and ' plus c produces
c-with-cedilla.
(cherry picked from commit c0102b3089)
2012-11-30 15:09:46 +01:00
Alexander Larsson e36f80f0ef css: Make test pass
The new css tree may change the order of selectors (keeping the
same semantics). This affects how the selectors are printed later,
which causes some css parsing tests to not match the references.

Fortunately the order is consistent between runs given the same
css, so we just have to switch around the order in some of the
.ref.css files.
2012-11-30 14:53:30 +01:00
Alexander Larsson 3c421db473 css: Allocate the css tree in a single chunk
This gives us several advantages:

* Smaller struct on 64bit (32bit indexes vs 64bit pointers)
* Less overhead for allocation
* Less fragmentation
2012-11-30 14:53:30 +01:00
Alexander Larsson 2dbeabdc58 css: Fix leak of lists while building tree 2012-11-30 14:53:30 +01:00
Alexander Larsson 528e6032ae css: Add accessor functions for traversing css tree
This will let us later change how the tree is stored
2012-11-30 14:53:30 +01:00
Alexander Larsson 42716cb60f css: Add const to _gtk_css_selector_tree_match_all arg 2012-11-30 14:53:30 +01:00
Alexander Larsson d69c6fff7a css: Don't keep around linear selectors
Now we use the selector tree everywhere, so there is no need to
keep around the linear selectors unless we're using them to
verify the tree correctness, so free them.
2012-11-30 14:53:30 +01:00
Alexander Larsson c10a0962cf css: Remove gtk_css_ruleset_matches
This is only not needed anymore, and only the VERIFY_TREE code
should access ->selector.
2012-11-30 14:53:30 +01:00
Alexander Larsson fd4712590a css: Use tree for gtk_css_provider_get_style_property 2012-11-30 14:53:30 +01:00
Alexander Larsson 9b989a1427 css: Implement ruleset_get_change() with the tree
We traverse the tree on the matches instead of using
the linear selectors.
2012-11-30 14:53:30 +01:00
Alexander Larsson 146b6f3a93 css: Ensure the tree built is always the same
We add some "artificial" ordering to the otherwise unordered
tree nodes. This means the tree will be the same every time for the
same input. This is good because e.g. tree order affects the
reordering of the simple selectors, which may affect how
css providers are printed, which need to be consistent for
the css tests to work.
2012-11-30 14:53:30 +01:00
Alexander Larsson 3d5e8f98ec css: Use the tree to print css selectors 2012-11-30 14:53:30 +01:00
Alexander Larsson 6bec577771 css: Track the tree selector matches 2012-11-30 14:53:30 +01:00
Alexander Larsson f678827918 css: Fix type of GtkCssSelectorRuleSetInfo match
The old type was a leftover from a previous version.
2012-11-30 14:53:30 +01:00
Alexander Larsson 6b85db7555 css: Track parent in the css tree nodes
This way we can reconstruct matched css rules
2012-11-30 14:53:30 +01:00
Alexander Larsson 69feabd139 css: Better tree match verification 2012-11-30 14:53:30 +01:00
Alexander Larsson 0ede06d229 css: Fix up position with region tree matching
This was using the wrong result in case of a match (results from
the position, not the region. Also, the descendant checks were
wrong.
2012-11-30 14:53:30 +01:00
Alexander Larsson d6932dd823 css: Don't reorder some selectors when building selector tree
When building the tree we generally reorder the selectors inside
the same simple selector in order to pick a good first selector
to balance the tree better. However, some kinds of selectors
can't really be reordered, even thought they are simple.

This is since the matching code for some types handle
the existance of a directly preceeding selector differently:

 REGION and ANY selectors look for a DESCENDANT previous
 POSITION selector look for a REGION previous
2012-11-30 14:53:30 +01:00
Alexander Larsson 63cb467e06 css: Fixed typo in PRINT_TREE debug code 2012-11-30 14:53:30 +01:00
Alexander Larsson 1bfa6593c8 css: Create and use a tree for css selector matching 2012-11-30 14:53:30 +01:00
Alexander Larsson daefb12a23 css: Add GtkCssSelectorTree creation and matching
From a set of GtkCssSelectors and the rulesets they match to
we create a large decision tree that lets us efficitently match
against all the rules and return the set of matched rulesets.

The tree is created such that at each level we pick the initial rule[1]
in all the considered selectors for that level and use put the
one that is in most selectors in the node. All selectors matching that
are put in the previous part of the tree.
2012-11-30 14:53:29 +01:00
Alexander Larsson 16f2b20f96 css: Add _gtk_css_matcher_matches_any()
This returns true if the matcher matches *anything*. We need
to check this later, because such matchers are dangerous in loops
that iterate over all parents/siblings since such loops would not
terminate.
2012-11-30 14:53:29 +01:00
Alexander Larsson 3b4040d619 css: Track which selectors are "simple" 2012-11-30 14:53:29 +01:00
Alexander Larsson cfdc68db5c Reuse rendered symbolic icons
With the previous commit all loads of the same icon will share a single
GtkIconInfo, which typicallty means the pixbuf is shared via Info->pixbuf.

However, atm we don't share symbolic icons, which causes these to be re-read
and re-parsed every time. This is especially bad if the icon is used many times
in some form of list. So, we cache the pixbufs and reuse them.

https://bugzilla.gnome.org/show_bug.cgi?id=689081
2012-11-30 11:33:26 +01:00
Alexander Larsson 92e904a257 Cache GtkIconInfo
In order to avoid loading and keeping around the same icon multiple times
we keep a cache of all outstanding GtkIconInfo objects for a given theme.

Additionally we return to the app not the normal pixbuf from the info,
but rather a proxy copy of it sharing the same data, but no extra
reference. This allows us to track when the app is no longer using
the pixbuf, and we can thus ensure that the GtkIconInfo in the cache
stays around for at least as long as the pixbuf is alive.

When the app unrefs the pixbuf we put the Info on a short LRU list
to keep it alive a bit longer, in case the app needs it in a short
while.

https://bugzilla.gnome.org/show_bug.cgi?id=689081
2012-11-30 11:33:26 +01:00
Matthias Clasen e75860e466 Add a missing va_end call
va_copy must be matched with va_end.
2012-11-29 23:18:49 -05:00
Matthias Clasen 5b9c687595 Avoid unreachable code
Reestablish an else that went missing in commit 5ff328d2. Without
it, the return is reached unconditionally, and the code behind
it is dead.
2012-11-29 23:10:40 -05:00
Matthias Clasen b3b83545c4 Don't return prematurely
This code was clearly meant to return _after_ the loop.
Don't put the return inside the loop body, then.
2012-11-29 23:10:35 -05:00
Matthias Clasen c5c7323942 GtkAboutDialog: Initialize a variable
Coverity complains about it being uninitialized, otherwise.
2012-11-29 23:10:34 -05:00
Matthias Clasen 52af9aede6 GtkNotebook: Clarify a switch statement
We were intentionally falling through here, this commit
just adds comments to make that explicit.
2012-11-29 23:10:34 -05:00
Matthias Clasen 4557e4d7a5 GtkCellAccessible: Add missing break statements
This switch was entirely breakless. Amazing accessibility code,
found by Coverity.
2012-11-29 23:10:34 -05:00
Matthias Clasen 9ba32fec6e GtkExpander: Clarify a nested switch
This code confused Coverity into thinking we were falling through,
when we were not. Add a few explicit breaks to clear that up.
2012-11-29 23:10:34 -05:00
Matthias Clasen 6400eeba35 Add a forgotten break in render_border
The GTK_BORDER_STYLE_DOUBLE case was clearly not meant to
fall through to the subsequent cases, yet it did.
Found by Coverity.
2012-11-29 23:10:34 -05:00
Matthias Clasen a7ed598d37 GtkIconViewAccessible: Fix a copy-paste error
Don't access vadjustment after checking hadjustment for
not being NULL. Found by Coverity.
2012-11-29 23:10:34 -05:00
Matthias Clasen 3519226c5a GtkActionHelper: Fix a copy-paste error
The code clearly meant to reset action->active here.

This was found by Coverity.
2012-11-29 23:10:34 -05:00
Matthias Clasen bf26d46cb2 gtk_css_value_bg_size_equal: actually compare contain values
Due to a copy-paste error, the code failed to compare the
contain members of value1 and value2.

This was found by Coverity.
2012-11-29 23:10:34 -05:00
Matthias Clasen ce6f43a522 Don't check the same crossing mode twice
This was broken since commit b2aaa94 in 2008. Its commit message
clearly states that the intention was to check for GTK_GRAB,
GTK_UNGRAB and STATE_CHANGED. Lets do that, then.

This was found by Coverity.
2012-11-29 23:10:34 -05:00
Matthias Clasen 5230cfe805 GtkLabel: Fix a pointless expression
Clearly, what was meant here was that we create a new attribute
list if either of the input attribute lists are non-NULL.
This was found by Coverity.
2012-11-29 23:10:34 -05:00
Matthias Clasen 256f168525 Obtain the recent files max age setting from xsettings
This will help with implementing desktop-wide policy for
retaining of history.

https://bugzilla.gnome.org/show_bug.cgi?id=689047
2012-11-29 23:10:33 -05:00
Timothy Arceri 50acce4074 In the file chooser, use a proper apostrophe rather than a prime mark (tick mark)
https://bugzilla.gnome.org/show_bug.cgi?id=689012
2012-11-29 11:34:29 -06:00
Alan McGovern 149de71624 Fix broken function pointer declarations on windows
Both flashing a window and setting the window opacity were using
incorrect declarations for function pointers. They were missing the
WINAPI annotation as defined in windows.h. As a result, the stack
could be corrupted when these functions were invoked.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=689235
(cherry picked from commit 5637ef1f97)
2012-11-29 15:07:42 +01:00
Michael Natterer 709f12b9ac quartz: add mountain lion as version 8 to enum GdkOSXVersion
Also use GDK_OSX_UNSUPPORTED instead of 0 in gdk_quartz_osx_version().
(cherry picked from commit 9644e910a8)
2012-11-29 15:00:57 +01:00
Michael Natterer e2144fbb7e quartz: call Gestalt() only once per session in gdk_quartz_osx_version()
Thanks to Paul Davis for pointing this out.
(cherry picked from commit d6533ffc44)
2012-11-29 15:00:38 +01:00
Benjamin Berg fd301e7847 Use the ppd groups "name" instead of "text" (bug #687065)
This commit fixes a regression caused by a patch to remove Cups 1.2
ifdefs. This resulted in the "installable options" to appear in the
print dialog.
2012-11-29 10:02:08 +01:00
Benjamin Otte 4d0ca91c72 menuitem: Remove unused variables 2012-11-28 21:15:05 +01:00
Benjamin Otte 29c8420746 tests: Add CSS test for comment detection
Tests recent fix.
2012-11-28 21:11:48 +01:00
Marcus Kraßmann 7f3595a6be cssparser: Don't detect /*/ as a comment 2012-11-28 21:11:48 +01:00
Cosimo Cecchi ea415cd350 menubar: deprecate internal-padding style property
https://bugzilla.gnome.org/show_bug.cgi?id=689168
2012-11-28 10:09:16 -05:00
Cosimo Cecchi 1a79ee4d3e menubar: add support for CSS padding
In preparation for the removal of the internal-padding style property.

https://bugzilla.gnome.org/show_bug.cgi?id=689168
2012-11-28 10:09:16 -05:00
Cosimo Cecchi 01dc23cdec menu: deprecate horizontal-padding and vertical-padding
https://bugzilla.gnome.org/show_bug.cgi?id=689168
2012-11-28 10:09:16 -05:00
Cosimo Cecchi a69619edbc menuitem: deprecate horizontal-padding style property
https://bugzilla.gnome.org/show_bug.cgi?id=689168
2012-11-28 10:09:16 -05:00
Nilamdyuti Goswami d3051ca79c Assamese translation updated 2012-11-28 13:49:44 +05:30
Nilamdyuti Goswami 9ac005abee Assamese translation updated 2012-11-28 13:47:38 +05:30
Matej Urbančič 943de24211 Updated Slovenian translation 2012-11-26 21:12:00 +01:00
Matej Urbančič db6d6fcc84 Updated Slovenian translation 2012-11-26 21:07:25 +01:00
David King 941851fc86 docs: Add gtk-doc comment for GtkTreeRowReference
https://bugzilla.gnome.org/show_bug.cgi?id=93381
2012-11-26 14:12:14 +00:00
Christophe Fergeau e8659679cd Sanitize memory handling in cups_request_printer_list_cb
gtk+ was trying to display already freed strings, leaking memory,
...I noticed this because I was getting weird blinking characters
as the status of my cups printers, and valgrind confirmed something
was wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=683072
2012-11-26 10:19:31 +01:00
Philip Withnall 693581250e i18n: Update British English translation 2012-11-26 09:00:59 +00:00
Philip Withnall ceb866dfe6 Bug 595615 — Use proper ellipses
Use ‘…’ instead of ‘...’ in translatable strings.

Closes: https://bugzilla.gnome.org/show_bug.cgi?id=595615
2012-11-26 08:59:27 +00:00
Piotr Drąg 788f1a0934 Updated POTFILES.skip 2012-11-26 00:46:05 +01:00
Benjamin Otte 6b33ee9c53 reftests: Add reftest for broken fixed height mode
https://bugzilla.gnome.org/show_bug.cgi?id=687816
2012-11-26 00:09:35 +01:00
Benjamin Otte 239c631ad3 treeview: Delay computing fixed height
In the setter, we only set fixed height mode and queue a revalidation of
the row heights.

https://bugzilla.gnome.org/show_bug.cgi?id=687816
2012-11-26 00:09:35 +01:00
Emmanuele Bassi 4498ff314e sizegroup: Use g_hash_table_add()
This is the function to use when treating hash tables as a set.
2012-11-25 22:58:19 +01:00
Benjamin Otte 87b351e6e6 styleproperty: Use _gtk_css_initial_value_get()
See previous commit(s).
2012-11-25 22:29:14 +01:00
Benjamin Otte 1d805139db cssvalue: Use _gtk_css_initial_value_get() for the inherit value
See previous commit(s).
2012-11-25 22:29:14 +01:00
Benjamin Otte f204473ee0 cssvalue: Add _gtk_css_initial_value_get()
... so we don't bump a refcount whenever we get the initial singleton.

We want to use this function instead of
_gtk_css_style_property_get_initial_value() everywhere where we compute
values, because some initial values may depend on settings soon.
2012-11-25 15:31:59 +01:00
Benjamin Otte 2ab65ef771 izegroup: Improve performance
Keep a list of all groups and avoid groups we already handled. Speeds up
GtkToolpalette a lot.
2012-11-25 13:32:21 +01:00
Benjamin Otte da7a4089fe widget: Remove an unneeded queue_resize()
Resizes are queued via
   gtk_widget_propagate_state()
=> gtk_style_context_set_state()
=> gtk_style_context_queue_invalidate()
=> gtk_style_context_validate()
=> _gtk_widget_style_context_invalidated()
so there's no need to queue an extra one.
2012-11-25 04:46:36 +01:00
Benjamin Otte 41486895d5 deprecations: Move files into deprecated/ dir 2012-11-25 04:16:43 +01:00
Benjamin Otte 0862afaded gtkgradient: Deprecate 2012-11-25 03:47:51 +01:00
Benjamin Otte fb643c1c12 symboliccolor: Deprecate
Symbolic colors are an implementation detail of the CSS engine and have
been superceded by GtkCssColorValue. We don't want them clobbering the
public API. In particular because the only use I could find in the
public API is people using it to shade colors.
2012-11-25 03:43:28 +01:00
Benjamin Otte df25349d63 themingengine: Do shading with GtkHSLA
... instead of with symbolic colors.
2012-11-25 03:34:02 +01:00
Benjamin Otte 9aac4dffc5 hsla: Add _gtk_hsla_shade()
We use it in multiple places, so better split it out.
2012-11-25 03:25:15 +01:00
Benjamin Otte 4f9a8e6b3d symboliccolor: Remove extra includes
That header was included in way too many places.
2012-11-25 02:59:15 +01:00
Benjamin Otte 42dc0ea0fd styleprovider: Change function prototype
Make _gtk_style_provider_private_get_color() return a GtkCssValue (a
GtkCssColorValue to be exact) instead of GtkSymbolicColor.

With this, the symbolic color usage inside GTK is minimized.
2012-11-25 02:45:10 +01:00
Benjamin Otte 08ac1504d2 symboliccolor: Implement using GtkCssValue 2012-11-25 02:41:17 +01:00
Benjamin Otte b8e58015eb symboliccolor: symbolic color is no longer a CssValue
This is not needed anymore, because we have GtkCssColorValue for that
now.
2012-11-25 01:51:18 +01:00
Benjamin Otte 94b80cc774 symboliccolor: Change prototype of function
Makes it easier to use the function in the places where it's still used.
2012-11-24 21:56:47 +01:00
Benjamin Otte 5ca35bd5dd settings: Remove support for color schemes
Color schemes were unused and their interaction with CSS3 themes was
undefined. So we decided to remove support for them.

This commit does that.
2012-11-24 21:27:33 +01:00
Benjamin Otte 932794e105 styleprovider: Remove (broken) implementations of get_style
The implementations were broken and get_style() is deprecated and
documented to return NULL now.
2012-11-24 21:12:00 +01:00
Benjamin Otte 324ff12553 stylecascade: Remove get_icon_factory() implementation
It was redundant.
2012-11-24 21:12:00 +01:00
Benjamin Otte 45b4fb02b1 styleprovider: Deprecate two non-working functions
Both of them weren't used inside GTK. And apparently they weren't used
outside of GTK either, as alex recently mentioned them being severly
broken.
2012-11-24 21:12:00 +01:00
David King fbdb81bbdf docs: gtk_file_chooser_get_filename() returns absolute paths
The documentation for gtk_file_chooser_get_filenames() states that the
returned filenames are absolute paths, and uses g_file_get_path() to
construct the filename. The same function is used to construct the
filename in gtk_file_chooser_get_filename(), so it should also return
absolute paths.

https://bugzilla.gnome.org/show_bug.cgi?id=371034
2012-11-24 19:58:10 +00:00
Nilamdyuti Goswami 840f09bdc8 Assamese translation updated 2012-11-23 20:18:36 +05:30
Nilamdyuti Goswami b05ee6aa29 Assamese translation updated 2012-11-23 20:17:24 +05:30
200 changed files with 9130 additions and 6549 deletions
+2 -2
View File
@@ -39,8 +39,8 @@ 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.35.0])
m4_define([pango_required_version], [1.30.0])
m4_define([glib_required_version], [2.35.3])
m4_define([pango_required_version], [1.32.4])
m4_define([atk_required_version], [2.5.3])
m4_define([cairo_required_version], [1.10.0])
m4_define([gdk_pixbuf_required_version], [2.26.0])
+1
View File
@@ -536,6 +536,7 @@ gtk_builder_add_objects_from_string
gtk_builder_add_objects_from_resource
gtk_builder_get_object
gtk_builder_get_objects
gtk_builder_expose_object
gtk_builder_connect_signals
gtk_builder_connect_signals_full
gtk_builder_set_translation_domain
+2 -2
View File
@@ -1060,7 +1060,7 @@ _gdk_broadway_display_open (const gchar *display_name)
{
GdkDisplay *display;
GdkBroadwayDisplay *broadway_display;
GError *error;
GError *error = NULL;
int port;
display = g_object_new (GDK_TYPE_BROADWAY_DISPLAY, NULL);
@@ -1104,7 +1104,7 @@ _gdk_broadway_display_open (const gchar *display_name)
G_OBJECT (display),
&error))
{
g_printerr ("Unable to listen to port %d: %s\n", 8080, error->message);
g_printerr ("Unable to listen to port %d: %s\n", port, error->message);
g_error_free (error);
return NULL;
}
+8 -3
View File
@@ -28,9 +28,14 @@ GdkWindow *_gdk_root = NULL;
GdkOSXVersion
gdk_quartz_osx_version (void)
{
gint minor;
OSErr err = Gestalt (gestaltSystemVersionMinor, &minor);
g_return_val_if_fail (err == noErr, GDK_OSX_UNSUPPORTED);
static gint32 minor = GDK_OSX_UNSUPPORTED;
if (minor == GDK_OSX_UNSUPPORTED)
{
OSErr err = Gestalt (gestaltSystemVersionMinor, (SInt32*)&minor);
g_return_val_if_fail (err == noErr, GDK_OSX_UNSUPPORTED);
}
if (minor < GDK_OSX_MIN)
return GDK_OSX_UNSUPPORTED;
+2 -1
View File
@@ -48,7 +48,8 @@ typedef enum
GDK_OSX_LEOPARD = 5,
GDK_OSX_SNOW_LEOPARD = 6,
GDK_OSX_LION = 7,
GDK_OSX_CURRENT = 7,
GDK_OSX_MOUNTAIN_LION = 8,
GDK_OSX_CURRENT = 8,
GDK_OSX_NEW = 99
} GdkOSXVersion;
+3 -2
View File
@@ -27,6 +27,7 @@
#include "config.h"
#include <stdlib.h>
#include <windows.h>
#include "gdk.h"
#include "gdkwindowimpl.h"
@@ -1533,7 +1534,7 @@ gdk_win32_window_set_urgency_hint (GdkWindow *window,
gboolean urgent)
{
FLASHWINFO flashwinfo;
typedef BOOL (*PFN_FlashWindowEx) (FLASHWINFO*);
typedef BOOL (WINAPI *PFN_FlashWindowEx) (FLASHWINFO*);
PFN_FlashWindowEx flashWindowEx = NULL;
g_return_if_fail (GDK_IS_WINDOW (window));
@@ -3264,7 +3265,7 @@ gdk_win32_window_set_opacity (GdkWindow *window,
gdouble opacity)
{
LONG exstyle;
typedef BOOL (*PFN_SetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
typedef BOOL (WINAPI *PFN_SetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
PFN_SetLayeredWindowAttributes setLayeredWindowAttributes = NULL;
g_return_if_fail (GDK_IS_WINDOW (window));
+4 -2
View File
@@ -82,7 +82,8 @@ static const char gdk_settings_names[] =
"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/EnablePrimaryPaste\0" "gtk-enable-primary-paste\0";
"Gtk/EnablePrimaryPaste\0" "gtk-enable-primary-paste\0"
"Gtk/RecentFilesMaxAge\0" "gtk-recent-files-max-age\0";
@@ -140,5 +141,6 @@ static const struct
{ 1767, 1784 },
{ 1802, 1824 },
{ 1849, 1871 },
{ 1895, 1918 }
{ 1895, 1918 },
{ 1943, 1965 }
};
+12 -8
View File
@@ -148,6 +148,7 @@ deprecated_h_sources = \
deprecated/gtkcolorsel.h \
deprecated/gtkcolorseldialog.h \
deprecated/gtkfontsel.h \
deprecated/gtkgradient.h \
deprecated/gtkhandlebox.h \
deprecated/gtkhbbox.h \
deprecated/gtkhbox.h \
@@ -156,8 +157,9 @@ deprecated_h_sources = \
deprecated/gtkhscrollbar.h \
deprecated/gtkhseparator.h \
deprecated/gtkhsv.h \
deprecated/gtkstyle.h \
deprecated/gtkrc.h \
deprecated/gtkstyle.h \
deprecated/gtksymboliccolor.h \
deprecated/gtktable.h \
deprecated/gtktearoffmenuitem.h \
deprecated/gtkvbbox.h \
@@ -167,6 +169,10 @@ deprecated_h_sources = \
deprecated/gtkvseparator.h \
deprecated/gtkvpaned.h
deprecated_private_h_sources = \
deprecated/gtkgradientprivate.h \
deprecated/gtksymboliccolorprivate.h
gtk_public_h_sources = \
gtk.h \
gtkx.h \
@@ -249,7 +255,6 @@ gtk_public_h_sources = \
gtkfontchooserdialog.h \
gtkfontchooserwidget.h \
gtkframe.h \
gtkgradient.h \
gtkgrid.h \
gtkiconfactory.h \
gtkicontheme.h \
@@ -330,7 +335,6 @@ gtk_public_h_sources = \
gtkstyleproperties.h \
gtkstyleprovider.h \
gtkswitch.h \
gtksymboliccolor.h \
gtktestutils.h \
gtktextattributes.h \
gtktextbuffer.h \
@@ -478,7 +482,6 @@ gtk_private_h_sources = \
gtkfilesystemmodel.h \
gtkfontchooserprivate.h \
gtkfontchooserutils.h \
gtkgradientprivate.h \
gtkhslaprivate.h \
gtkiconcache.h \
gtkiconhelperprivate.h \
@@ -527,7 +530,6 @@ gtk_private_h_sources = \
gtkstylepropertiesprivate.h \
gtkstylepropertyprivate.h \
gtkstyleproviderprivate.h \
gtksymboliccolorprivate.h \
gtktextbtree.h \
gtktextbufferserialize.h \
gtktextchildprivate.h \
@@ -556,6 +558,7 @@ deprecated_c_sources = \
deprecated/gtkcolorsel.c \
deprecated/gtkcolorseldialog.c \
deprecated/gtkfontsel.c \
deprecated/gtkgradient.c \
deprecated/gtkhandlebox.c \
deprecated/gtkhbbox.c \
deprecated/gtkhbox.c \
@@ -566,6 +569,7 @@ deprecated_c_sources = \
deprecated/gtkhsv.c \
deprecated/gtkrc.c \
deprecated/gtkstyle.c \
deprecated/gtksymboliccolor.c \
deprecated/gtktable.c \
deprecated/gtktearoffmenuitem.c \
deprecated/gtkvbbox.c \
@@ -721,7 +725,6 @@ gtk_base_c_sources = \
gtkfontchooserutils.c \
gtkfontchooserwidget.c \
gtkframe.c \
gtkgradient.c \
gtkgrid.c \
gtkhsla.c \
gtkiconcache.c \
@@ -824,7 +827,6 @@ gtk_base_c_sources = \
gtkstyleprovider.c \
gtkstyleproviderprivate.c \
gtkswitch.c \
gtksymboliccolor.c \
gtktestutils.c \
gtktextattributes.c \
gtktextbtree.c \
@@ -973,6 +975,7 @@ gtk_private_h_sources += $(gtk_use_quartz_private_h_sources)
endif
gtk_all_private_h_sources = \
$(deprecated_private_h_sources) \
$(gtk_private_h_sources) \
$(gtk_use_x11_private_h_sources) \
$(gtk_use_win32_private_h_sources) \
@@ -1127,7 +1130,8 @@ gtktypebuiltins.c: @REBUILD@ $(gtk_public_h_sources) $(deprecated_h_sources) gtk
gtkresources.h: gtk.gresource.xml
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/gtk.gresource.xml \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-header --manual-register
gtkresources.c: gtk.gresource.xml gtk-default.css gtk-win32.css gtk-win32-xp.css gtk-win32-base.css gtk-win32-classic.css $(DND_CURSORS)
gtkresources.c: gtk.gresource.xml \
$(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies gtk.gresource.xml)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/gtk.gresource.xml \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-source --manual-register
+3
View File
@@ -287,10 +287,13 @@ gtk_cell_accessible_action_do_action (AtkAction *action,
{
case 0:
_gtk_cell_accessible_parent_expand_collapse (parent, cell);
break;
case 1:
_gtk_cell_accessible_parent_edit (parent, cell);
break;
case 2:
_gtk_cell_accessible_parent_activate (parent, cell);
break;
default:
return FALSE;
}
+4 -2
View File
@@ -549,7 +549,8 @@ gtk_entry_accessible_notify_gtk (GObject *obj,
const gchar *name;
name = gtk_entry_get_icon_name (gtk_entry,
GTK_ENTRY_ICON_PRIMARY);
atk_object_set_name (priv->icons[GTK_ENTRY_ICON_PRIMARY], name);
if (name)
atk_object_set_name (priv->icons[GTK_ENTRY_ICON_PRIMARY], name);
}
}
else if (g_strcmp0 (pspec->name, "secondary-icon-name") == 0)
@@ -559,7 +560,8 @@ gtk_entry_accessible_notify_gtk (GObject *obj,
const gchar *name;
name = gtk_entry_get_icon_name (gtk_entry,
GTK_ENTRY_ICON_SECONDARY);
atk_object_set_name (priv->icons[GTK_ENTRY_ICON_SECONDARY], name);
if (name)
atk_object_set_name (priv->icons[GTK_ENTRY_ICON_SECONDARY], name);
}
}
else if (g_strcmp0 (pspec->name, "primary-icon-tooltip-text") == 0)
+1 -1
View File
@@ -708,7 +708,7 @@ gtk_icon_view_item_accessible_is_showing (GtkIconViewItemAccessible *item)
if (icon_view->priv->hadjustment)
visible_rect.x += gtk_adjustment_get_value (icon_view->priv->hadjustment);
visible_rect.y = 0;
if (icon_view->priv->hadjustment)
if (icon_view->priv->vadjustment)
visible_rect.y += gtk_adjustment_get_value (icon_view->priv->vadjustment);
visible_rect.width = allocation.width;
visible_rect.height = allocation.height;
+1
View File
@@ -499,6 +499,7 @@ gtk_widget_accessible_notify_gtk (GObject *obj,
gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (atk_obj),
widget);
}
else
return;
atk_object_notify_state_change (atk_obj, state, value);
@@ -17,8 +17,11 @@
#include "config.h"
#define GDK_DISABLE_DEPRECATION_WARNINGS
#include "gtkgradientprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkstyleproperties.h"
@@ -40,6 +43,11 @@
* It is not normally necessary to deal directly with #GtkGradients,
* since they are mostly used behind the scenes by #GtkStyleContext and
* #GtkCssProvider.
*
* #GtkGradient is deprecated. It was used internally by GTK's CSS engine
* to represent gradients. As its handling is not conforming to modern
* web standards, it is not used anymore. If you want to use gradients in
* your own code, please use Cairo directly.
*/
G_DEFINE_BOXED_TYPE (GtkGradient, gtk_gradient,
@@ -80,6 +88,8 @@ struct _GtkGradient
* Returns: A newly created #GtkGradient
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkGradient is deprecated.
**/
GtkGradient *
gtk_gradient_new_linear (gdouble x0,
@@ -120,6 +130,8 @@ gtk_gradient_new_linear (gdouble x0,
* Returns: A newly created #GtkGradient
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkGradient is deprecated.
**/
GtkGradient *
gtk_gradient_new_radial (gdouble x0,
@@ -155,6 +167,8 @@ gtk_gradient_new_radial (gdouble x0,
* Adds a stop color to @gradient.
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkGradient is deprecated.
**/
void
gtk_gradient_add_color_stop (GtkGradient *gradient,
@@ -180,6 +194,8 @@ gtk_gradient_add_color_stop (GtkGradient *gradient,
* Returns: The same @gradient
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkGradient is deprecated.
**/
GtkGradient *
gtk_gradient_ref (GtkGradient *gradient)
@@ -199,6 +215,8 @@ gtk_gradient_ref (GtkGradient *gradient)
* if the reference count reaches 0.
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkGradient is deprecated.
**/
void
gtk_gradient_unref (GtkGradient *gradient)
@@ -239,6 +257,8 @@ gtk_gradient_unref (GtkGradient *gradient)
* Returns: %TRUE if the gradient has been resolved
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkGradient is deprecated.
**/
gboolean
gtk_gradient_resolve (GtkGradient *gradient,
@@ -318,11 +338,11 @@ _gtk_gradient_resolve_full (GtkGradient *gradient,
stop = &g_array_index (gradient->stops, ColorStop, i);
/* if color resolving fails, assume transparency */
val = _gtk_symbolic_color_resolve_full (stop->color,
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
&stop_deps);
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (stop->color),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
&stop_deps);
if (val)
{
rgba = *_gtk_css_rgba_value_get_rgba (val);
@@ -372,6 +392,8 @@ append_number (GString *str,
* for using in GTK CSS files.
*
* Returns: A string representation for @gradient
*
* Deprecated: 3.8: #GtkGradient is deprecated.
**/
char *
gtk_gradient_to_string (GtkGradient *gradient)
@@ -518,11 +540,9 @@ _gtk_gradient_transition (GtkGradient *start,
end_stop = &g_array_index (end->stops, ColorStop, i);
offset = (1 - progress) * start_stop->offset + progress * end_stop->offset;
color = (GtkSymbolicColor *) _gtk_css_value_transition ((GtkCssValue *) start_stop->color,
(GtkCssValue *) end_stop->color,
property_id,
progress);
g_assert (color);
color = gtk_symbolic_color_new_mix (start_stop->color,
end_stop->color,
progress);
gtk_gradient_add_color_stop (gradient, offset, color);
gtk_symbolic_color_unref (color);
}
@@ -25,7 +25,7 @@
#include <gdk/gdk.h>
#include <gtk/gtkstylecontext.h>
#include <gtk/gtkstyleproperties.h>
#include <gtk/gtksymboliccolor.h>
#include <gtk/deprecated/gtksymboliccolor.h>
G_BEGIN_DECLS
@@ -33,10 +33,12 @@ G_BEGIN_DECLS
GType gtk_gradient_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_8
GtkGradient * gtk_gradient_new_linear (gdouble x0,
gdouble y0,
gdouble x1,
gdouble y1);
GDK_DEPRECATED_IN_3_8
GtkGradient * gtk_gradient_new_radial (gdouble x0,
gdouble y0,
gdouble radius0,
@@ -44,21 +46,27 @@ GtkGradient * gtk_gradient_new_radial (gdouble x0,
gdouble y1,
gdouble radius1);
GDK_DEPRECATED_IN_3_8
void gtk_gradient_add_color_stop (GtkGradient *gradient,
gdouble offset,
GtkSymbolicColor *color);
GDK_DEPRECATED_IN_3_8
GtkGradient * gtk_gradient_ref (GtkGradient *gradient);
GDK_DEPRECATED_IN_3_8
void gtk_gradient_unref (GtkGradient *gradient);
GDK_DEPRECATED_IN_3_8
gboolean gtk_gradient_resolve (GtkGradient *gradient,
GtkStyleProperties *props,
cairo_pattern_t **resolved_gradient);
GDK_DEPRECATED_IN_3_8
cairo_pattern_t *
gtk_gradient_resolve_for_context
(GtkGradient *gradient,
GtkStyleContext *context);
GDK_DEPRECATED_IN_3_8
char * gtk_gradient_to_string (GtkGradient *gradient);
G_END_DECLS
+359
View File
@@ -0,0 +1,359 @@
/* 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"
#define GDK_DISABLE_DEPRECATION_WARNINGS
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkhslaprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtksymboliccolorprivate.h"
#include "gtkstyleproperties.h"
#include "gtkintl.h"
#include "gtkwin32themeprivate.h"
/**
* SECTION:gtksymboliccolor
* @Short_description: Symbolic colors
* @Title: GtkSymbolicColor
*
* GtkSymbolicColor is a boxed type that represents a symbolic color.
* It is the result of parsing a
* <link linkend="gtkcssprovider-symbolic-colors">color expression</link>.
* To obtain the color represented by a GtkSymbolicColor, it has to
* be resolved with gtk_symbolic_color_resolve(), which replaces all
* symbolic color references by the colors they refer to (in a given
* context) and evaluates mix, shade and other expressions, resulting
* in a #GdkRGBA value.
*
* It is not normally necessary to deal directly with #GtkSymbolicColors,
* since they are mostly used behind the scenes by #GtkStyleContext and
* #GtkCssProvider.
*
* #GtkSymbolicColor is deprecated. Symbolic colors are considered an
* implementation detail of GTK+.
*/
G_DEFINE_BOXED_TYPE (GtkSymbolicColor, gtk_symbolic_color,
gtk_symbolic_color_ref, gtk_symbolic_color_unref)
struct _GtkSymbolicColor
{
GtkCssValue *value;
gint ref_count;
};
static GtkSymbolicColor *
gtk_symbolic_color_new (GtkCssValue *value)
{
GtkSymbolicColor *symbolic;
symbolic = g_slice_new0 (GtkSymbolicColor);
symbolic->value = value;
symbolic->ref_count = 1;
return symbolic;
}
/**
* gtk_symbolic_color_new_literal:
* @color: a #GdkRGBA
*
* Creates a symbolic color pointing to a literal color.
*
* Returns: a newly created #GtkSymbolicColor
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
GtkSymbolicColor *
gtk_symbolic_color_new_literal (const GdkRGBA *color)
{
g_return_val_if_fail (color != NULL, NULL);
return gtk_symbolic_color_new (_gtk_css_color_value_new_literal (color));
}
/**
* gtk_symbolic_color_new_name:
* @name: color name
*
* Creates a symbolic color pointing to an unresolved named
* color. See gtk_style_context_lookup_color() and
* gtk_style_properties_lookup_color().
*
* Returns: a newly created #GtkSymbolicColor
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
GtkSymbolicColor *
gtk_symbolic_color_new_name (const gchar *name)
{
g_return_val_if_fail (name != NULL, NULL);
return gtk_symbolic_color_new (_gtk_css_color_value_new_name (name));
}
/**
* gtk_symbolic_color_new_shade: (constructor)
* @color: another #GtkSymbolicColor
* @factor: shading factor to apply to @color
*
* Creates a symbolic color defined as a shade of
* another color. A factor > 1.0 would resolve to
* a brighter color, while < 1.0 would resolve to
* a darker color.
*
* Returns: A newly created #GtkSymbolicColor
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
GtkSymbolicColor *
gtk_symbolic_color_new_shade (GtkSymbolicColor *color,
gdouble factor)
{
g_return_val_if_fail (color != NULL, NULL);
return gtk_symbolic_color_new (_gtk_css_color_value_new_shade (color->value,
factor));
}
/**
* gtk_symbolic_color_new_alpha: (constructor)
* @color: another #GtkSymbolicColor
* @factor: factor to apply to @color alpha
*
* Creates a symbolic color by modifying the relative alpha
* value of @color. A factor < 1.0 would resolve to a more
* transparent color, while > 1.0 would resolve to a more
* opaque color.
*
* Returns: A newly created #GtkSymbolicColor
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
GtkSymbolicColor *
gtk_symbolic_color_new_alpha (GtkSymbolicColor *color,
gdouble factor)
{
g_return_val_if_fail (color != NULL, NULL);
return gtk_symbolic_color_new (_gtk_css_color_value_new_alpha (color->value,
factor));
}
/**
* gtk_symbolic_color_new_mix: (constructor)
* @color1: color to mix
* @color2: another color to mix
* @factor: mix factor
*
* Creates a symbolic color defined as a mix of another
* two colors. a mix factor of 0 would resolve to @color1,
* while a factor of 1 would resolve to @color2.
*
* Returns: A newly created #GtkSymbolicColor
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
GtkSymbolicColor *
gtk_symbolic_color_new_mix (GtkSymbolicColor *color1,
GtkSymbolicColor *color2,
gdouble factor)
{
g_return_val_if_fail (color1 != NULL, NULL);
g_return_val_if_fail (color1 != NULL, NULL);
return gtk_symbolic_color_new (_gtk_css_color_value_new_mix (color1->value,
color2->value,
factor));
}
/**
* gtk_symbolic_color_new_win32: (constructor)
* @theme_class: The theme class to pull color from
* @id: The color id
*
* Creates a symbolic color based on the current win32
* theme.
*
* Note that while this call is available on all platforms
* the actual value returned is not reliable on non-win32
* platforms.
*
* Returns: A newly created #GtkSymbolicColor
*
* Since: 3.4
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
*/
GtkSymbolicColor *
gtk_symbolic_color_new_win32 (const gchar *theme_class,
gint id)
{
g_return_val_if_fail (theme_class != NULL, NULL);
return gtk_symbolic_color_new (_gtk_css_color_value_new_win32 (theme_class, id));
}
/**
* gtk_symbolic_color_ref:
* @color: a #GtkSymbolicColor
*
* Increases the reference count of @color
*
* Returns: the same @color
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
GtkSymbolicColor *
gtk_symbolic_color_ref (GtkSymbolicColor *color)
{
g_return_val_if_fail (color != NULL, NULL);
color->ref_count++;
return color;
}
/**
* gtk_symbolic_color_unref:
* @color: a #GtkSymbolicColor
*
* Decreases the reference count of @color, freeing its memory if the
* reference count reaches 0.
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
void
gtk_symbolic_color_unref (GtkSymbolicColor *color)
{
g_return_if_fail (color != NULL);
if (--color->ref_count)
return;
_gtk_css_value_unref (color->value);
g_slice_free (GtkSymbolicColor, color);
}
/**
* gtk_symbolic_color_resolve:
* @color: a #GtkSymbolicColor
* @props: (allow-none): #GtkStyleProperties to use when resolving
* named colors, or %NULL
* @resolved_color: (out): return location for the resolved color
*
* If @color is resolvable, @resolved_color will be filled in
* with the resolved color, and %TRUE will be returned. Generally,
* if @color can't be resolved, it is due to it being defined on
* top of a named color that doesn't exist in @props.
*
* When @props is %NULL, resolving of named colors will fail, so if
* your @color is or references such a color, this function will
* return %FALSE.
*
* Returns: %TRUE if the color has been resolved
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
gboolean
gtk_symbolic_color_resolve (GtkSymbolicColor *color,
GtkStyleProperties *props,
GdkRGBA *resolved_color)
{
GdkRGBA pink = { 1.0, 0.5, 0.5, 1.0 };
GtkCssValue *v, *current;
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (resolved_color != NULL, FALSE);
g_return_val_if_fail (props == NULL || GTK_IS_STYLE_PROPERTIES (props), FALSE);
current = _gtk_css_rgba_value_new_from_rgba (&pink);
v = _gtk_css_color_value_resolve (color->value,
GTK_STYLE_PROVIDER_PRIVATE (props),
current,
0,
NULL);
_gtk_css_value_unref (current);
if (v == NULL)
return FALSE;
*resolved_color = *_gtk_css_rgba_value_get_rgba (v);
_gtk_css_value_unref (v);
return TRUE;
}
/**
* gtk_symbolic_color_to_string:
* @color: color to convert to a string
*
* Converts the given @color to a string representation. This is useful
* both for debugging and for serialization of strings. The format of
* the string may change between different versions of GTK, but it is
* guaranteed that the GTK css parser is able to read the string and
* create the same symbolic color from it.
*
* Returns: a new string representing @color
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
char *
gtk_symbolic_color_to_string (GtkSymbolicColor *color)
{
g_return_val_if_fail (color != NULL, NULL);
return _gtk_css_value_to_string (color->value);
}
GtkSymbolicColor *
_gtk_css_symbolic_value_new (GtkCssParser *parser)
{
GtkCssValue *value;
value = _gtk_css_color_value_parse (parser);
if (value == NULL)
return NULL;
return gtk_symbolic_color_new (value);
}
GtkCssValue *
_gtk_symbolic_color_get_css_value (GtkSymbolicColor *symbolic)
{
return symbolic->value;
}
@@ -31,23 +31,33 @@ G_BEGIN_DECLS
GType gtk_symbolic_color_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_8
GtkSymbolicColor * gtk_symbolic_color_new_literal (const GdkRGBA *color);
GDK_DEPRECATED_IN_3_8
GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name);
GDK_DEPRECATED_IN_3_8
GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color,
gdouble factor);
GDK_DEPRECATED_IN_3_8
GtkSymbolicColor * gtk_symbolic_color_new_alpha (GtkSymbolicColor *color,
gdouble factor);
GDK_DEPRECATED_IN_3_8
GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1,
GtkSymbolicColor *color2,
gdouble factor);
GDK_DEPRECATED_IN_3_8
GtkSymbolicColor * gtk_symbolic_color_new_win32 (const gchar *theme_class,
gint id);
GDK_DEPRECATED_IN_3_8
GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color);
GDK_DEPRECATED_IN_3_8
void gtk_symbolic_color_unref (GtkSymbolicColor *color);
GDK_DEPRECATED_IN_3_8
char * gtk_symbolic_color_to_string (GtkSymbolicColor *color);
GDK_DEPRECATED_IN_3_8
gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color,
GtkStyleProperties *props,
GdkRGBA *resolved_color);
+33
View File
@@ -0,0 +1,33 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 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_SYMBOLIC_COLOR_PRIVATE_H__
#define __GTK_SYMBOLIC_COLOR_PRIVATE_H__
#include "gtk/deprecated/gtksymboliccolor.h"
#include "gtk/gtkcssparserprivate.h"
#include "gtk/gtkcssvalueprivate.h"
G_BEGIN_DECLS
GtkSymbolicColor * _gtk_css_symbolic_value_new (GtkCssParser *parser);
GtkCssValue * _gtk_symbolic_color_get_css_value (GtkSymbolicColor *symbolic);
G_END_DECLS
#endif /* __GTK_SYMBOLIC_COLOR_PRIVATE_H__ */
+2 -2
View File
@@ -66,9 +66,9 @@ main (int argc, char *argv[])
#endif
/* Translators: this message will appear immediately after the */
/* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE> */
/* usage string - Usage: COMMAND [OPTION] <THIS_MESSAGE> */
context =
g_option_context_new (_("APPLICATION [URI...] - launch an APPLICATION with URI."));
g_option_context_new (_("APPLICATION [URI] launch an APPLICATION with URI."));
/* Translators: this message will appear after the usage string */
/* and before the list of options. */
+2 -2
View File
@@ -107,7 +107,6 @@
#include <gtk/gtkfontchooserdialog.h>
#include <gtk/gtkfontchooserwidget.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkgradient.h>
#include <gtk/gtkgrid.h>
#include <gtk/gtkiconfactory.h>
#include <gtk/gtkicontheme.h>
@@ -185,7 +184,6 @@
#include <gtk/gtkstyleproperties.h>
#include <gtk/gtkstyleprovider.h>
#include <gtk/gtkswitch.h>
#include <gtk/gtksymboliccolor.h>
#include <gtk/gtktextattributes.h>
#include <gtk/gtktextbuffer.h>
#include <gtk/gtktextbufferrichtext.h>
@@ -229,6 +227,7 @@
#include <gtk/deprecated/gtkcolorsel.h>
#include <gtk/deprecated/gtkcolorseldialog.h>
#include <gtk/deprecated/gtkfontsel.h>
#include <gtk/deprecated/gtkgradient.h>
#include <gtk/deprecated/gtkhandlebox.h>
#include <gtk/deprecated/gtkhbbox.h>
#include <gtk/deprecated/gtkhbox.h>
@@ -239,6 +238,7 @@
#include <gtk/deprecated/gtkhseparator.h>
#include <gtk/deprecated/gtkrc.h>
#include <gtk/deprecated/gtkstyle.h>
#include <gtk/deprecated/gtksymboliccolor.h>
#include <gtk/deprecated/gtktable.h>
#include <gtk/deprecated/gtktearoffmenuitem.h>
#include <gtk/deprecated/gtkvbbox.h>
+9 -12
View File
@@ -2095,11 +2095,9 @@ text_view_new (GtkAboutDialog *about,
GdkColor color;
GdkColor link_color;
GdkColor visited_link_color;
gint size;
PangoFontDescription *font_desc;
GtkAboutDialogPrivate *priv = about->priv;
GtkStyleContext *context;
GtkStateFlags state;
GtkTextIter start_iter, end_iter;
GtkTextTag *tag;
gtk_widget_style_get (GTK_WIDGET (about),
"link-color", &style_link_color,
@@ -2128,14 +2126,11 @@ text_view_new (GtkAboutDialog *about,
gtk_text_view_set_editable (text_view, FALSE);
gtk_text_view_set_wrap_mode (text_view, wrap_mode);
context = gtk_widget_get_style_context (view);
state = gtk_widget_get_state_flags (view);
size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
font_desc = pango_font_description_new ();
pango_font_description_set_size (font_desc, size * PANGO_SCALE_SMALL);
gtk_widget_override_font (view, font_desc);
pango_font_description_free (font_desc);
gtk_text_buffer_get_start_iter (buffer, &start_iter);
gtk_text_buffer_get_start_iter (buffer, &end_iter);
tag = gtk_text_tag_new (NULL);
g_object_set (tag, "font-scale", PANGO_SCALE_SMALL, NULL);
gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
gtk_text_view_set_left_margin (text_view, 8);
gtk_text_view_set_right_margin (text_view, 8);
@@ -2395,6 +2390,8 @@ create_credits_page (GtkAboutDialog *about)
gtk_widget_set_valign (grid, GTK_ALIGN_START);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), grid);
row = 0;
if (priv->authors != NULL)
add_credits_section (about, GTK_GRID (grid), &row, _("Created by"), priv->authors);
+1 -1
View File
@@ -189,7 +189,7 @@ gtk_action_helper_action_removed (GtkActionHelper *helper)
if (helper->active)
{
helper->enabled = FALSE;
helper->active = FALSE;
gtk_action_helper_report_change (helper, PROP_ACTIVE);
}
+3 -3
View File
@@ -225,7 +225,7 @@ other_application_dialog_response_cb (GtkDialog *dialog,
if (response_id != GTK_RESPONSE_OK)
{
/* reset the active item, otherwise we are stuck on
* 'Other application...'
* 'Other application'
*/
gtk_combo_box_set_active (GTK_COMBO_BOX (self), self->priv->last_active);
gtk_widget_destroy (GTK_WIDGET (dialog));
@@ -287,7 +287,7 @@ gtk_app_chooser_button_ensure_dialog_item (GtkAppChooserButton *self,
gtk_list_store_insert_after (self->priv->store, &iter, &iter2);
real_insert_custom_item (self, CUSTOM_ITEM_OTHER_APP,
_("Other application..."), NULL,
_("Other application"), NULL,
FALSE, &iter);
}
@@ -611,7 +611,7 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
*/
pspec =
g_param_spec_boolean ("show-dialog-item",
P_("Include an 'Other...' item"),
P_("Include an 'Other' item"),
P_("Whether the combobox should include an item that triggers a GtkAppChooserDialog"),
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+203 -202
View File
@@ -123,22 +123,24 @@
* (can be specified by their name, nick or integer value), flags (can be
* specified by their name, nick, integer value, optionally combined with "|",
* e.g. "GTK_VISIBLE|GTK_REALIZED") and colors (in a format understood by
* gdk_color_parse()). Objects can be referred to by their name. Pixbufs can be
* specified as a filename of an image file to load. In general, GtkBuilder
* allows forward references to objects &mdash; an object doesn't have to be
* constructed before it can be referred to. The exception to this rule is that
* an object has to be constructed before it can be used as the value of a
* construct-only property.
* gdk_color_parse()). Pixbufs can be specified as a filename of an image file to load.
* Objects can be referred to by their name and by default refer to objects declared
* in the local xml fragment and objects exposed via gtk_builder_expose_object().
*
* In general, GtkBuilder allows forward references to objects &mdash declared
* in the local xml; an object doesn't have to be constructed before it can be referred to.
* The exception to this rule is that an object has to be constructed before
* it can be used as the value of a construct-only property.
*
* Signal handlers are set up with the &lt;signal&gt; element. The "name"
* attribute specifies the name of the signal, and the "handler" attribute
* specifies the function to connect to the signal. By default, GTK+ tries to
* find the handler using g_module_symbol(), but this can be changed by passing
* a custom #GtkBuilderConnectFunc to gtk_builder_connect_signals_full(). The
* remaining attributes, "after", "swapped" and "object", have the same meaning
* attributes "after", "swapped" and "object", have the same meaning
* as the corresponding parameters of the g_signal_connect_object() or
* g_signal_connect_data() functions. A "last_modification_time" attribute
* is also allowed, but it does not have a meaning to the builder.
* g_signal_connect_data() functions. A "last_modification_time" attribute is also
* allowed, but it does not have a meaning to the builder.
*
* Sometimes it is necessary to refer to widgets which have implicitly been
* constructed by GTK+ as part of a composite widget, to set properties on them
@@ -272,6 +274,8 @@ struct _GtkBuilderPrivate
GSList *signals;
gchar *filename;
gchar *resource_prefix;
GType ignore_type;
};
G_DEFINE_TYPE (GtkBuilder, gtk_builder, G_TYPE_OBJECT)
@@ -490,22 +494,24 @@ gtk_builder_get_parameters (GtkBuilder *builder,
if (G_IS_PARAM_SPEC_OBJECT (pspec) &&
(G_PARAM_SPEC_VALUE_TYPE (pspec) != GDK_TYPE_PIXBUF))
{
GObject *object = gtk_builder_get_object (builder, prop->data);
GObject *object;
if (object)
if (pspec->flags & G_PARAM_CONSTRUCT_ONLY)
{
g_value_init (&parameter.value, G_OBJECT_TYPE (object));
g_value_set_object (&parameter.value, object);
}
else
{
if (pspec->flags & G_PARAM_CONSTRUCT_ONLY)
object = gtk_builder_get_object (builder, prop->data);
if (!object)
{
g_warning ("Failed to get constuct only property "
"%s of %s with value `%s'",
prop->name, object_name, prop->data);
continue;
}
g_value_init (&parameter.value, G_OBJECT_TYPE (object));
g_value_set_object (&parameter.value, object);
}
else
{
/* Delay setting property */
property = g_slice_new (DelayedProperty);
property->object = g_strdup (object_name);
@@ -562,7 +568,7 @@ gtk_builder_get_internal_child (GtkBuilder *builder,
obj = gtk_buildable_get_internal_child (GTK_BUILDABLE (info->object),
builder,
childname);
};
}
if (!obj)
{
@@ -574,6 +580,33 @@ gtk_builder_get_internal_child (GtkBuilder *builder,
return obj;
}
static inline void
object_set_name (GObject *object, const gchar *name)
{
if (GTK_IS_BUILDABLE (object))
gtk_buildable_set_name (GTK_BUILDABLE (object), name);
else
g_object_set_data_full (object, "gtk-builder-name", g_strdup (name), g_free);
}
void
_gtk_builder_add_object (GtkBuilder *builder,
const gchar *id,
GObject *object)
{
object_set_name (object, id);
g_hash_table_insert (builder->priv->objects, g_strdup (id), g_object_ref (object));
}
const gchar *
_gtk_builder_object_get_name (GObject *object)
{
if (GTK_IS_BUILDABLE (object))
return gtk_buildable_get_name (GTK_BUILDABLE (object));
else
return g_object_get_data (object, "gtk-builder-name");
}
GObject *
_gtk_builder_construct (GtkBuilder *builder,
ObjectInfo *info,
@@ -587,25 +620,32 @@ _gtk_builder_construct (GtkBuilder *builder,
gboolean custom_set_property;
GtkBuildable *buildable;
g_assert (info->class_name != NULL);
object_type = gtk_builder_get_type_from_name (builder, info->class_name);
if (object_type == G_TYPE_INVALID)
if ((object_type = info->object_type) == G_TYPE_INVALID)
{
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_VALUE,
"Invalid object type `%s'",
info->class_name);
g_type_name (object_type));
return NULL;
}
gtk_builder_get_parameters (builder, object_type,
/* Safeguard to avoid recursion if we are building a new type with builder */
if (object_type == builder->priv->ignore_type)
return NULL;
gtk_builder_get_parameters (builder, info->object_type,
info->id,
info->properties,
&parameters,
&construct_parameters);
if (info->constructor)
if (info->object)
{
/* external_object */
obj = g_object_ref (info->object);
}
else if (info->constructor)
{
GObject *constructor;
@@ -662,7 +702,7 @@ _gtk_builder_construct (GtkBuilder *builder,
g_object_ref_sink (obj);
GTK_NOTE (BUILDER,
g_print ("created %s of type %s\n", info->id, info->class_name));
g_print ("created %s of type %s\n", info->id, g_type_name (object_type)));
for (i = 0; i < construct_parameters->len; i++)
{
@@ -703,29 +743,16 @@ _gtk_builder_construct (GtkBuilder *builder,
g_value_unset (&param->value);
}
g_array_free (parameters, TRUE);
if (GTK_IS_BUILDABLE (obj))
gtk_buildable_set_name (buildable, info->id);
else
g_object_set_data_full (obj,
"gtk-builder-name",
g_strdup (info->id),
g_free);
/* we already own a reference to obj. put it in the hash table. */
g_hash_table_insert (builder->priv->objects, g_strdup (info->id), obj);
/* put it in the hash table. */
_gtk_builder_add_object (builder, info->id, obj);
/* we already own a reference to obj. */
g_object_unref (obj);
return obj;
}
void
_gtk_builder_add_object (GtkBuilder *builder,
const gchar *id,
GObject *object)
{
g_hash_table_insert (builder->priv->objects, g_strdup (id), g_object_ref (object));
}
void
_gtk_builder_add (GtkBuilder *builder,
ChildInfo *child_info)
@@ -851,6 +878,41 @@ gtk_builder_new (void)
return g_object_new (GTK_TYPE_BUILDER, NULL);
}
static guint
gtk_builder_add_from_file_real (GtkBuilder *builder,
const gchar *filename,
gchar **object_ids,
GError **error)
{
GError *tmp_error = NULL;
gchar *buffer;
gsize length;
if (!g_file_get_contents (filename, &buffer, &length, &tmp_error))
{
g_propagate_error (error, tmp_error);
return 0;
}
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (filename);
builder->priv->resource_prefix = NULL;
_gtk_builder_parser_parse_buffer (builder, filename, buffer, length,
object_ids, &tmp_error);
g_free (buffer);
if (tmp_error != NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
return 1;
}
/**
* gtk_builder_add_from_file:
* @builder: a #GtkBuilder
@@ -873,41 +935,11 @@ gtk_builder_add_from_file (GtkBuilder *builder,
const gchar *filename,
GError **error)
{
gchar *buffer;
gsize length;
GError *tmp_error;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (filename != NULL, 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
tmp_error = NULL;
if (!g_file_get_contents (filename, &buffer, &length, &tmp_error))
{
g_propagate_error (error, tmp_error);
return 0;
}
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (filename);
builder->priv->resource_prefix = NULL;
_gtk_builder_parser_parse_buffer (builder, filename,
buffer, length,
NULL,
&tmp_error);
g_free (buffer);
if (tmp_error != NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
return 1;
return gtk_builder_add_from_file_real (builder, filename, NULL, error);
}
/**
@@ -941,34 +973,52 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
gchar **object_ids,
GError **error)
{
gchar *buffer;
gsize length;
GError *tmp_error;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (filename != NULL, 0);
g_return_val_if_fail (object_ids != NULL && object_ids[0] != NULL, 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
return gtk_builder_add_from_file_real (builder, filename, object_ids, error);
}
static guint
gtk_builder_add_from_resource_real (GtkBuilder *builder,
const gchar *path,
gchar **object_ids,
GError **error)
{
GError *tmp_error;
GBytes *data;
char *filename_for_errors;
char *slash;
tmp_error = NULL;
if (!g_file_get_contents (filename, &buffer, &length, &tmp_error))
data = g_resources_lookup_data (path, 0, &tmp_error);
if (data == NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (filename);
builder->priv->resource_prefix = NULL;
builder->priv->filename = g_strdup (".");
_gtk_builder_parser_parse_buffer (builder, filename,
buffer, length,
object_ids,
&tmp_error);
slash = strrchr (path, '/');
if (slash != NULL)
builder->priv->resource_prefix = g_strndup (path, slash - path + 1);
else
builder->priv->resource_prefix = g_strdup ("/");
g_free (buffer);
filename_for_errors = g_strconcat ("<resource>", path, NULL);
_gtk_builder_parser_parse_buffer (builder, filename_for_errors,
g_bytes_get_data (data, NULL), g_bytes_get_size (data),
object_ids, &tmp_error);
g_free (filename_for_errors);
g_bytes_unref (data);
if (tmp_error != NULL)
{
@@ -1001,53 +1051,11 @@ gtk_builder_add_from_resource (GtkBuilder *builder,
const gchar *resource_path,
GError **error)
{
GError *tmp_error;
GBytes *data;
char *filename_for_errors;
char *slash;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (resource_path != NULL, 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
tmp_error = NULL;
data = g_resources_lookup_data (resource_path, 0, &tmp_error);
if (data == NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (".");
slash = strrchr (resource_path, '/');
if (slash != NULL)
builder->priv->resource_prefix =
g_strndup (resource_path, slash - resource_path + 1);
else
builder->priv->resource_prefix =
g_strdup ("/");
filename_for_errors = g_strconcat ("<resource>", resource_path, NULL);
_gtk_builder_parser_parse_buffer (builder, filename_for_errors,
g_bytes_get_data (data, NULL), g_bytes_get_size (data),
NULL,
&tmp_error);
g_free (filename_for_errors);
g_bytes_unref (data);
if (tmp_error != NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
return 1;
return gtk_builder_add_from_resource_real (builder, resource_path, NULL, error);
}
/**
@@ -1081,46 +1089,31 @@ gtk_builder_add_objects_from_resource (GtkBuilder *builder,
gchar **object_ids,
GError **error)
{
GError *tmp_error;
GBytes *data;
char *filename_for_errors;
char *slash;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (resource_path != NULL, 0);
g_return_val_if_fail (object_ids != NULL && object_ids[0] != NULL, 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
tmp_error = NULL;
return gtk_builder_add_from_resource_real (builder, resource_path,
object_ids, error);
}
data = g_resources_lookup_data (resource_path, 0, &tmp_error);
if (data == NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
static guint
gtk_builder_add_from_string_real (GtkBuilder *builder,
const gchar *buffer,
gsize length,
gchar **object_ids,
GError **error)
{
GError *tmp_error = NULL;
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (".");
builder->priv->resource_prefix = NULL;
slash = strrchr (resource_path, '/');
if (slash != NULL)
builder->priv->resource_prefix =
g_strndup (resource_path, slash - resource_path + 1);
else
builder->priv->resource_prefix =
g_strdup ("/");
filename_for_errors = g_strconcat ("<resource>", resource_path, NULL);
_gtk_builder_parser_parse_buffer (builder, filename_for_errors,
g_bytes_get_data (data, NULL), g_bytes_get_size (data),
object_ids,
&tmp_error);
g_free (filename_for_errors);
g_bytes_unref (data);
_gtk_builder_parser_parse_buffer (builder, "<input>", buffer, length,
object_ids, &tmp_error);
if (tmp_error != NULL)
{
g_propagate_error (error, tmp_error);
@@ -1153,30 +1146,11 @@ gtk_builder_add_from_string (GtkBuilder *builder,
gsize length,
GError **error)
{
GError *tmp_error;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (buffer != NULL, 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
tmp_error = NULL;
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (".");
builder->priv->resource_prefix = NULL;
_gtk_builder_parser_parse_buffer (builder, "<input>",
buffer, length,
NULL,
&tmp_error);
if (tmp_error != NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
return 1;
return gtk_builder_add_from_string_real (builder, buffer, length, NULL, error);
}
/**
@@ -1211,32 +1185,13 @@ gtk_builder_add_objects_from_string (GtkBuilder *builder,
gchar **object_ids,
GError **error)
{
GError *tmp_error;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (buffer != NULL, 0);
g_return_val_if_fail (object_ids != NULL && object_ids[0] != NULL, 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
tmp_error = NULL;
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (".");
builder->priv->resource_prefix = NULL;
_gtk_builder_parser_parse_buffer (builder, "<input>",
buffer, length,
object_ids,
&tmp_error);
if (tmp_error != NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
return 1;
return gtk_builder_add_from_string_real (builder, buffer, length,
object_ids, error);
}
/**
@@ -1340,6 +1295,39 @@ gtk_builder_get_translation_domain (GtkBuilder *builder)
return builder->priv->domain;
}
/**
* gtk_builder_expose_object:
* @builder: a #GtkBuilder
* @name: the name of the object exposed to the builder
* @object: the object to expose
*
* Add @object to the @builder object pool so it can be referenced just like any
* other object built by builder.
*
* To make this function even more useful a new special entry point element
* &lt;external-object&gt; is defined. It is similar to &lt;object&gt; but has
* to reference an external object exposed with this function.
* This way you can change properties and even add children to an
* external object using builder, not just reference it.
*
* Since: 3.8
**/
void
gtk_builder_expose_object (GtkBuilder *builder,
const gchar *name,
GObject *object)
{
g_return_if_fail (GTK_IS_BUILDER (builder));
g_return_if_fail (name && name[0]);
g_return_if_fail (gtk_builder_get_object (builder, name) == NULL);
object_set_name (object, name);
g_hash_table_insert (builder->priv->objects,
g_strdup (name),
g_object_ref (object));
}
typedef struct {
GModule *module;
gpointer data;
@@ -1480,7 +1468,8 @@ gtk_builder_connect_signals_full (GtkBuilder *builder,
if (signal->connect_object_name)
{
connect_object = g_hash_table_lookup (builder->priv->objects,
signal->connect_object_name);
signal->connect_object_name);
if (!connect_object)
g_warning ("Could not lookup object %s on signal %s of object %s",
signal->connect_object_name, signal->name,
@@ -2088,3 +2077,15 @@ _gtk_builder_get_absolute_filename (GtkBuilder *builder, const gchar *string)
return filename;
}
void
_gtk_builder_set_ignore_type (GtkBuilder *builder, GType ignore_type)
{
builder->priv->ignore_type = ignore_type;
}
GType
_gtk_builder_get_ignore_type (GtkBuilder *builder)
{
return builder->priv->ignore_type;
}
+6 -1
View File
@@ -59,6 +59,7 @@ typedef struct _GtkBuilderPrivate GtkBuilderPrivate;
* @GTK_BUILDER_ERROR_VERSION_MISMATCH: The input file requires a newer version
* of GTK+.
* @GTK_BUILDER_ERROR_DUPLICATE_ID: An object id occurred twice.
* @GTK_BUILDER_ERROR_TEMPLATE_CLASS_MISMATCH: The Class template is designed for a different class.
*
* Error codes that identify various errors that can occur while using
* #GtkBuilder.
@@ -73,7 +74,8 @@ typedef enum
GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
GTK_BUILDER_ERROR_INVALID_VALUE,
GTK_BUILDER_ERROR_VERSION_MISMATCH,
GTK_BUILDER_ERROR_DUPLICATE_ID
GTK_BUILDER_ERROR_DUPLICATE_ID,
GTK_BUILDER_ERROR_TEMPLATE_CLASS_MISMATCH
} GtkBuilderError;
GQuark gtk_builder_error_quark (void);
@@ -141,6 +143,9 @@ guint gtk_builder_add_objects_from_string (GtkBuilder *builder,
GObject* gtk_builder_get_object (GtkBuilder *builder,
const gchar *name);
GSList* gtk_builder_get_objects (GtkBuilder *builder);
void gtk_builder_expose_object (GtkBuilder *builder,
const gchar *name,
GObject *object);
void gtk_builder_connect_signals (GtkBuilder *builder,
gpointer user_data);
void gtk_builder_connect_signals_full (GtkBuilder *builder,
+15 -1
View File
@@ -1,6 +1,6 @@
start = element interface {
attribute domain { text } ?,
( requires | object | menu ) *
( requires | object | external-object | template | menu ) *
}
requires = element requires {
@@ -16,9 +16,23 @@ object = element object {
(property | signal | child | ANY) *
}
object = element external-object {
attribute id { xsd:ID },
attribute class { text },
(property | signal | child | ANY) *
}
object = element template {
attribute id { xsd:ID },
attribute class { text },
attribute parent { text },
(property | signal | child | ANY) *
}
property = element property {
attribute name { text },
attribute translatable { "yes" | "no" } ?,
attribute external-object { "yes" | "no" } ?,
attribute comments { text } ?,
attribute context { text } ?,
text ?
+429 -52
View File
@@ -29,7 +29,7 @@
#include "gtkversion.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
#include "gtkcontainer.h"
static void free_property_info (PropertyInfo *info);
static void free_object_info (ObjectInfo *info);
@@ -64,6 +64,32 @@ state_pop (ParserData *data)
#define state_peek_info(data, st) ((st*)state_peek(data))
#define state_pop_info(data, st) ((st*)state_pop(data))
static void
error_generic (GError **error,
GtkBuilderError code,
ParserData *data,
const gchar *tag,
const gchar *format,
...)
{
gint line_number, char_number;
gchar *message;
va_list args;
g_markup_parse_context_get_position (data->ctx,
&line_number,
&char_number);
va_start (args, format);
message = g_strdup_vprintf (format, args);
va_end (args);
g_set_error (error, GTK_BUILDER_ERROR, code, "%s:%d:%d <%s> %s",
data->filename, line_number, char_number, tag, message);
g_free (message);
}
static void
error_missing_attribute (ParserData *data,
const gchar *tag,
@@ -190,6 +216,13 @@ builder_construct (ParserData *data,
if (object_info->object)
return object_info->object;
/* Safeguard to avoid recursion if we are building a new type with builder
* _gtk_builder_construct() also checks for this, but there is no need to
* reverse the property list if we are not going to build the object.
*/
if (object_info->object_type == _gtk_builder_get_ignore_type (data->builder))
return NULL;
object_info->properties = g_slist_reverse (object_info->properties);
object = _gtk_builder_construct (data->builder, object_info, error);
@@ -203,24 +236,19 @@ builder_construct (ParserData *data,
return object;
}
static gchar *
static GType
_get_type_by_symbol (const gchar* symbol)
{
static GModule *module = NULL;
GTypeGetFunc func;
GType type;
if (!module)
module = g_module_open (NULL, 0);
if (!g_module_symbol (module, symbol, (gpointer)&func))
return NULL;
return G_TYPE_INVALID;
type = func ();
if (type == G_TYPE_INVALID)
return NULL;
return g_strdup (g_type_name (type));
return func ();
}
static void
@@ -295,6 +323,29 @@ is_requested_object (const gchar *object,
return FALSE;
}
static gboolean
parser_add_object_id (ParserData *data,
const gchar *object_id,
GError **error)
{
gint line, line2;
g_markup_parse_context_get_position (data->ctx, &line, NULL);
line2 = GPOINTER_TO_INT (g_hash_table_lookup (data->object_ids, object_id));
if (line2 != 0)
{
g_set_error (error, GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_DUPLICATE_ID,
_("Duplicate object ID '%s' on line %d (previously on line %d)"),
object_id, line, line2);
return TRUE;
}
g_hash_table_insert (data->object_ids, g_strdup (object_id), GINT_TO_POINTER (line));
return FALSE;
}
static void
parse_object (GMarkupParseContext *context,
ParserData *data,
@@ -303,13 +354,13 @@ parse_object (GMarkupParseContext *context,
const gchar **values,
GError **error)
{
GType object_type = G_TYPE_INVALID;
ObjectInfo *object_info;
ChildInfo* child_info;
int i;
gchar *object_class = NULL;
gchar *object_id = NULL;
gchar *constructor = NULL;
gint line, line2;
ChildInfo *child_info;
const gchar *object_class = NULL;
const gchar *object_id = NULL;
const gchar *constructor = NULL;
gint i, line;
child_info = state_peek_info (data, ChildInfo);
if (child_info && strcmp (child_info->tag.name, "object") == 0)
@@ -321,19 +372,19 @@ parse_object (GMarkupParseContext *context,
for (i = 0; names[i] != NULL; i++)
{
if (strcmp (names[i], "class") == 0)
object_class = g_strdup (values[i]);
object_class = values[i];
else if (strcmp (names[i], "id") == 0)
object_id = g_strdup (values[i]);
object_id = values[i];
else if (strcmp (names[i], "constructor") == 0)
constructor = g_strdup (values[i]);
constructor = values[i];
else if (strcmp (names[i], "type-func") == 0)
{
/* Call the GType function, and return the name of the GType,
* it's guaranteed afterwards that g_type_from_name on the name
* will return our GType
*/
object_class = _get_type_by_symbol (values[i]);
if (!object_class)
object_type = _get_type_by_symbol (values[i]);
if (object_type == G_TYPE_INVALID)
{
g_markup_parse_context_get_position (context, &line, NULL);
g_set_error (error, GTK_BUILDER_ERROR,
@@ -350,7 +401,7 @@ parse_object (GMarkupParseContext *context,
}
}
if (!object_class)
if (object_type == G_TYPE_INVALID && !object_class)
{
error_missing_attribute (data, element_name, "class", error);
return;
@@ -362,6 +413,20 @@ parse_object (GMarkupParseContext *context,
return;
}
if (object_type == G_TYPE_INVALID)
{
/* Make sure the class is initialized so we have intern string available */
object_type = gtk_builder_get_type_from_name (data->builder, object_class);
if (object_type == G_TYPE_INVALID)
{
g_set_error (error, GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_VALUE,
_("Invalid class: '%s'"), object_class);
return;
}
}
++data->cur_object_level;
/* check if we reached a requested object (if it is specified) */
@@ -379,36 +444,24 @@ parse_object (GMarkupParseContext *context,
}
else
{
g_free (object_class);
g_free (object_id);
g_free (constructor);
return;
}
}
else if ((data->in_external_object && !data->external_object) ||
data->template_level)
return;
object_info = g_slice_new0 (ObjectInfo);
object_info->class_name = object_class;
object_info->id = object_id;
object_info->constructor = constructor;
object_info->object_type = object_type;
object_info->id = g_strdup (object_id);
object_info->constructor = g_strdup (constructor);
state_push (data, object_info);
object_info->tag.name = element_name;
if (child_info)
object_info->parent = (CommonInfo*)child_info;
g_markup_parse_context_get_position (context, &line, NULL);
line2 = GPOINTER_TO_INT (g_hash_table_lookup (data->object_ids, object_id));
if (line2 != 0)
{
g_set_error (error, GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_DUPLICATE_ID,
_("Duplicate object ID '%s' on line %d (previously on line %d)"),
object_id, line, line2);
return;
}
g_hash_table_insert (data->object_ids, g_strdup (object_id), GINT_TO_POINTER (line));
parser_add_object_id (data, object_id, error);
}
static void
@@ -420,7 +473,6 @@ free_object_info (ObjectInfo *info)
(GFunc)free_property_info, NULL);
g_slist_free (info->properties);
g_free (info->constructor);
g_free (info->class_name);
g_free (info->id);
g_slice_free (ObjectInfo, info);
}
@@ -531,20 +583,21 @@ parse_property (ParserData *data,
}
info = g_slice_new0 (PropertyInfo);
info->name = name;
info->name = g_intern_string (name);
info->translatable = translatable;
info->context = context;
info->text = g_string_new ("");
info->context = context;
info->text = g_string_new ("");
state_push (data, info);
info->tag.name = element_name;
g_free (name);
}
static void
free_property_info (PropertyInfo *info)
{
g_free (info->data);
g_free (info->name);
g_slice_free (PropertyInfo, info);
}
@@ -556,7 +609,7 @@ parse_signal (ParserData *data,
GError **error)
{
SignalInfo *info;
gchar *name = NULL;
const gchar *name = NULL;
gchar *handler = NULL;
gchar *object = NULL;
gboolean after = FALSE;
@@ -575,7 +628,7 @@ parse_signal (ParserData *data,
for (i = 0; names[i] != NULL; i++)
{
if (strcmp (names[i], "name") == 0)
name = g_strdup (values[i]);
name = values[i];
else if (strcmp (names[i], "handler") == 0)
handler = g_strdup (values[i]);
else if (strcmp (names[i], "after") == 0)
@@ -617,7 +670,7 @@ parse_signal (ParserData *data,
swapped = TRUE;
info = g_slice_new0 (SignalInfo);
info->name = name;
info->name = g_intern_string (name);
info->handler = handler;
if (after)
info->flags |= G_CONNECT_AFTER;
@@ -629,12 +682,303 @@ parse_signal (ParserData *data,
info->tag.name = element_name;
}
typedef struct
{
const gchar *tmpl_class;
gboolean found, done, in_tmpl;
GString *xml;
} TemplateParseData;
static void
extract_template_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer user_data,
GError **error)
{
TemplateParseData *state = user_data;
gint i;
if (state->done) return;
if (g_strcmp0 (element_name, "template") == 0)
{
for (i = 0; attribute_names[i]; i++)
{
if (!g_strcmp0 (attribute_names[i], "class"))
state->found = (g_strcmp0 (attribute_values[i], state->tmpl_class) == 0);
}
if (state->found)
{
state->in_tmpl = TRUE;
g_string_append_printf (state->xml, "<external-object class=\"%s\" id=\"%s\">",
state->tmpl_class,
state->tmpl_class);
return;
}
else
g_string_append_printf (state->xml, "<%s", element_name);
}
else
g_string_append_printf (state->xml, "<%s", element_name);
for (i = 0; attribute_names[i]; i++)
{
g_string_append_printf (state->xml, " %s=\"%s\"",
attribute_names[i], attribute_values[i]);
}
g_string_append_printf (state->xml, ">");
}
static void
extract_template_end_element (GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
GError **error)
{
TemplateParseData *state = user_data;
if (state->done) return;
if (g_strcmp0 (element_name, "template") == 0 && state->in_tmpl)
{
state->in_tmpl = FALSE;
g_string_append (state->xml, "</external-object>");
}
else
g_string_append_printf (state->xml, "</%s>", element_name);
if (g_strcmp0 (element_name, "interface") == 0 && state->found)
state->done = TRUE;
}
static void
extract_template_text (GMarkupParseContext *context,
const gchar *text,
gsize text_len,
gpointer user_data,
GError **error)
{
TemplateParseData *state = user_data;
if (state->done) return;
g_string_append_len (state->xml, text, text_len);
}
static gchar *
extract_template (const gchar *buffer, const gchar *class_name)
{
GMarkupParser parser = { extract_template_start_element, extract_template_end_element, extract_template_text };
TemplateParseData state = { class_name, FALSE, FALSE, FALSE, g_string_new ("")};
GMarkupParseContext *context;
context = g_markup_parse_context_new (&parser,
G_MARKUP_TREAT_CDATA_AS_TEXT |
G_MARKUP_PREFIX_ERROR_POSITION,
&state, NULL);
g_markup_parse_context_parse (context, buffer, -1, NULL);
g_markup_parse_context_end_parse (context, NULL);
g_markup_parse_context_free (context);
if (state.done)
{
gchar *retval = state.xml->str;
g_string_free (state.xml, FALSE);
g_file_set_contents ("/tmp/a.dump", retval, -1, NULL);
return retval;
}
g_string_free (state.xml, TRUE);
return NULL;
}
typedef struct
{
GTypeInfo *info;
gchar *tmpl;
} TmplClassData;
static void
composite_template_derived_class_init (gpointer g_class, gpointer class_data)
{
TmplClassData *data = class_data;
gtk_container_class_set_template_from_string (g_class, data->tmpl,
G_OBJECT_CLASS_NAME (g_class));
}
static GType
create_inline_type (GType parent_type,
const gchar *class_name,
const gchar *template_xml)
{
TmplClassData *tmpl;
GTypeQuery query;
GTypeInfo *info;
g_type_query (parent_type, &query);
tmpl = g_new0 (TmplClassData, 1);
tmpl->info = info = g_new0 (GTypeInfo, 1);
tmpl->tmpl = extract_template (template_xml, class_name);
info->class_size = query.class_size;
info->class_init = composite_template_derived_class_init;
info->class_data = tmpl; /* Let it leak! */
info->instance_size = query.instance_size;
return g_type_register_static (parent_type, class_name, info, 0);
}
static void
parse_template (ParserData *data,
const gchar *element_name,
const gchar **names,
const gchar **values,
GError **error)
{
const gchar *parent_class = NULL;
const gchar *class_name = NULL;
const GSList *l, *p;
GType parent_type;
gint i;
data->template_level++;
if (data->template_level > 1 ||
!((l = g_markup_parse_context_get_element_stack (data->ctx)) &&
(p = g_slist_next (l)) && g_strcmp0 (p->data, "interface") == 0))
{
error_generic (error, GTK_BUILDER_ERROR_INVALID_TAG, data,
element_name, "non toplevel template found");
return;
}
for (i = 0; names[i] != NULL; i++)
{
if (strcmp (names[i], "class") == 0)
class_name = values[i];
else if (strcmp (names[i], "parent") == 0)
parent_class = values[i];
else
{
error_invalid_attribute (data, element_name, names[i], error);
return;
}
}
if (!class_name)
{
error_missing_attribute (data, element_name, "class", error);
return;
}
if (!parent_class)
{
error_missing_attribute (data, element_name, "parent", error);
return;
}
if (g_type_from_name (class_name))
{
error_generic (error, GTK_BUILDER_ERROR_TEMPLATE_CLASS_MISMATCH, data,
element_name, "template class '%s' already registered", class_name);
return;
}
if (!(parent_type = gtk_builder_get_type_from_name (data->builder, parent_class)))
{
error_generic (error, GTK_BUILDER_ERROR_TEMPLATE_CLASS_MISMATCH, data,
element_name, "invalid parent class type found '%s'", parent_class);
return;
}
/* Generate inline type */
create_inline_type (parent_type, class_name, data->buffer);
}
static void
parse_external_object (ParserData *data,
const gchar *element_name,
const gchar **names,
const gchar **values,
GError **error)
{
const gchar *class_name = NULL;
const gchar *id = NULL;
GObject *parent;
gint i;
data->in_external_object = TRUE;
for (i = 0; names[i] != NULL; i++)
{
if (strcmp (names[i], "class") == 0)
class_name = values[i];
else if (strcmp (names[i], "id") == 0)
id = values[i];
else if (strcmp (names[i], "parent") == 0);
else
{
error_invalid_attribute (data, element_name, names[i], error);
return;
}
}
if (!class_name)
{
error_missing_attribute (data, element_name, "class", error);
return;
}
if (!id)
{
error_missing_attribute (data, element_name, "id", error);
return;
}
if (data->requested_objects == NULL &&
(parent = gtk_builder_get_object (data->builder, id)))
{
GType class_type, parent_type = G_OBJECT_TYPE (parent);
ObjectInfo *object_info;
if (!(class_type = g_type_from_name (class_name)))
{
error_generic (error, GTK_BUILDER_ERROR_TEMPLATE_CLASS_MISMATCH, data,
element_name, "invalid class type found '%s'", class_name);
return;
}
if (!g_type_is_a (parent_type, class_type))
{
error_generic (error, GTK_BUILDER_ERROR_TEMPLATE_CLASS_MISMATCH, data,
element_name, "this template is for a class type %s not for %s",
class_name, G_OBJECT_TYPE_NAME (parent));
return;
}
/* push parent to build its children from the template */
object_info = g_slice_new0 (ObjectInfo);
object_info->object = data->external_object = parent;
object_info->object_type = parent_type;
object_info->id = g_strdup (_gtk_builder_object_get_name (parent));
object_info->tag.name = "object";
state_push (data, object_info);
parser_add_object_id (data, object_info->id, error);
}
}
/* Called by GtkBuilder */
void
_free_signal_info (SignalInfo *info,
gpointer user_data)
{
g_free (info->name);
g_free (info->handler);
g_free (info->connect_object_name);
g_free (info->object_name);
@@ -875,9 +1219,15 @@ start_element (GMarkupParseContext *context,
if (strcmp (element_name, "requires") == 0)
parse_requires (data, element_name, names, values, error);
else if (strcmp (element_name, "template") == 0)
parse_template (data, element_name, names, values, error);
else if (strcmp (element_name, "external-object") == 0)
parse_external_object (data, element_name, names, values, error);
else if (strcmp (element_name, "object") == 0)
parse_object (context, data, element_name, names, values, error);
else if (data->requested_objects && !data->inside_requested_object)
else if ((data->requested_objects && !data->inside_requested_object) ||
(data->in_external_object && !data->external_object) ||
data->template_level)
{
/* If outside a requested object, simply ignore this tag */
return;
@@ -963,9 +1313,35 @@ end_element (GMarkupParseContext *context,
else if (strcmp (element_name, "interface") == 0)
{
}
else if (data->requested_objects && !data->inside_requested_object)
else if (strcmp (element_name, "template") == 0)
{
/* If outside a requested object, simply ignore this tag */
data->template_level--;
}
else if (strcmp (element_name, "external-object") == 0)
{
data->in_external_object = FALSE;
if (data->external_object)
{
ObjectInfo *object_info = state_pop_info (data, ObjectInfo);
object_info->properties = g_slist_reverse (object_info->properties);
/* This is just to apply properties to the external object */
_gtk_builder_construct (data->builder, object_info, error);
if (object_info->signals)
_gtk_builder_add_signals (data->builder, object_info->signals);
free_object_info (object_info);
data->external_object = NULL;
}
}
else if ((data->requested_objects && !data->inside_requested_object) ||
(data->in_external_object && !data->external_object) ||
data->template_level)
{
/* If outside a requested object or template, simply ignore this tag */
return;
}
else if (strcmp (element_name, "menu") == 0)
@@ -1144,6 +1520,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
domain = gtk_builder_get_translation_domain (builder);
data = g_new0 (ParserData, 1);
data->buffer = buffer;
data->builder = builder;
data->filename = filename;
data->domain = g_strdup (domain);
+19 -10
View File
@@ -31,7 +31,7 @@ typedef struct {
typedef struct {
TagInfo tag;
gchar *class_name;
GType object_type;
gchar *id;
gchar *constructor;
GSList *properties;
@@ -58,17 +58,17 @@ typedef struct {
typedef struct {
TagInfo tag;
gchar *name;
const gchar *name; /* Intern string */
GString *text;
gchar *data;
gboolean translatable;
gchar *context;
guint8 translatable : 1;
} PropertyInfo;
typedef struct {
TagInfo tag;
gchar *object_name;
gchar *name;
const gchar *name; /* Intern string */
gchar *handler;
GConnectFlags flags;
gchar *connect_object_name;
@@ -91,6 +91,7 @@ typedef struct {
} SubParser;
typedef struct {
const gchar *buffer;
const gchar *last_element;
GtkBuilder *builder;
gchar *domain;
@@ -107,17 +108,21 @@ typedef struct {
gint cur_object_level;
GHashTable *object_ids;
GObject *external_object;
gint in_external_object;
gint template_level;
} ParserData;
typedef GType (*GTypeGetFunc) (void);
/* Things only GtkBuilder should use */
void _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
const gchar *filename,
const gchar *buffer,
gsize length,
gchar **requested_objs,
GError **error);
void _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
const gchar *filename,
const gchar *buffer,
gsize length,
gchar **requested_objs,
GError **error);
GObject * _gtk_builder_construct (GtkBuilder *builder,
ObjectInfo *info,
GError **error);
@@ -159,5 +164,9 @@ void _gtk_builder_menu_start (ParserData *parser_data,
GError **error);
void _gtk_builder_menu_end (ParserData *parser_data);
const gchar * _gtk_builder_object_get_name (GObject *object);
void _gtk_builder_set_ignore_type (GtkBuilder *builder, GType ignore_type);
GType _gtk_builder_get_ignore_type (GtkBuilder *builder);
#endif /* __GTK_BUILDER_PRIVATE_H__ */
+2 -2
View File
@@ -413,7 +413,7 @@ gtk_cell_renderer_accel_get_preferred_width (GtkCellRenderer *cell,
GtkRequisition min_req, nat_req;
if (priv->sizing_label == NULL)
priv->sizing_label = gtk_label_new (_("New accelerator..."));
priv->sizing_label = gtk_label_new (_("New accelerator"));
gtk_widget_get_preferred_size (priv->sizing_label, &min_req, &nat_req);
@@ -744,7 +744,7 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
* an accelerator when the cell is clicked to change the
* acelerator.
*/
gtk_label_set_text (GTK_LABEL (label), _("New accelerator..."));
gtk_label_set_text (GTK_LABEL (label), _("New accelerator"));
gtk_container_add (GTK_CONTAINER (eventbox), label);
+3 -7
View File
@@ -1768,7 +1768,7 @@ get_size (GtkCellRenderer *cell,
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
font_desc = pango_font_description_copy_static (gtk_style_context_get_font (style_context, state));
gtk_style_context_get (style_context, state, "font", &font_desc, NULL);
pango_font_description_merge_static (font_desc, priv->font, TRUE);
if (priv->scale_set)
@@ -2128,8 +2128,6 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
{
GtkCellRendererTextPrivate *priv;
GtkCellRendererText *celltext;
GtkStyleContext *style_context;
const PangoFontDescription *font_desc;
PangoLayout *layout;
PangoContext *context;
PangoFontMetrics *metrics;
@@ -2149,8 +2147,6 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
celltext = GTK_CELL_RENDERER_TEXT (cell);
priv = celltext->priv;
style_context = gtk_widget_get_style_context (widget);
gtk_cell_renderer_get_padding (cell, &xpad, NULL);
layout = get_layout (celltext, widget, NULL, 0);
@@ -2162,8 +2158,8 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
/* Fetch the average size of a charachter */
context = pango_layout_get_context (layout);
font_desc = gtk_style_context_get_font (style_context, 0);
metrics = pango_context_get_metrics (context, font_desc,
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
+71 -35
View File
@@ -38,6 +38,13 @@ enum {
LAST_SIGNAL
};
@interface GtkClipboardOwner : NSObject {
GtkClipboard *clipboard;
gboolean setting_same_owner;
}
@end
typedef struct _GtkClipboardClass GtkClipboardClass;
struct _GtkClipboard
@@ -45,6 +52,8 @@ struct _GtkClipboard
GObject parent_instance;
NSPasteboard *pasteboard;
GtkClipboardOwner *owner;
NSInteger change_count;
GdkAtom selection;
@@ -76,16 +85,15 @@ struct _GtkClipboardClass
GdkEventOwnerChange *event);
};
@interface GtkClipboardOwner : NSObject {
GtkClipboard *clipboard;
static void gtk_clipboard_class_init (GtkClipboardClass *class);
static void gtk_clipboard_finalize (GObject *object);
static void gtk_clipboard_owner_change (GtkClipboard *clipboard,
GdkEventOwnerChange *event);
GtkClipboardGetFunc get_func;
GtkClipboardClearFunc clear_func;
gpointer user_data;
}
@end
static void clipboard_unset (GtkClipboard *clipboard);
static GtkClipboard *clipboard_peek (GdkDisplay *display,
GdkAtom selection,
gboolean only_if_exists);
@implementation GtkClipboardOwner
-(void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type
@@ -117,12 +125,16 @@ struct _GtkClipboardClass
}
}
/* pasteboardChangedOwner is not called immediately, and it's not called
* reliably. It is somehow documented in the apple api docs, but the docs
* suck and don't really give clear instructions. Therefore we track
* changeCount in several places below and clear the clipboard if it
* changed.
*/
- (void)pasteboardChangedOwner:(NSPasteboard *)sender
{
if (clear_func)
clear_func (clipboard, user_data);
[self release];
if (! setting_same_owner)
clipboard_unset (clipboard);
}
- (id)initWithClipboard:(GtkClipboard *)aClipboard
@@ -132,6 +144,7 @@ struct _GtkClipboardClass
if (self)
{
clipboard = aClipboard;
setting_same_owner = FALSE;
}
return self;
@@ -139,15 +152,6 @@ struct _GtkClipboardClass
@end
static void gtk_clipboard_class_init (GtkClipboardClass *class);
static void gtk_clipboard_finalize (GObject *object);
static void gtk_clipboard_owner_change (GtkClipboard *clipboard,
GdkEventOwnerChange *event);
static void clipboard_unset (GtkClipboard *clipboard);
static GtkClipboard *clipboard_peek (GdkDisplay *display,
GdkAtom selection,
gboolean only_if_exists);
static const gchar clipboards_owned_key[] = "gtk-clipboards-owned";
static GQuark clipboards_owned_key_id = 0;
@@ -331,10 +335,6 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
NSSet *types;
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
if (!(clipboard->have_owner && have_owner) ||
clipboard->user_data != user_data)
{
@@ -349,17 +349,44 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
clipboard->user_data != user_data)
{
(*clear_func) (clipboard, user_data);
[pool release];
return FALSE;
}
else
{
[pool release];
return TRUE;
}
}
}
pool = [[NSAutoreleasePool alloc] init];
types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
/* call declareTypes before setting the clipboard members because
* declareTypes might clear the clipboard
*/
if (user_data && user_data == clipboard->user_data)
{
owner = [clipboard->owner retain];
owner->setting_same_owner = TRUE;
clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
owner: owner];
owner->setting_same_owner = FALSE;
}
else
{
owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
owner: owner];
}
[owner release];
[types release];
[pool release];
clipboard->owner = owner;
clipboard->user_data = user_data;
clipboard->have_owner = have_owner;
if (have_owner)
@@ -371,12 +398,6 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
gtk_target_list_unref (clipboard->target_list);
clipboard->target_list = gtk_target_list_new (targets, n_targets);
types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
[clipboard->pasteboard declareTypes:[types allObjects] owner:owner];
[types release];
[pool release];
return TRUE;
}
@@ -420,6 +441,12 @@ gtk_clipboard_get_owner (GtkClipboard *clipboard)
{
g_return_val_if_fail (clipboard != NULL, NULL);
if (clipboard->change_count < [clipboard->pasteboard changeCount])
{
clipboard_unset (clipboard);
clipboard->change_count = [clipboard->pasteboard changeCount];
}
if (clipboard->have_owner)
return clipboard->user_data;
else
@@ -448,7 +475,8 @@ clipboard_unset (GtkClipboard *clipboard)
clipboard->n_storable_targets = -1;
g_free (clipboard->storable_targets);
clipboard->storable_targets = NULL;
clipboard->owner = NULL;
clipboard->get_func = NULL;
clipboard->clear_func = NULL;
clipboard->user_data = NULL;
@@ -473,6 +501,8 @@ clipboard_unset (GtkClipboard *clipboard)
void
gtk_clipboard_clear (GtkClipboard *clipboard)
{
clipboard_unset (clipboard);
[clipboard->pasteboard declareTypes:nil owner:nil];
}
@@ -656,6 +686,12 @@ gtk_clipboard_wait_for_contents (GtkClipboard *clipboard,
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GtkSelectionData *selection_data = NULL;
if (clipboard->change_count < [clipboard->pasteboard changeCount])
{
clipboard_unset (clipboard);
clipboard->change_count = [clipboard->pasteboard changeCount];
}
if (target == gdk_atom_intern_static_string ("TARGETS"))
{
NSArray *types = [clipboard->pasteboard types];
+33 -26
View File
@@ -584,36 +584,42 @@ dialog_response (GtkDialog *dialog,
}
}
/* Create the dialog and connects its buttons */
static void
ensure_dialog (GtkColorButton *button)
{
GtkWidget *parent, *dialog;
if (button->priv->cs_dialog != NULL)
return;
parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
gtk_window_set_modal (GTK_WINDOW (dialog),
gtk_window_get_modal (GTK_WINDOW (parent)));
}
g_signal_connect (dialog, "response",
G_CALLBACK (dialog_response), button);
g_signal_connect (dialog, "destroy",
G_CALLBACK (dialog_destroy), button);
}
static void
gtk_color_button_clicked (GtkButton *b)
{
GtkColorButton *button = GTK_COLOR_BUTTON (b);
GtkWidget *dialog;
/* if dialog already exists, make sure it's shown and raised */
if (!button->priv->cs_dialog)
{
/* Create the dialog and connects its buttons */
GtkWidget *parent;
parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
gtk_window_set_modal (GTK_WINDOW (dialog),
gtk_window_get_modal (GTK_WINDOW (parent)));
}
g_signal_connect (dialog, "response",
G_CALLBACK (dialog_response), button);
g_signal_connect (dialog, "destroy",
G_CALLBACK (dialog_destroy), button);
}
ensure_dialog (button);
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
button->priv->use_alpha);
@@ -962,8 +968,9 @@ gtk_color_button_add_palette (GtkColorChooser *chooser,
{
GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
if (button->priv->cs_dialog)
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
ensure_dialog (button);
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
orientation, colors_per_line, n_colors, colors);
}
+2 -8
View File
@@ -5446,12 +5446,9 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
gint font_size, arrow_size;
PangoContext *context;
PangoFontMetrics *metrics;
const PangoFontDescription *font_desc;
GtkWidget *child;
gint minimum_width = 0, natural_width = 0;
gint child_min, child_nat;
GtkStyleContext *style_context;
GtkStateFlags state;
GtkBorder padding;
gfloat arrow_scaling;
@@ -5465,14 +5462,11 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
"arrow-scaling", &arrow_scaling,
NULL);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
get_widget_padding_and_border (widget, &padding);
font_desc = gtk_style_context_get_font (style_context, state);
context = gtk_widget_get_pango_context (GTK_WIDGET (widget));
metrics = pango_context_get_metrics (context, font_desc,
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
pango_context_get_language (context));
font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));
+349
View File
@@ -231,6 +231,36 @@
* </refsect2>
*/
typedef struct
{
gchar *name;
GType type;
guint offset;
gboolean private;
} InternalChildData;
typedef struct
{
gchar *name;
GObject *object;
} InternalChild;
typedef enum
{
TMPL_STRING,
TMPL_RESOURCE
} GtkContainerTemplateType;
struct _GtkContainerClassPrivate
{
GSList *tmpl_classes;
const gchar *tmpl, *tmpl_id;
glong tmpl_len;
GtkContainerTemplateType tmpl_type;
GtkBuilderConnectFunc connect_func;
GList *internal_children; /* InternalChildData list */
};
struct _GtkContainerPrivate
{
@@ -244,6 +274,8 @@ struct _GtkContainerPrivate
guint restyle_pending : 1;
guint resize_mode : 2;
guint request_mode : 2;
GArray *internal_children; /* InternalChild array */
};
enum {
@@ -271,6 +303,9 @@ static void gtk_container_base_class_finalize (GtkContainerClass *klass);
static void gtk_container_class_init (GtkContainerClass *klass);
static void gtk_container_init (GtkContainer *container);
static void gtk_container_destroy (GtkWidget *widget);
static GObject *gtk_container_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties);
static void gtk_container_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -390,6 +425,8 @@ gtk_container_get_type (void)
GTK_TYPE_BUILDABLE,
&buildable_info);
g_type_add_class_private (container_type, sizeof (GtkContainerClassPrivate));
}
return container_type;
@@ -398,7 +435,19 @@ gtk_container_get_type (void)
static void
gtk_container_base_class_init (GtkContainerClass *class)
{
GtkContainerClassPrivate *priv;
/* reset instance specifc class fields that don't get inherited */
class->priv = priv = G_TYPE_CLASS_GET_PRIVATE (class,
GTK_TYPE_CONTAINER,
GtkContainerClassPrivate);
priv->tmpl = NULL;
priv->tmpl_id = NULL;
priv->tmpl_classes = NULL;
priv->connect_func = NULL;
priv->internal_children = NULL;
class->set_child_property = NULL;
class->get_child_property = NULL;
}
@@ -406,6 +455,7 @@ gtk_container_base_class_init (GtkContainerClass *class)
static void
gtk_container_base_class_finalize (GtkContainerClass *class)
{
GtkContainerClassPrivate *priv = class->priv;
GList *list, *node;
list = g_param_spec_pool_list_owned (_gtk_widget_child_property_pool, G_OBJECT_CLASS_TYPE (class));
@@ -418,6 +468,8 @@ gtk_container_base_class_finalize (GtkContainerClass *class)
g_param_spec_unref (pspec);
}
g_list_free (list);
g_slist_free (priv->tmpl_classes);
}
static void
@@ -431,6 +483,7 @@ gtk_container_class_init (GtkContainerClass *class)
vadjustment_key_id = g_quark_from_static_string (vadjustment_key);
hadjustment_key_id = g_quark_from_static_string (hadjustment_key);
gobject_class->constructor = gtk_container_constructor;
gobject_class->set_property = gtk_container_set_property;
gobject_class->get_property = gtk_container_get_property;
@@ -520,10 +573,37 @@ gtk_container_class_init (GtkContainerClass *class)
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_CONTAINER_ACCESSIBLE);
}
static GObject *
gtk_container_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *childname)
{
GArray *internal_children;
g_return_val_if_fail (childname && childname[0], NULL);
if ((internal_children = GTK_CONTAINER (buildable)->priv->internal_children))
{
gint i, len;
for (i = 0, len = internal_children->len; i < len; i++)
{
InternalChild *data = &g_array_index (internal_children, InternalChild, i);
if (g_strcmp0 (data->name, childname) == 0) return data->object;
}
}
return parent_buildable_iface->get_internal_child (buildable,
builder,
childname);
}
static void
gtk_container_buildable_init (GtkBuildableIface *iface)
{
parent_buildable_iface = g_type_interface_peek_parent (iface);
iface->get_internal_child = gtk_container_buildable_get_internal_child;
iface->add_child = gtk_container_buildable_add_child;
iface->custom_tag_start = gtk_container_buildable_custom_tag_start;
iface->custom_tag_end = gtk_container_buildable_custom_tag_end;
@@ -1319,6 +1399,152 @@ gtk_container_class_list_child_properties (GObjectClass *cclass,
return pspecs;
}
static void
gtk_container_class_set_template (GtkContainerClass *container_class,
const gchar *tmpl,
const gchar *template_id,
GtkContainerTemplateType tmpl_type)
{
GtkContainerClassPrivate *priv = container_class->priv;
GObjectClass *oclass;
priv->tmpl = tmpl;
priv->tmpl_len = g_utf8_strlen (tmpl, -1);
priv->tmpl_id = template_id;
priv->tmpl_type = tmpl_type;
if (priv->tmpl_classes)
{
g_slist_free (priv->tmpl_classes);
priv->tmpl_classes = NULL;
}
/* Collect an ordered list of class which have templates to build */
for (oclass = G_OBJECT_CLASS (container_class);
GTK_IS_CONTAINER_CLASS (oclass);
oclass = g_type_class_peek_parent (oclass))
{
GtkContainerClassPrivate *cpriv = GTK_CONTAINER_CLASS (oclass)->priv;
if (cpriv->tmpl)
priv->tmpl_classes = g_slist_prepend (priv->tmpl_classes, oclass);
}
}
/**
* gtk_container_class_set_template_from_string:
* @container_class: a #GtkContainerClass
* @template_string: the #GtkBuilder xml string
* @template_id: the template id
*
* For type implementations it is recommended to use #gtk_container_class_set_template_from_resource
* instead of this function.
*
* Since: 3.8
*/
void
gtk_container_class_set_template_from_string (GtkContainerClass *container_class,
const gchar *template_string,
const gchar *template_id)
{
g_return_if_fail (GTK_IS_CONTAINER_CLASS (container_class));
g_return_if_fail (template_string && template_string[0]);
g_return_if_fail (template_id && template_id[0]);
gtk_container_class_set_template (container_class, template_string,
template_id, TMPL_STRING);
}
/**
* gtk_container_class_set_template_from_resource:
* @container_class: a #GtkContainerClass
* @resource_path: the #GtkBuilder xml resource path
* @template_id: the template id
*
* This is used when implementing new composite widget types
* to specify a UI template for instances of this type.
*
* Templates are in the <link linkend="BUILDER-UI">GtkBuilder UI description</link>
* format and are used to implement composite widget types in
* an automated way.
*
* Instances with an assigned template will have their children built at object
* construct time.
*
* The provided xml is expected to have a <external-object> tag instead of
* <object> with id=@template_id.
*
* Since: 3.8
*/
void
gtk_container_class_set_template_from_resource (GtkContainerClass *container_class,
const gchar *resource_path,
const gchar *template_id)
{
g_return_if_fail (GTK_IS_CONTAINER_CLASS (container_class));
g_return_if_fail (resource_path && resource_path[0]);
g_return_if_fail (template_id && template_id[0]);
gtk_container_class_set_template (container_class, resource_path,
template_id, TMPL_RESOURCE);
}
/**
* gtk_container_class_set_connect_func:
* @container_class: a #GtkContainerClass
* @connect_func: the #GtkBuilderConnectFunc to use when connecting signals internally.
*
* Sets the function to be used when automatically connecting signals
* defined by this class's GtkBuilder template.
*
* Since: 3.6
*/
void
gtk_container_class_set_connect_func (GtkContainerClass *container_class,
GtkBuilderConnectFunc connect_func)
{
g_return_if_fail (GTK_IS_CONTAINER_CLASS(container_class));
g_return_if_fail (connect_func != NULL);
container_class->priv->connect_func = connect_func;
}
/**
* gtk_container_class_declare_internal_child:
* @container_class: a #GtkContainerClass
* @use_private: True if struct_offset refers to the instance private struct
* @struct_offset: offset where to save composite children pointer
* @name: the name of the composite children to declare
*
* Declare a child defined in the template as an internal children.
* Use #G_STRUCT_OFFSET to pass in the struct_offset of the pointer that will be set automatically on construction.
* If you do not need to keep a pointer set use_private to FALSE and struct_offset to 0.
*
* Since: 3.6
*/
void
gtk_container_class_declare_internal_child (GtkContainerClass *container_class,
gboolean use_private,
guint struct_offset,
const gchar *name)
{
GtkContainerClassPrivate *priv;
InternalChildData *child;
g_return_if_fail (GTK_IS_CONTAINER_CLASS (container_class));
g_return_if_fail (name);
priv = container_class->priv;
child = g_new0 (InternalChildData, 1);
child->name = g_strdup (name);
child->private = use_private;
child->type = G_TYPE_FROM_CLASS (container_class);
child->offset = struct_offset;
priv->internal_children = g_list_prepend (priv->internal_children, child);
}
static void
gtk_container_add_unimplemented (GtkContainer *container,
GtkWidget *widget)
@@ -1347,6 +1573,7 @@ gtk_container_init (GtkContainer *container)
priv->border_width = 0;
priv->resize_mode = GTK_RESIZE_PARENT;
priv->reallocate_redraws = FALSE;
priv->internal_children = NULL;
}
static void
@@ -1375,11 +1602,133 @@ gtk_container_destroy (GtkWidget *widget)
if (priv->has_focus_chain)
gtk_container_unset_focus_chain (container);
if (priv->internal_children)
{
GArray *internal_children = priv->internal_children;
gint i, len = internal_children->len;
for (i = 0; i < len; i++)
{
InternalChild *data = &g_array_index (internal_children, InternalChild, i);
g_object_unref (data->object);
}
g_array_unref (internal_children);
priv->internal_children = NULL;
}
gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL);
GTK_WIDGET_CLASS (parent_class)->destroy (widget);
}
static void
gtk_container_child_set_internal (GtkContainer *container,
InternalChildData *child,
GObject *internal)
{
GtkContainerPrivate *priv = container->priv;
InternalChild data;
GObject **retval;
if (!priv->internal_children)
priv->internal_children = g_array_new (FALSE, FALSE, sizeof (InternalChild));
if (GTK_IS_WIDGET (internal))
gtk_widget_set_composite_name (GTK_WIDGET (internal), child->name);
data.name = child->name;
data.object = g_object_ref (internal);
g_array_append_val (priv->internal_children, data);
if (child->private)
{
gpointer pstruct = G_TYPE_INSTANCE_GET_PRIVATE (container, child->type, gpointer);
retval = G_STRUCT_MEMBER_P (pstruct, child->offset);
}
else
retval = G_STRUCT_MEMBER_P (container, child->offset);
*retval = internal;
}
static GObject *
gtk_container_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GtkContainerClassPrivate *priv;
GtkContainer *container;
GError *error = NULL;
GtkBuilder *builder;
GObject *object;
GSList *l;
object = G_OBJECT_CLASS (parent_class)->constructor (type,
n_construct_properties,
construct_properties);
priv = GTK_CONTAINER_CLASS (G_OBJECT_GET_CLASS (object))->priv;
container = GTK_CONTAINER (object);
gtk_widget_push_composite_child ();
/* Build the templates for each class starting with the superclass descending */
for (l = priv->tmpl_classes; l; l = g_slist_next (l))
{
GtkContainerClassPrivate *cpriv = GTK_CONTAINER_CLASS (l->data)->priv;
GList *children;
guint ret;
builder = gtk_builder_new ();
gtk_builder_expose_object (builder, cpriv->tmpl_id, object);
/* Safeguard to avoid recursion */
_gtk_builder_set_ignore_type (builder, type);
if (cpriv->tmpl_type == TMPL_STRING)
ret = gtk_builder_add_from_string (builder, cpriv->tmpl, cpriv->tmpl_len, &error);
else if (cpriv->tmpl_type == TMPL_RESOURCE)
ret = gtk_builder_add_from_resource (builder, cpriv->tmpl, &error);
else
ret = 0;
if (ret)
{
/* Setup internal children */
for (children = cpriv->internal_children; children; children = g_list_next (children))
{
InternalChildData *child = children->data;
GObject *internal;
if ((internal = gtk_builder_get_object (builder, child->name)))
gtk_container_child_set_internal (container, child, internal);
else
{
g_warning ("Unable to setup internal child %s while building GtkContainer class %s",
g_type_name (type), child->name);
continue;
}
}
if (cpriv->connect_func)
gtk_builder_connect_signals_full (builder, cpriv->connect_func, container);
else
gtk_builder_connect_signals (builder, container);
}
else
{
g_critical ("Unable to build GtkContainer class %s from template: %s",
g_type_name (type), error->message);
g_error_free (error);
}
g_object_unref (builder);
}
gtk_widget_pop_composite_child ();
return object;
}
static void
gtk_container_set_property (GObject *object,
guint prop_id,
+19 -1
View File
@@ -31,6 +31,8 @@
#include <gtk/gtkwidget.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkbuilder.h>
G_BEGIN_DECLS
@@ -46,6 +48,7 @@ G_BEGIN_DECLS
typedef struct _GtkContainer GtkContainer;
typedef struct _GtkContainerPrivate GtkContainerPrivate;
typedef struct _GtkContainerClass GtkContainerClass;
typedef struct _GtkContainerClassPrivate GtkContainerClassPrivate;
struct _GtkContainer
{
@@ -91,6 +94,8 @@ struct _GtkContainerClass
unsigned int _handle_border_width : 1;
GtkContainerClassPrivate *priv;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
@@ -99,7 +104,6 @@ struct _GtkContainerClass
void (*_gtk_reserved5) (void);
void (*_gtk_reserved6) (void);
void (*_gtk_reserved7) (void);
void (*_gtk_reserved8) (void);
};
@@ -219,6 +223,20 @@ void gtk_container_forall (GtkContainer *container,
void gtk_container_class_handle_border_width (GtkContainerClass *klass);
/* Class-level functions */
void gtk_container_class_set_template_from_string (GtkContainerClass *container_class,
const gchar *template_string,
const gchar *template_id);
void gtk_container_class_set_template_from_resource (GtkContainerClass *container_class,
const gchar *resource_path,
const gchar *template_id);
void gtk_container_class_set_connect_func (GtkContainerClass *container_class,
GtkBuilderConnectFunc connect_func);
void gtk_container_class_declare_internal_child (GtkContainerClass *container_class,
gboolean use_private,
guint struct_offset,
const gchar *name);
GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer *container,
GtkWidget *child);
+18 -13
View File
@@ -51,28 +51,33 @@ gtk_css_value_array_compute (GtkCssValue *value,
GtkCssDependencies *dependencies)
{
GtkCssValue *result;
gboolean changed = FALSE;
guint i;
GtkCssValue *i_value;
guint i, j;
GtkCssDependencies child_deps;
if (value->n_values == 0)
return _gtk_css_value_ref (value);
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
result = NULL;
for (i = 0; i < value->n_values; i++)
{
result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, values, parent_values, &child_deps);
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
changed |= (result->values[i] != value->values[i]);
if (result == NULL &&
i_value != value->values[i])
{
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
for (j = 0; j < i; j++)
_gtk_css_value_ref (result->values[j]);
}
if (result != NULL)
result->values[i] = i_value;
else
_gtk_css_value_unref (i_value);
}
if (!changed)
{
_gtk_css_value_unref (result);
return _gtk_css_value_ref (value);
}
if (result == NULL)
return _gtk_css_value_ref (value);
return result;
}
+1 -1
View File
@@ -74,7 +74,7 @@ gtk_css_value_bg_size_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
return value1->cover == value2->cover &&
value2->contain == value2->contain &&
value1->contain == value2->contain &&
(value1->x == value2->x ||
(value1->x != NULL && value2->x != NULL &&
_gtk_css_value_equal (value1->x, value2->x))) &&
+20 -27
View File
@@ -24,7 +24,6 @@
#include "gtkhslaprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproperties.h"
#include "gtksymboliccolorprivate.h"
#include "gtkwin32themeprivate.h"
typedef enum {
@@ -136,12 +135,12 @@ gtk_css_value_color_get_fallback (guint property_id,
}
}
static GtkCssValue *
gtk_css_color_value_resolve_full (GtkCssValue *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies)
GtkCssValue *
_gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies)
{
GtkCssDependencies unused;
GtkCssValue *value;
@@ -161,14 +160,13 @@ gtk_css_color_value_resolve_full (GtkCssValue *color,
return _gtk_css_value_ref (color->last_value);
case COLOR_TYPE_NAME:
{
GtkSymbolicColor *symbolic;
GtkCssValue *named;
symbolic = _gtk_style_provider_private_get_color (provider, color->sym_col.name);
if (!symbolic)
named = _gtk_style_provider_private_get_color (provider, color->sym_col.name);
if (named == NULL)
return NULL;
value = _gtk_symbolic_color_resolve_full (symbolic, provider, current, current_deps, dependencies);
value = _gtk_css_color_value_resolve (named, provider, current, current_deps, dependencies);
}
break;
@@ -178,19 +176,14 @@ gtk_css_color_value_resolve_full (GtkCssValue *color,
GtkHSLA hsla;
GdkRGBA shade;
val = gtk_css_color_value_resolve_full (color->sym_col.shade.color, provider, current, current_deps, dependencies);
val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, current_deps, dependencies);
if (val == NULL)
return NULL;
*dependencies = _gtk_css_dependencies_union (*dependencies, 0);
_gtk_hsla_init_from_rgba (&hsla, _gtk_css_rgba_value_get_rgba (val));
hsla.lightness *= color->sym_col.shade.factor;
hsla.lightness = CLAMP (hsla.lightness, 0.0, 1.0);
hsla.saturation *= color->sym_col.shade.factor;
hsla.saturation = CLAMP (hsla.saturation, 0.0, 1.0);
_gtk_hsla_shade (&hsla, &hsla, color->sym_col.shade.factor);
_gdk_rgba_init_from_hsla (&shade, &hsla);
@@ -205,7 +198,7 @@ gtk_css_color_value_resolve_full (GtkCssValue *color,
GtkCssValue *val;
GdkRGBA alpha;
val = gtk_css_color_value_resolve_full (color->sym_col.alpha.color, provider, current, current_deps, dependencies);
val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, current_deps, dependencies);
if (val == NULL)
return NULL;
@@ -225,13 +218,13 @@ gtk_css_color_value_resolve_full (GtkCssValue *color,
GdkRGBA color1, color2, res;
GtkCssDependencies dep1, dep2;
val = gtk_css_color_value_resolve_full (color->sym_col.mix.color1, provider, current, current_deps, &dep1);
val = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, current_deps, &dep1);
if (val == NULL)
return NULL;
color1 = *_gtk_css_rgba_value_get_rgba (val);
_gtk_css_value_unref (val);
val = gtk_css_color_value_resolve_full (color->sym_col.mix.color2, provider, current, current_deps, &dep2);
val = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, current_deps, &dep2);
if (val == NULL)
return NULL;
color2 = *_gtk_css_rgba_value_get_rgba (val);
@@ -329,11 +322,11 @@ gtk_css_value_color_compute (GtkCssValue *value,
current_deps = GTK_CSS_DEPENDS_ON_COLOR;
}
resolved = gtk_css_color_value_resolve_full (value,
provider,
current,
current_deps,
dependencies);
resolved = _gtk_css_color_value_resolve (value,
provider,
current,
current_deps,
dependencies);
if (resolved == NULL)
return gtk_css_value_color_get_fallback (property_id, provider, values, parent_values);
+6
View File
@@ -43,6 +43,12 @@ GtkCssValue * _gtk_css_color_value_new_current_color (void);
GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies);
G_END_DECLS
+17 -15
View File
@@ -19,6 +19,7 @@
#include "config.h"
#include "gtkprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssanimationprivate.h"
@@ -120,9 +121,9 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkCssDependencies dependencies;
GtkCssValue *value;
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
g_return_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values));
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
gtk_internal_return_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values));
/* http://www.w3.org/TR/css3-cascade/#cascade
* Then, for every element, the value for each property can be found
@@ -154,8 +155,8 @@ _gtk_css_computed_values_set_animated_value (GtkCssComputedValues *values,
guint id,
GtkCssValue *value)
{
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (value != NULL);
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
gtk_internal_return_if_fail (value != NULL);
if (values->animated_values == NULL)
values->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
@@ -175,10 +176,11 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
GtkCssDependencies dependencies,
GtkCssSection *section)
{
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
gtk_internal_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);
values->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (),
(GDestroyNotify)_gtk_css_value_unref);
if (id >= values->values->len)
g_ptr_array_set_size (values->values, id + 1);
@@ -216,7 +218,7 @@ GtkCssValue *
_gtk_css_computed_values_get_value (GtkCssComputedValues *values,
guint id)
{
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->animated_values &&
id < values->animated_values->len &&
@@ -230,7 +232,7 @@ GtkCssValue *
_gtk_css_computed_values_get_intrinsic_value (GtkCssComputedValues *values,
guint id)
{
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->values == NULL ||
id >= values->values->len)
@@ -243,7 +245,7 @@ GtkCssSection *
_gtk_css_computed_values_get_section (GtkCssComputedValues *values,
guint id)
{
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->sections == NULL ||
id >= values->sections->len)
@@ -528,8 +530,8 @@ _gtk_css_computed_values_advance (GtkCssComputedValues *values,
GSList *list;
guint i;
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (timestamp >= values->current_time, NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (timestamp >= values->current_time, NULL);
values->current_time = timestamp;
old_computed_values = values->animated_values;
@@ -578,7 +580,7 @@ _gtk_css_computed_values_is_static (GtkCssComputedValues *values)
{
GSList *list;
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), TRUE);
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), TRUE);
for (list = values->animations; list; list = list->next)
{
@@ -592,7 +594,7 @@ _gtk_css_computed_values_is_static (GtkCssComputedValues *values)
void
_gtk_css_computed_values_cancel_animations (GtkCssComputedValues *values)
{
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
if (values->animated_values)
{
@@ -610,7 +612,7 @@ _gtk_css_computed_values_compute_dependencies (GtkCssComputedValues *values,
{
GtkBitmask *changes;
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), _gtk_bitmask_new ());
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), _gtk_bitmask_new ());
changes = _gtk_bitmask_copy (parent_changes);
changes = _gtk_bitmask_intersect (changes, values->depends_on_parent);
+13
View File
@@ -28,16 +28,22 @@
#include "gtkstylepropertiesprivate.h"
#include "gtkthemingengine.h"
#include "deprecated/gtksymboliccolor.h"
G_DEFINE_TYPE (GtkCssCustomProperty, _gtk_css_custom_property, GTK_TYPE_CSS_STYLE_PROPERTY)
static GType
gtk_css_custom_property_get_specified_type (GParamSpec *pspec)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (pspec->value_type == GDK_TYPE_RGBA ||
pspec->value_type == GDK_TYPE_COLOR)
return GTK_TYPE_SYMBOLIC_COLOR;
else
return pspec->value_type;
G_GNUC_END_IGNORE_DEPRECATIONS;
}
static GtkCssValue *
@@ -205,6 +211,8 @@ gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
* </note>
*
* Since: 3.0
*
* Deprecated: 3.8: Code should use the default properties provided by CSS.
**/
void
gtk_theming_engine_register_property (const gchar *name_space,
@@ -254,6 +262,8 @@ gtk_theming_engine_register_property (const gchar *name_space,
* a theming engine, you want to use that function instead.
*
* Since: 3.0
*
* Deprecated: 3.8: Code should use the default properties provided by CSS.
**/
void
gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
@@ -297,6 +307,9 @@ gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
* Returns: %TRUE if the property is registered, %FALSE otherwise
*
* Since: 3.0
*
* Deprecated: 3.8: This code could only look up custom properties and
* those are deprecated.
**/
gboolean
gtk_style_properties_lookup_property (const gchar *property_name,
+148 -1
View File
@@ -19,7 +19,9 @@
#include "gtkcssenumvalueprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkstyleproviderprivate.h"
/* repeated API */
@@ -124,6 +126,151 @@ _gtk_css_border_style_value_get (const GtkCssValue *value)
return value->value;
}
/* GtkCssFontSize */
/* XXX: Kinda bad to have that machinery here, nobody expects vital font
* size code to appear in gtkcssvalueenum.c.
*/
#define DEFAULT_FONT_SIZE 10
double
_gtk_css_font_size_get_default (GtkStyleProviderPrivate *provider)
{
GtkSettings *settings;
PangoFontDescription *description;
char *font_name;
double font_size;
settings = _gtk_style_provider_private_get_settings (provider);
if (settings == NULL)
return DEFAULT_FONT_SIZE;
g_object_get (settings, "gtk-font-name", &font_name, NULL);
description = pango_font_description_from_string (font_name);
g_free (font_name);
if (description == NULL)
return DEFAULT_FONT_SIZE;
if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_SIZE)
font_size = (double) pango_font_description_get_size (description) / PANGO_SCALE;
else
font_size = DEFAULT_FONT_SIZE;
pango_font_description_free (description);
return font_size;
}
static GtkCssValue *
gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
{
double font_size;
switch (value->value)
{
case GTK_CSS_FONT_SIZE_XX_SMALL:
font_size = _gtk_css_font_size_get_default (provider) * 3. / 5;
break;
case GTK_CSS_FONT_SIZE_X_SMALL:
font_size = _gtk_css_font_size_get_default (provider) * 3. / 4;
break;
case GTK_CSS_FONT_SIZE_SMALL:
font_size = _gtk_css_font_size_get_default (provider) * 8. / 9;
break;
default:
g_assert_not_reached ();
/* fall thru */
case GTK_CSS_FONT_SIZE_MEDIUM:
font_size = _gtk_css_font_size_get_default (provider);
break;
case GTK_CSS_FONT_SIZE_LARGE:
font_size = _gtk_css_font_size_get_default (provider) * 6. / 5;
break;
case GTK_CSS_FONT_SIZE_X_LARGE:
font_size = _gtk_css_font_size_get_default (provider) * 3. / 2;
break;
case GTK_CSS_FONT_SIZE_XX_LARGE:
font_size = _gtk_css_font_size_get_default (provider) * 2;
break;
case GTK_CSS_FONT_SIZE_SMALLER:
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
font_size = _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
font_size = _gtk_css_font_size_get_default (provider);
/* XXX: This is what WebKit does... */
font_size /= 1.2;
break;
case GTK_CSS_FONT_SIZE_LARGER:
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
font_size = _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
font_size = _gtk_css_font_size_get_default (provider);
/* XXX: This is what WebKit does... */
font_size *= 1.2;
break;
}
return _gtk_css_number_value_new (font_size, GTK_CSS_PX);
}
static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
gtk_css_value_enum_free,
gtk_css_value_font_size_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
};
static GtkCssValue font_size_values[] = {
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_LARGER, "larger" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_SMALL, "small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_LARGE, "large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
};
GtkCssValue *
_gtk_css_font_size_value_new (GtkCssFontSize font_size)
{
g_return_val_if_fail (font_size < G_N_ELEMENTS (font_size_values), NULL);
return _gtk_css_value_ref (&font_size_values[font_size]);
}
GtkCssValue *
_gtk_css_font_size_value_try_parse (GtkCssParser *parser)
{
guint i;
g_return_val_if_fail (parser != NULL, NULL);
for (i = 0; i < G_N_ELEMENTS (font_size_values); i++)
{
if (_gtk_css_parser_try (parser, font_size_values[i].name, TRUE))
return _gtk_css_value_ref (&font_size_values[i]);
}
return NULL;
}
GtkCssFontSize
_gtk_css_font_size_value_get (const GtkCssValue *value)
{
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_FONT_SIZE, GTK_CSS_FONT_SIZE_MEDIUM);
return value->value;
}
/* PangoStyle */
static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
+5
View File
@@ -31,6 +31,11 @@ GtkCssValue * _gtk_css_border_style_value_new (GtkBorderStyle border
GtkCssValue * _gtk_css_border_style_value_try_parse (GtkCssParser *parser);
GtkBorderStyle _gtk_css_border_style_value_get (const GtkCssValue *value);
GtkCssValue * _gtk_css_font_size_value_new (GtkCssFontSize size);
GtkCssValue * _gtk_css_font_size_value_try_parse (GtkCssParser *parser);
GtkCssFontSize _gtk_css_font_size_value_get (const GtkCssValue *value);
double _gtk_css_font_size_get_default (GtkStyleProviderPrivate *provider);
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);
+6 -3
View File
@@ -19,11 +19,14 @@
#include "config.h"
#define GDK_DISABLE_DEPRECATION_WARNINGS
#include "gtkcssimagegradientprivate.h"
#include "gtkcssprovider.h"
#include "gtkgradientprivate.h"
#include "gtksymboliccolorprivate.h"
#include "deprecated/gtkgradientprivate.h"
#include "deprecated/gtksymboliccolorprivate.h"
G_DEFINE_TYPE (GtkCssImageGradient, _gtk_css_image_gradient, GTK_TYPE_CSS_IMAGE)
@@ -474,7 +477,7 @@ _gtk_gradient_parse (GtkCssParser *parser)
return NULL;
}
color = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
color = _gtk_css_symbolic_value_new (parser);
if (color == NULL)
{
gtk_gradient_unref (gradient);
+1 -1
View File
@@ -22,7 +22,7 @@
#include "gtk/gtkcssimageprivate.h"
#include <gtk/gtkgradient.h>
#include <gtk/deprecated/gtkgradient.h>
G_BEGIN_DECLS
+2 -2
View File
@@ -19,7 +19,7 @@
#include "gtkcssinheritvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcssinitialvalueprivate.h"
#include "gtkstylecontextprivate.h"
struct _GtkCssValue {
@@ -48,7 +48,7 @@ gtk_css_value_inherit_compute (GtkCssValue *value,
}
else
{
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
return _gtk_css_value_compute (_gtk_css_initial_value_get (),
property_id,
provider,
values,
+43
View File
@@ -19,7 +19,11 @@
#include "gtkcssinitialvalueprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
@@ -40,6 +44,39 @@ gtk_css_value_initial_compute (GtkCssValue *value,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
{
GtkSettings *settings;
switch (property_id)
{
case GTK_CSS_PROPERTY_FONT_FAMILY:
settings = _gtk_style_provider_private_get_settings (provider);
if (settings)
{
PangoFontDescription *description;
char *font_name;
GtkCssValue *value;
g_object_get (settings, "gtk-font-name", &font_name, NULL);
description = pango_font_description_from_string (font_name);
g_free (font_name);
if (description == NULL)
break;
if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_FAMILY)
{
value = _gtk_css_array_value_new (_gtk_css_string_value_new (pango_font_description_get_family (description)));
pango_font_description_free (description);
return value;
}
pango_font_description_free (description);
}
break;
default:
break;
}
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
@@ -86,3 +123,9 @@ _gtk_css_initial_value_new (void)
{
return _gtk_css_value_ref (&initial);
}
GtkCssValue *
_gtk_css_initial_value_get (void)
{
return &initial;
}
+1
View File
@@ -25,6 +25,7 @@
G_BEGIN_DECLS
GtkCssValue * _gtk_css_initial_value_new (void);
GtkCssValue * _gtk_css_initial_value_get (void);
G_END_DECLS
+14 -13
View File
@@ -62,13 +62,11 @@ gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher)
}
static gboolean
gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher,
const char *name)
gtk_css_matcher_widget_path_has_type (const GtkCssMatcher *matcher,
GType type)
{
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);
@@ -179,12 +177,13 @@ 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_type,
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,
FALSE
};
gboolean
@@ -235,8 +234,8 @@ gtk_css_matcher_any_get_state (const GtkCssMatcher *matcher)
}
static gboolean
gtk_css_matcher_any_has_name (const GtkCssMatcher *matcher,
const char *name)
gtk_css_matcher_any_has_type (const GtkCssMatcher *matcher,
GType type)
{
return TRUE;
}
@@ -282,12 +281,13 @@ 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_type,
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,
TRUE
};
void
@@ -330,11 +330,11 @@ gtk_css_matcher_superset_get_state (const GtkCssMatcher *matcher)
}
static gboolean
gtk_css_matcher_superset_has_name (const GtkCssMatcher *matcher,
const char *name)
gtk_css_matcher_superset_has_type (const GtkCssMatcher *matcher,
GType type)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
return _gtk_css_matcher_has_name (matcher->superset.subset, name);
return _gtk_css_matcher_has_type (matcher->superset.subset, type);
else
return TRUE;
}
@@ -400,12 +400,13 @@ 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_type,
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,
FALSE
};
void
+12 -5
View File
@@ -36,8 +36,8 @@ struct _GtkCssMatcherClass {
const GtkCssMatcher *next);
GtkStateFlags (* get_state) (const GtkCssMatcher *matcher);
gboolean (* has_name) (const GtkCssMatcher *matcher,
const char *name);
gboolean (* has_type) (const GtkCssMatcher *matcher,
GType type);
gboolean (* has_class) (const GtkCssMatcher *matcher,
GQuark class_name);
gboolean (* has_id) (const GtkCssMatcher *matcher,
@@ -50,6 +50,7 @@ struct _GtkCssMatcherClass {
gboolean forward,
int a,
int b);
gboolean is_any;
};
struct _GtkCssMatcherWidgetPath {
@@ -102,10 +103,10 @@ _gtk_css_matcher_get_state (const GtkCssMatcher *matcher)
}
static inline gboolean
_gtk_css_matcher_has_name (const GtkCssMatcher *matcher,
const char *name)
_gtk_css_matcher_has_type (const GtkCssMatcher *matcher,
GType type)
{
return matcher->klass->has_name (matcher, name);
return matcher->klass->has_type (matcher, type);
}
static inline gboolean
@@ -146,6 +147,12 @@ _gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
return matcher->klass->has_position (matcher, forward, a, b);
}
static inline gboolean
_gtk_css_matcher_matches_any (const GtkCssMatcher *matcher)
{
return matcher->klass->is_any;
}
G_END_DECLS
+28 -4
View File
@@ -20,6 +20,7 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
#include "gtkstylepropertyprivate.h"
struct _GtkCssValue {
@@ -34,6 +35,26 @@ gtk_css_value_number_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
static double
get_base_font_size (guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
{
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
{
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
return _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
return _gtk_css_font_size_get_default (provider);
}
*dependencies = GTK_CSS_DEPENDS_ON_FONT_SIZE;
return _gtk_css_number_value_get (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
}
static GtkCssValue *
gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
@@ -48,6 +69,11 @@ gtk_css_value_number_compute (GtkCssValue *number,
g_assert_not_reached();
/* fall through */
case GTK_CSS_PERCENT:
/* percentages for font sizes are computed, other percentages aren't */
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
return _gtk_css_number_value_new (number->value / 100.0 *
get_base_font_size (property_id, provider, values, parent_values, dependencies),
GTK_CSS_PX);
case GTK_CSS_NUMBER:
case GTK_CSS_PX:
case GTK_CSS_DEG:
@@ -73,16 +99,14 @@ gtk_css_value_number_compute (GtkCssValue *number,
GTK_CSS_PX);
break;
case GTK_CSS_EM:
*dependencies = GTK_CSS_DEPENDS_ON_FONT_SIZE;
return _gtk_css_number_value_new (number->value *
_gtk_css_number_value_get (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_FONT_SIZE), 100),
get_base_font_size (property_id, provider, values, parent_values, dependencies),
GTK_CSS_PX);
break;
case GTK_CSS_EX:
/* for now we pretend ex is half of em */
*dependencies = GTK_CSS_DEPENDS_ON_FONT_SIZE;
return _gtk_css_number_value_new (number->value * 0.5 *
_gtk_css_number_value_get (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_FONT_SIZE), 100),
get_base_font_size (property_id, provider, values, parent_values, dependencies),
GTK_CSS_PX);
case GTK_CSS_RAD:
return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),
+1 -1
View File
@@ -257,7 +257,7 @@ gtk_css_parser_skip_comment (GtkCssParser *parser)
parser->data++;
if (parser->data[-2] == '*')
if (len > 0 && parser->data[-2] == '*')
return TRUE;
if (parser->data[0] == '*')
_gtk_css_parser_error (parser, "'/*' in comment block");
+121 -527
View File
@@ -27,13 +27,13 @@
#include "gtkbitmaskprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcsskeyframesprivate.h"
#include "gtkcssparserprivate.h"
#include "gtkcsssectionprivate.h"
#include "gtkcssselectorprivate.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtkcssstylefuncsprivate.h"
#include "gtksymboliccolor.h"
#include "gtkstyleprovider.h"
#include "gtkstylecontextprivate.h"
#include "gtkstylepropertiesprivate.h"
@@ -986,6 +986,7 @@ struct _WidgetPropertyValue {
struct GtkCssRuleset
{
GtkCssSelector *selector;
GtkCssSelectorTree *selector_match;
WidgetPropertyValue *widget_style;
PropertyValue *styles;
GtkBitmask *set_styles;
@@ -994,37 +995,6 @@ struct GtkCssRuleset
guint owns_widget_style : 1;
};
enum RulesetsTreeType {
RULESETS_TREE_TYPE_STATE,
RULESETS_TREE_TYPE_CLASS,
RULESETS_TREE_TYPE_RULES
};
typedef struct _GtkCssRulesetList GtkCssRulesetList;
typedef struct _GtkCssRulesetsTree GtkCssRulesetsTree;
struct _GtkCssRulesetList {
guint *rules;
guint num_rules;
};
struct _GtkCssRulesetsTree
{
enum RulesetsTreeType type;
union {
GtkCssRulesetList rules;
struct {
GtkCssRulesetsTree *matched;
GtkStateFlags state;
} state;
struct {
GtkCssRulesetsTree *matched;
GQuark class;
} class;
} u;
GtkCssRulesetsTree *next;
};
struct _GtkCssScanner
{
GtkCssProvider *provider;
@@ -1042,8 +1012,7 @@ struct _GtkCssProviderPrivate
GHashTable *keyframes;
GArray *rulesets;
guint *rulesets_refs;
GtkCssRulesetsTree *rulesets_tree;
GtkCssSelectorTree *tree;
GResource *resource;
};
@@ -1060,7 +1029,6 @@ static void gtk_css_provider_finalize (GObject *object);
static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface);
static void gtk_css_style_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface);
static void widget_property_value_list_free (WidgetPropertyValue *head);
static void gtk_css_rulesets_tree_free (GtkCssRulesetsTree *tree);
static gboolean
gtk_css_provider_load_internal (GtkCssProvider *css_provider,
@@ -1305,19 +1273,6 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
ruleset->styles[i].section = NULL;
}
static gboolean
gtk_css_ruleset_matches (GtkCssRuleset *ruleset,
const GtkCssMatcher *matcher)
{
return _gtk_css_selector_matches (ruleset->selector, matcher);
}
static GtkCssChange
gtk_css_ruleset_get_change (GtkCssRuleset *ruleset)
{
return _gtk_css_selector_get_change (ruleset->selector);
}
static void
gtk_css_scanner_destroy (GtkCssScanner *scanner)
{
@@ -1437,75 +1392,92 @@ gtk_css_provider_init (GtkCssProvider *css_provider)
priv->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) gtk_symbolic_color_unref);
(GDestroyNotify) _gtk_css_value_unref);
priv->keyframes = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) _gtk_css_value_unref);
}
static void
css_provider_dump_symbolic_colors (GtkCssProvider *css_provider,
GtkStyleProperties *props)
verify_tree_match_results (GtkCssProvider *provider,
const GtkCssMatcher *matcher,
GPtrArray *tree_rules)
{
GtkCssProviderPrivate *priv;
GHashTableIter iter;
gpointer key, value;
#ifdef VERIFY_TREE
GtkCssProviderPrivate *priv = provider->priv;
GtkCssRuleset *ruleset;
gboolean should_match;
int i, j;
priv = css_provider->priv;
g_hash_table_iter_init (&iter, priv->symbolic_colors);
while (g_hash_table_iter_next (&iter, &key, &value))
for (i = 0; i < priv->rulesets->len; i++)
{
const gchar *name;
GtkSymbolicColor *color;
gboolean found = FALSE;
name = key;
color = value;
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
gtk_style_properties_map_color (props, name, color);
for (j = 0; j < tree_rules->len; j++)
{
if (ruleset == tree_rules->pdata[j])
{
found = TRUE;
break;
}
}
should_match = _gtk_css_selector_matches (ruleset->selector, matcher);
if (found != !!should_match)
{
g_error ("expected rule '%s' to %s, but it %s\n",
_gtk_css_selector_to_string (ruleset->selector),
should_match ? "match" : "not match",
found ? "matched" : "didn't match");
}
}
#endif
}
static GtkStyleProperties *
gtk_css_provider_get_style (GtkStyleProvider *provider,
GtkWidgetPath *path)
static void
verify_tree_get_change_results (GtkCssProvider *provider,
const GtkCssMatcher *matcher,
GtkCssChange change)
{
GtkCssMatcher matcher;
GtkCssProvider *css_provider;
GtkCssProviderPrivate *priv;
GtkStyleProperties *props;
guint i, j;
#ifdef VERIFY_TREE
{
GtkCssChange verify_change = 0;
GPtrArray *tree_rules;
int i;
css_provider = GTK_CSS_PROVIDER (provider);
priv = css_provider->priv;
props = gtk_style_properties_new ();
tree_rules = _gtk_css_selector_tree_match_all (provider->priv->tree, matcher);
verify_tree_match_results (provider, matcher, tree_rules);
css_provider_dump_symbolic_colors (css_provider, props);
if (_gtk_css_matcher_init (&matcher, path, 0))
{
for (i = 0; i < priv->rulesets->len; i++)
{
GtkCssRuleset *ruleset;
for (i = tree_rules->len - 1; i >= 0; i--)
{
GtkCssRuleset *ruleset;
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
ruleset = tree_rules->pdata[i];
if (ruleset->styles == NULL)
continue;
verify_change |= _gtk_css_selector_tree_match_get_change (ruleset->selector_match);
}
if (!gtk_css_ruleset_matches (ruleset, &matcher))
continue;
if (change != verify_change)
{
GString *s;
for (j = 0; j < ruleset->n_styles; j++)
_gtk_style_properties_set_property_by_property (props,
GTK_CSS_STYLE_PROPERTY (ruleset->styles[i].property),
_gtk_css_selector_get_state_flags (ruleset->selector),
ruleset->styles[i].value);
}
}
s = g_string_new ("");
g_string_append_printf (s, "expected change 0x%x, but it was 0x%x", verify_change, change);
if ((change & ~verify_change) != 0)
g_string_append_printf (s, ", unexpectedly set: 0x%x", change & ~verify_change);
if ((~change & verify_change) != 0)
g_string_append_printf (s, ", unexpectedly no set: 0x%x", ~change & verify_change);
g_warning (s->str);
g_string_free (s, TRUE);
}
return props;
g_ptr_array_free (tree_rules, TRUE);
}
#endif
}
static gboolean
gtk_css_provider_get_style_property (GtkStyleProvider *provider,
GtkWidgetPath *path,
@@ -1516,6 +1488,7 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
GtkCssProvider *css_provider = GTK_CSS_PROVIDER (provider);
GtkCssProviderPrivate *priv = css_provider->priv;
WidgetPropertyValue *val;
GPtrArray *tree_rules;
GtkCssMatcher matcher;
gboolean found = FALSE;
gchar *prop_name;
@@ -1524,22 +1497,20 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
if (!_gtk_css_matcher_init (&matcher, path, state))
return FALSE;
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, &matcher);
verify_tree_match_results (css_provider, &matcher, tree_rules);
prop_name = g_strdup_printf ("-%s-%s",
g_type_name (pspec->owner_type),
pspec->name);
for (i = priv->rulesets->len - 1; i >= 0; i--)
for (i = tree_rules->len - 1; i >= 0; i--)
{
GtkCssRuleset *ruleset;
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
GtkCssRuleset *ruleset = tree_rules->pdata[i];
if (ruleset->widget_style == NULL)
continue;
if (!gtk_css_ruleset_matches (ruleset, &matcher))
continue;
for (val = ruleset->widget_style; val != NULL; val = val->next)
{
if (strcmp (val->name, prop_name) == 0)
@@ -1566,6 +1537,7 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
}
g_free (prop_name);
g_ptr_array_free (tree_rules, TRUE);
return found;
}
@@ -1573,11 +1545,10 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
static void
gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface)
{
iface->get_style = gtk_css_provider_get_style;
iface->get_style_property = gtk_css_provider_get_style_property;
}
static GtkSymbolicColor *
static GtkCssValue *
gtk_css_style_provider_get_color (GtkStyleProviderPrivate *provider,
const char *name)
{
@@ -1595,117 +1566,6 @@ gtk_css_style_provider_get_keyframes (GtkStyleProviderPrivate *provider,
return g_hash_table_lookup (css_provider->priv->keyframes, name);
}
static void
collect_possible_rules (GPtrArray *rules_lists,
GtkCssRulesetsTree *tree,
const GtkCssMatcher *matcher)
{
if (tree == NULL)
return;
switch (tree->type)
{
case RULESETS_TREE_TYPE_RULES:
g_ptr_array_add (rules_lists, &tree->u.rules);
break;
case RULESETS_TREE_TYPE_STATE:
if ((_gtk_css_matcher_get_state (matcher) & tree->u.state.state) == tree->u.state.state)
collect_possible_rules (rules_lists,
tree->u.state.matched,
matcher);
break;
case RULESETS_TREE_TYPE_CLASS:
if (_gtk_css_matcher_has_class (matcher, tree->u.class.class))
collect_possible_rules (rules_lists,
tree->u.class.matched,
matcher);
break;
}
collect_possible_rules (rules_lists,
tree->next,
matcher);
}
/* Merged two pre-sorted arrays of uints, assumes enough space in destination to fit a_len + b_len */
static void
merge_uints (guint *dest, const guint *a, int a_len, const guint* b, int b_len)
{
const guint *a_end = a + a_len;
const guint *b_end = b + b_len;
while (a != a_end ||
b != b_end)
{
if (a == a_end)
{
memcpy (dest, b, sizeof (guint) * (b_end - b));
break;
}
else if (b == b_end)
{
memcpy (dest, a, sizeof (guint) * (a_end - a));
break;
}
else if (*a <= *b)
*dest++ = *a++;
else
*dest++ = *b++;
}
}
static guint *
find_possible_rules (GtkCssRulesetsTree *tree,
const GtkCssMatcher *matcher,
guint *num_refs_out)
{
GPtrArray *rules_lists;
gint i;
guint *merged, *tmp_refs, *swap_ptr;
guint merged_size;
guint num_refs;
/* Collect all possible rules from the tree */
rules_lists = g_ptr_array_new ();
collect_possible_rules (rules_lists, tree, matcher);
/* Merge the separate sorted lists into one list */
num_refs = 0;
for (i = 0; i < rules_lists->len; i++)
{
GtkCssRulesetList *list = (GtkCssRulesetList *)rules_lists->pdata[i];
num_refs += list->num_rules;
}
merged = g_new (guint, num_refs);
merged_size = 0;
tmp_refs = g_new (guint, num_refs);
/* Merge the already sorted refs list */
for (i = 0; i < rules_lists->len; i++)
{
GtkCssRulesetList *list = (GtkCssRulesetList *)rules_lists->pdata[i];
if (i == 0)
memcpy (merged, list->rules, sizeof (*list->rules) * list->num_rules);
else
{
merge_uints (tmp_refs, merged, merged_size, list->rules, list->num_rules);
swap_ptr = merged;
merged = tmp_refs;
tmp_refs = swap_ptr;
}
merged_size += list->num_rules;
}
g_free (tmp_refs);
g_ptr_array_free (rules_lists, TRUE);
*num_refs_out = num_refs;
return merged;
}
static void
gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
@@ -1715,23 +1575,18 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
GtkCssProviderPrivate *priv;
GtkCssRuleset *ruleset;
guint j;
gint i;
guint *refs;
guint num_refs;
int i;
GPtrArray *tree_rules;
css_provider = GTK_CSS_PROVIDER (provider);
priv = css_provider->priv;
if (priv->rulesets->len == 0)
return;
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, matcher);
verify_tree_match_results (css_provider, matcher, tree_rules);
refs = find_possible_rules (priv->rulesets_tree, matcher, &num_refs);
if (num_refs == 0)
return;
for (i = num_refs - 1; i >= 0; i--)
for (i = tree_rules->len - 1; i >= 0; i--)
{
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, refs[i]);
ruleset = tree_rules->pdata[i];
if (ruleset->styles == NULL)
continue;
@@ -1740,9 +1595,6 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
ruleset->set_styles))
continue;
if (!gtk_css_ruleset_matches (ruleset, matcher))
continue;
for (j = 0; j < ruleset->n_styles; j++)
{
GtkCssStyleProperty *prop = ruleset->styles[j].property;
@@ -1761,7 +1613,7 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
break;
}
g_free (refs);
g_ptr_array_free (tree_rules, TRUE);
}
static GtkCssChange
@@ -1770,34 +1622,14 @@ gtk_css_style_provider_get_change (GtkStyleProviderPrivate *provider,
{
GtkCssProvider *css_provider;
GtkCssProviderPrivate *priv;
GtkCssChange change = 0;
int i;
guint *refs;
guint num_refs;
GtkCssChange change;
css_provider = GTK_CSS_PROVIDER (provider);
priv = css_provider->priv;
refs = find_possible_rules (priv->rulesets_tree, matcher, &num_refs);
if (num_refs == 0)
return change;
change = _gtk_css_selector_tree_get_change_all (priv->tree, matcher);
for (i = num_refs - 1; i >= 0; i--)
{
GtkCssRuleset *ruleset;
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, refs[i]);
if (ruleset->styles == NULL)
continue;
if (!gtk_css_ruleset_matches (ruleset, matcher))
continue;
change |= gtk_css_ruleset_get_change (ruleset);
}
g_free (refs);
verify_tree_get_change_results (css_provider, matcher, change);
return change;
}
@@ -1825,8 +1657,7 @@ gtk_css_provider_finalize (GObject *object)
gtk_css_ruleset_clear (&g_array_index (priv->rulesets, GtkCssRuleset, i));
g_array_free (priv->rulesets, TRUE);
g_free (priv->rulesets_refs);
gtk_css_rulesets_tree_free (priv->rulesets_tree);
_gtk_css_selector_tree_free (priv->tree);
g_hash_table_destroy (priv->symbolic_colors);
g_hash_table_destroy (priv->keyframes);
@@ -1961,14 +1792,12 @@ gtk_css_provider_reset (GtkCssProvider *css_provider)
g_hash_table_remove_all (priv->symbolic_colors);
g_hash_table_remove_all (priv->keyframes);
g_free (priv->rulesets_refs);
priv->rulesets_refs = NULL;
gtk_css_rulesets_tree_free (priv->rulesets_tree);
priv->rulesets_tree = NULL;
for (i = 0; i < priv->rulesets->len; i++)
gtk_css_ruleset_clear (&g_array_index (priv->rulesets, GtkCssRuleset, i));
g_array_set_size (priv->rulesets, 0);
_gtk_css_selector_tree_free (priv->tree);
priv->tree = NULL;
}
static void
@@ -2071,7 +1900,7 @@ parse_import (GtkCssScanner *scanner)
static gboolean
parse_color_definition (GtkCssScanner *scanner)
{
GtkCssValue *symbolic;
GtkCssValue *color;
char *name;
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
@@ -2095,8 +1924,8 @@ parse_color_definition (GtkCssScanner *scanner)
return TRUE;
}
symbolic = _gtk_css_symbolic_value_new (scanner->parser);
if (symbolic == NULL)
color = _gtk_css_color_value_parse (scanner->parser);
if (color == NULL)
{
g_free (name);
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
@@ -2107,7 +1936,7 @@ parse_color_definition (GtkCssScanner *scanner)
if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
{
g_free (name);
_gtk_css_value_unref (symbolic);
_gtk_css_value_unref (color);
gtk_css_provider_error_literal (scanner->provider,
scanner,
GTK_CSS_PROVIDER_ERROR,
@@ -2119,7 +1948,7 @@ parse_color_definition (GtkCssScanner *scanner)
return TRUE;
}
g_hash_table_insert (scanner->provider->priv->symbolic_colors, name, symbolic);
g_hash_table_insert (scanner->provider->priv->symbolic_colors, name, color);
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
return TRUE;
@@ -2599,274 +2428,42 @@ gtk_css_provider_compare_rule (gconstpointer a_,
return 0;
}
static void
gtk_css_rulesets_tree_free (GtkCssRulesetsTree *tree)
{
if (tree == NULL)
return;
switch (tree->type)
{
case RULESETS_TREE_TYPE_RULES:
break;
case RULESETS_TREE_TYPE_STATE:
gtk_css_rulesets_tree_free (tree->u.state.matched);
break;
case RULESETS_TREE_TYPE_CLASS:
gtk_css_rulesets_tree_free (tree->u.class.matched);
break;
}
gtk_css_rulesets_tree_free (tree->next);
}
static gint
compare_refs_by_val (gconstpointer pa,
gconstpointer pb,
gpointer user_data)
{
guint a = *(guint *)pa;
guint b = *(guint *)pb;
return a - b;
}
static GtkCssRulesetsTree *
subdivide_by_none (GtkCssProviderPrivate *priv, guint *refs, guint start, guint end)
{
GtkCssRulesetsTree *tree;
tree = g_new0 (GtkCssRulesetsTree, 1);
tree->type = RULESETS_TREE_TYPE_RULES;
tree->u.rules.rules = refs + start;
tree->u.rules.num_rules = end - start;
tree->next = NULL;
/* Sort by rule index (i.e. css prio order) */
g_qsort_with_data (tree->u.rules.rules,
tree->u.rules.num_rules,
sizeof (guint),
compare_refs_by_val,
NULL);
return tree;
}
typedef struct {
GQuark class;
guint count;
} GtkCssPseudoClassCount;
static gint
compare_class_count (gconstpointer pa,
gconstpointer pb,
gpointer user_data)
{
GtkCssPseudoClassCount *a = (GtkCssPseudoClassCount *)pa;
GtkCssPseudoClassCount *b = (GtkCssPseudoClassCount *)pb;
return b->count - a->count;
}
static GtkCssRulesetsTree *
subdivide_by_class (GtkCssProviderPrivate *priv, guint *refs, guint start, guint end)
{
GHashTable *count_ht;
GHashTableIter iter;
guint i, j, n_classes;
gpointer key, value;
GtkCssPseudoClassCount *class_count;
GtkCssRulesetsTree *tree;
GtkCssRulesetsTree *trees = NULL;
count_ht = g_hash_table_new (g_direct_hash, g_direct_equal);
for (i = start; i < end; i++)
{
GtkCssSelector *selector = g_array_index (priv->rulesets, GtkCssRuleset, refs[i]).selector;
GQuark *classes = _gtk_css_selector_get_primary_classes (selector);
for (j = 0; classes[j] != 0; j++)
{
guint count = GPOINTER_TO_INT (g_hash_table_lookup (count_ht, GUINT_TO_POINTER (classes[j])));
g_hash_table_replace (count_ht, GUINT_TO_POINTER (classes[j]), GUINT_TO_POINTER (count + 1));
}
g_free (classes);
}
n_classes = 0;
class_count = g_new (GtkCssPseudoClassCount, g_hash_table_size (count_ht));
g_hash_table_iter_init (&iter, count_ht);
while (g_hash_table_iter_next (&iter, &key, &value))
{
guint count = GPOINTER_TO_UINT (value);
/* Random cuttoff point here. Obviously if any given class has only one item
with it, then adding a check doesn't help, and it uses memory. Where
is the inflexion point? Lets make it 3... */
if (count >= 3)
{
class_count[n_classes].class = GPOINTER_TO_UINT (key);
class_count[n_classes].count = count;
n_classes++;
}
}
g_hash_table_destroy (count_ht);
/* Sort largest class counts first */
g_qsort_with_data (class_count,
n_classes,
sizeof (*class_count),
compare_class_count,
NULL);
for (i = 0; i < n_classes; i++)
{
guint split = start;
for (j = start; j < end; j++)
{
GtkCssSelector *selector = g_array_index (priv->rulesets, GtkCssRuleset, refs[j]).selector;
if (_gtk_css_selector_has_primary_class (selector, class_count[i].class))
{
guint tmp = refs[split];
refs[split] = refs[j];
refs[j] = tmp;
split++;
}
}
/* Check size again sice nodes may have been used in other trees */
if (split - start > 3)
{
tree = g_new (GtkCssRulesetsTree, 1);
tree->type = RULESETS_TREE_TYPE_CLASS;
tree->u.class.matched = subdivide_by_none (priv, refs, start, split);
tree->u.class.class = class_count[i].class;
tree->next = trees;
trees = tree;
start = split;
}
}
g_free (class_count);
if (start != end)
{
tree = subdivide_by_none (priv, refs, start, end);
tree->next = trees;
trees = tree;
}
return trees;
}
static GtkCssRulesetsTree *
subdivide_by_state (GtkCssProviderPrivate *priv, guint *refs, guint start, guint end, guint state)
{
GtkCssRulesetsTree *tree;
guint i;
if (end == start)
return NULL;
if (state == 0)
return subdivide_by_class (priv, refs, start, end);
// Find first non-set flag
for (i = start; i < end; i++)
{
GtkCssSelector *selector = g_array_index (priv->rulesets, GtkCssRuleset, refs[i]).selector;
if ((_gtk_css_selector_get_primary_state_flags (selector) & state) == 0)
break;
}
if (i == start || i == end) /* All or none set, no use subdividing by this */
return subdivide_by_state (priv, refs, start, end, state >> 1);
tree = g_new (GtkCssRulesetsTree, 1);
tree->type = RULESETS_TREE_TYPE_STATE;
tree->u.state.matched = subdivide_by_state (priv, refs, start, i, state >> 1);
tree->u.state.state = state;
tree->next = subdivide_by_state (priv, refs, i, end, state >> 1);
return tree;
}
static gint
compare_refs_by_flags (gconstpointer pa,
gconstpointer pb,
gpointer user_data)
{
guint a = *(guint *)pa;
guint b = *(guint *)pb;
GArray *rulesets = user_data;
GtkCssSelector *selector_a, *selector_b;
guint32 flags_a, flags_b;
selector_a = g_array_index (rulesets, GtkCssRuleset, a).selector;
selector_b = g_array_index (rulesets, GtkCssRuleset, b).selector;
flags_a = _gtk_css_selector_get_primary_state_flags (selector_a);
flags_b = _gtk_css_selector_get_primary_state_flags (selector_b);
return flags_b - flags_a;
}
static void
print_tree (GtkCssRulesetsTree *tree, int indent)
{
if (tree == NULL)
return;
switch (tree->type)
{
case RULESETS_TREE_TYPE_RULES:
printf ("%*sCheck rules %p len %d\n", indent, "", tree->u.rules.rules, tree->u.rules.num_rules);
break;
case RULESETS_TREE_TYPE_STATE:
printf ("%*sMatch state 0x%x ->\n", indent, "", tree->u.state.state);
print_tree (tree->u.state.matched, indent + 4);
break;
case RULESETS_TREE_TYPE_CLASS:
printf ("%*sMatch class %s ->\n", indent, "", g_quark_to_string (tree->u.class.class));
print_tree (tree->u.class.matched, indent + 4);
break;
}
print_tree (tree->next, indent);
}
static void
gtk_css_provider_postprocess (GtkCssProvider *css_provider)
{
GtkCssProviderPrivate *priv = css_provider->priv;
guint *refs, i;
GtkCssSelectorTreeBuilder *builder;
guint i;
g_array_sort (priv->rulesets, gtk_css_provider_compare_rule);
refs = g_new (guint, priv->rulesets->len);
priv->rulesets_refs = refs;
builder = _gtk_css_selector_tree_builder_new ();
for (i = 0; i < priv->rulesets->len; i++)
refs[i] = i;
/* Sort by flags, so that high bits set is sorted first at each level */
g_qsort_with_data (refs,
priv->rulesets->len,
sizeof (guint),
compare_refs_by_flags,
priv->rulesets);
priv->rulesets_tree = subdivide_by_state (priv, refs, 0, priv->rulesets->len, GTK_STATE_FLAG_BACKDROP);
if (g_getenv ("GTK_CSS_DEBUG_TREE"))
{
g_print ("Rulesets tree for proviced %p (%d rules)\n", css_provider, priv->rulesets->len);
print_tree (priv->rulesets_tree, 1);
GtkCssRuleset *ruleset;
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
_gtk_css_selector_tree_builder_add (builder,
ruleset->selector,
&ruleset->selector_match,
ruleset);
}
priv->tree = _gtk_css_selector_tree_builder_build (builder);
_gtk_css_selector_tree_builder_free (builder);
#ifndef VERIFY_TREE
for (i = 0; i < priv->rulesets->len; i++)
{
GtkCssRuleset *ruleset;
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
_gtk_css_selector_free (ruleset->selector);
ruleset->selector = NULL;
}
#endif
}
static gboolean
@@ -3315,7 +2912,7 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
WidgetPropertyValue *widget_value;
guint i;
_gtk_css_selector_print (ruleset->selector, str);
_gtk_css_selector_tree_match_print (ruleset->selector_match, str);
g_string_append (str, " {\n");
@@ -3373,7 +2970,6 @@ gtk_css_provider_print_colors (GHashTable *colors,
GString *str)
{
GList *keys, *walk;
char *s;
keys = g_hash_table_get_keys (colors);
/* so the output is identical for identical styles */
@@ -3382,14 +2978,12 @@ gtk_css_provider_print_colors (GHashTable *colors,
for (walk = keys; walk; walk = walk->next)
{
const char *name = walk->data;
GtkSymbolicColor *symbolic = g_hash_table_lookup (colors, (gpointer) name);
GtkCssValue *color = g_hash_table_lookup (colors, (gpointer) name);
g_string_append (str, "@define-color ");
g_string_append (str, name);
g_string_append (str, " ");
s = gtk_symbolic_color_to_string (symbolic);
g_string_append (str, s);
g_free (s);
_gtk_css_value_print (color, str);
g_string_append (str, ";\n");
}
-1
View File
@@ -21,7 +21,6 @@
#include "gtkcssstylepropertyprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtksymboliccolorprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
+1394 -132
View File
File diff suppressed because it is too large Load Diff
+19 -7
View File
@@ -24,6 +24,8 @@
G_BEGIN_DECLS
typedef struct _GtkCssSelector GtkCssSelector;
typedef struct _GtkCssSelectorTree GtkCssSelectorTree;
typedef struct _GtkCssSelectorTreeBuilder GtkCssSelectorTreeBuilder;
GtkCssSelector * _gtk_css_selector_parse (GtkCssParser *parser);
void _gtk_css_selector_free (GtkCssSelector *selector);
@@ -32,18 +34,28 @@ char * _gtk_css_selector_to_string (const GtkCssSelector *sel
void _gtk_css_selector_print (const GtkCssSelector *selector,
GString *str);
GtkStateFlags _gtk_css_selector_get_state_flags (const GtkCssSelector *selector);
GtkCssChange _gtk_css_selector_get_change (const GtkCssSelector *selector);
gboolean _gtk_css_selector_matches (const GtkCssSelector *selector,
const GtkCssMatcher *matcher);
int _gtk_css_selector_compare (const GtkCssSelector *a,
const GtkCssSelector *b);
GtkStateFlags _gtk_css_selector_get_primary_state_flags (const GtkCssSelector *selector);
GQuark * _gtk_css_selector_get_primary_classes (const GtkCssSelector *selector);
gboolean _gtk_css_selector_has_primary_class (const GtkCssSelector *selector,
GQuark class);
void _gtk_css_selector_tree_free (GtkCssSelectorTree *tree);
GPtrArray * _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher);
GtkCssChange _gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher);
void _gtk_css_selector_tree_match_print (const GtkCssSelectorTree *tree,
GString *str);
GtkCssChange _gtk_css_selector_tree_match_get_change (const GtkCssSelectorTree *tree);
GtkCssSelectorTreeBuilder *_gtk_css_selector_tree_builder_new (void);
void _gtk_css_selector_tree_builder_add (GtkCssSelectorTreeBuilder *builder,
GtkCssSelector *selectors,
GtkCssSelectorTree **selector_match,
gpointer match);
GtkCssSelectorTree * _gtk_css_selector_tree_builder_build (GtkCssSelectorTreeBuilder *builder);
void _gtk_css_selector_tree_builder_free (GtkCssSelectorTreeBuilder *builder);
G_END_DECLS
+3 -3
View File
@@ -565,8 +565,8 @@ parse_background (GtkCssShorthandProperty *shorthand,
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
return FALSE;
}
return FALSE;
}
for (i = 0; i < 6; i++)
@@ -668,8 +668,8 @@ parse_transition (GtkCssShorthandProperty *shorthand,
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
return FALSE;
}
return FALSE;
}
for (i = 0; i < 4; i++)
@@ -784,8 +784,8 @@ parse_animation (GtkCssShorthandProperty *shorthand,
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
return FALSE;
}
return FALSE;
}
for (i = 0; i < 6; i++)
+33 -16
View File
@@ -27,20 +27,21 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo-gobject.h>
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssimagegradientprivate.h"
#include "gtkcssprovider.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkcsstypedvalueprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkgradient.h"
#include "gtkgradientprivate.h"
#include "gtkprivatetypebuiltins.h"
#include "gtkstylecontextprivate.h"
#include "gtksymboliccolorprivate.h"
#include "gtkthemingengine.h"
#include "gtktypebuiltins.h"
#include "gtkwin32themeprivate.h"
#include "deprecated/gtkgradientprivate.h"
#include "deprecated/gtksymboliccolorprivate.h"
/* this is in case round() is not provided by the compiler,
* such as in the case of C89 compilers, like MSVC
*/
@@ -171,7 +172,9 @@ rgba_value_parse (GtkCssParser *parser,
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
symbolic = _gtk_css_symbolic_value_new (parser);
if (symbolic == NULL)
return FALSE;
@@ -187,6 +190,8 @@ rgba_value_parse (GtkCssParser *parser,
g_value_take_boxed (value, symbolic);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
return TRUE;
}
@@ -225,11 +230,11 @@ rgba_value_compute (GtkStyleProviderPrivate *provider,
GValue new_value = G_VALUE_INIT;
GdkRGBA rgba;
val = _gtk_symbolic_color_resolve_full (symbolic,
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (symbolic),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
if (val != NULL)
{
rgba = *_gtk_css_rgba_value_get_rgba (val);
@@ -253,7 +258,9 @@ color_value_parse (GtkCssParser *parser,
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
symbolic = _gtk_css_symbolic_value_new (parser);
if (symbolic == NULL)
return FALSE;
@@ -274,6 +281,8 @@ color_value_parse (GtkCssParser *parser,
g_value_take_boxed (value, symbolic);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
return TRUE;
}
@@ -310,11 +319,11 @@ color_value_compute (GtkStyleProviderPrivate *provider,
GValue new_value = G_VALUE_INIT;
GtkCssValue *val;
val = _gtk_symbolic_color_resolve_full ((GtkSymbolicColor *) g_value_get_boxed (value),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (g_value_get_boxed (value)),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
if (val != NULL)
{
const GdkRGBA *rgba = _gtk_css_rgba_value_get_rgba (val);
@@ -338,7 +347,7 @@ symbolic_color_value_parse (GtkCssParser *parser,
{
GtkSymbolicColor *symbolic;
symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
symbolic = _gtk_css_symbolic_value_new (parser);
if (symbolic == NULL)
return FALSE;
@@ -352,6 +361,8 @@ symbolic_color_value_print (const GValue *value,
{
GtkSymbolicColor *symbolic = g_value_get_boxed (value);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (symbolic == NULL)
g_string_append (string, "none");
else
@@ -360,6 +371,8 @@ symbolic_color_value_print (const GValue *value,
g_string_append (string, s);
g_free (s);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
}
static gboolean
@@ -702,6 +715,8 @@ gradient_value_print (const GValue *value,
{
GtkGradient *gradient = g_value_get_boxed (value);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (gradient == NULL)
g_string_append (string, "none");
else
@@ -710,6 +725,8 @@ gradient_value_print (const GValue *value,
g_string_append (string, s);
g_free (s);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
}
static gboolean
+100 -12
View File
@@ -38,6 +38,8 @@
enum {
PROP_0,
PROP_ANIMATED,
PROP_AFFECTS_SIZE,
PROP_AFFECTS_FONT,
PROP_ID,
PROP_INHERIT,
PROP_INITIAL
@@ -45,6 +47,11 @@ enum {
G_DEFINE_TYPE (GtkCssStyleProperty, _gtk_css_style_property, GTK_TYPE_STYLE_PROPERTY)
static GtkBitmask *_properties_affecting_size = NULL;
static GtkBitmask *_properties_affecting_font = NULL;
static GtkCssStylePropertyClass *gtk_css_style_property_class = NULL;
static void
gtk_css_style_property_constructed (GObject *object)
{
@@ -54,6 +61,12 @@ gtk_css_style_property_constructed (GObject *object)
property->id = klass->style_properties->len;
g_ptr_array_add (klass->style_properties, property);
if (property->affects_size)
_properties_affecting_size = _gtk_bitmask_set (_properties_affecting_size, property->id, TRUE);
if (property->affects_font)
_properties_affecting_font = _gtk_bitmask_set (_properties_affecting_font, property->id, TRUE);
G_OBJECT_CLASS (_gtk_css_style_property_parent_class)->constructed (object);
}
@@ -70,6 +83,12 @@ gtk_css_style_property_set_property (GObject *object,
case PROP_ANIMATED:
property->animated = g_value_get_boolean (value);
break;
case PROP_AFFECTS_SIZE:
property->affects_size = g_value_get_boolean (value);
break;
case PROP_AFFECTS_FONT:
property->affects_font = g_value_get_boolean (value);
break;
case PROP_INHERIT:
property->inherit = g_value_get_boolean (value);
break;
@@ -96,6 +115,12 @@ gtk_css_style_property_get_property (GObject *object,
case PROP_ANIMATED:
g_value_set_boolean (value, property->animated);
break;
case PROP_AFFECTS_SIZE:
g_value_set_boolean (value, property->affects_size);
break;
case PROP_AFFECTS_FONT:
g_value_set_boolean (value, property->affects_font);
break;
case PROP_ID:
g_value_set_boolean (value, property->id);
break;
@@ -251,6 +276,20 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
P_("Set if the value can be animated"),
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_AFFECTS_SIZE,
g_param_spec_boolean ("affects-size",
P_("Affects size"),
P_("Set if the value affects the sizing of elements"),
TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_AFFECTS_FONT,
g_param_spec_boolean ("affects-font",
P_("Affects font"),
P_("Set if the value affects the font"),
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_ID,
g_param_spec_uint ("id",
@@ -278,6 +317,11 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
property_class->parse_value = gtk_css_style_property_parse_value;
klass->style_properties = g_ptr_array_new ();
_properties_affecting_size = _gtk_bitmask_new ();
_properties_affecting_font = _gtk_bitmask_new ();
gtk_css_style_property_class = klass;
}
static GtkCssValue *
@@ -307,15 +351,13 @@ _gtk_css_style_property_get_n_properties (void)
{
GtkCssStylePropertyClass *klass;
klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
if (G_UNLIKELY (klass == NULL))
if (G_UNLIKELY (gtk_css_style_property_class == NULL))
{
_gtk_style_property_init_properties ();
klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
g_assert (klass);
g_assert (gtk_css_style_property_class);
}
return klass->style_properties->len;
return gtk_css_style_property_class->style_properties->len;
}
/**
@@ -331,18 +373,16 @@ _gtk_css_style_property_get_n_properties (void)
GtkCssStyleProperty *
_gtk_css_style_property_lookup_by_id (guint id)
{
GtkCssStylePropertyClass *klass;
klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
if (G_UNLIKELY (klass == NULL))
if (G_UNLIKELY (gtk_css_style_property_class == NULL))
{
_gtk_style_property_init_properties ();
klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
g_assert (klass);
g_assert (gtk_css_style_property_class);
}
g_return_val_if_fail (id < klass->style_properties->len, NULL);
return g_ptr_array_index (klass->style_properties, id);
g_return_val_if_fail (id < gtk_css_style_property_class->style_properties->len, NULL);
return g_ptr_array_index (gtk_css_style_property_class->style_properties, id);
}
/**
@@ -381,6 +421,42 @@ _gtk_css_style_property_is_animated (GtkCssStyleProperty *property)
return property->animated;
}
/**
* _gtk_css_style_property_affects_size:
* @property: the property
*
* Queries if the given @property affects the size of elements. This is
* used for optimizations inside GTK, where a gtk_widget_queue_resize()
* can be avoided if the property does not affect size.
*
* Returns: %TRUE if the property affects sizing of elements.
**/
gboolean
_gtk_css_style_property_affects_size (GtkCssStyleProperty *property)
{
g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
return property->affects_size;
}
/**
* _gtk_css_style_property_affects_font:
* @property: the property
*
* Queries if the given @property affects the default font. This is
* used for optimizations inside GTK, where clearing pango
* layouts can be avoided if the font doesn't change.
*
* Returns: %TRUE if the property affects the font.
**/
gboolean
_gtk_css_style_property_affects_font (GtkCssStyleProperty *property)
{
g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
return property->affects_font;
}
/**
* _gtk_css_style_property_get_id:
* @property: the property
@@ -415,3 +491,15 @@ _gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property)
return property->initial_value;
}
gboolean
_gtk_css_style_property_changes_affect_size (const GtkBitmask *changes)
{
return _gtk_bitmask_intersects (changes, _properties_affecting_size);
}
gboolean
_gtk_css_style_property_changes_affect_font (const GtkBitmask *changes)
{
return _gtk_bitmask_intersects (changes, _properties_affecting_font);
}
+67 -61
View File
@@ -46,9 +46,10 @@
#include "gtkcsscornervalueprivate.h"
#include "gtkcsseasevalueprivate.h"
#include "gtkcssenginevalueprivate.h"
#include "gtkcssimagegradientprivate.h"
#include "gtkcssimageprivate.h"
#include "gtkcssimagegradientprivate.h"
#include "gtkcssimagevalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsspositionvalueprivate.h"
@@ -64,7 +65,9 @@
typedef enum {
GTK_STYLE_PROPERTY_INHERIT = (1 << 0),
GTK_STYLE_PROPERTY_ANIMATED = (1 << 1)
GTK_STYLE_PROPERTY_ANIMATED = (1 << 1),
GTK_STYLE_PROPERTY_NO_RESIZE = (1 << 2),
GTK_STYLE_PROPERTY_AFFECTS_FONT = (1 << 3)
} GtkStylePropertyFlags;
static void
@@ -86,6 +89,8 @@ gtk_css_style_property_register (const char * name,
node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
"value-type", value_type,
"affects-size", (flags & GTK_STYLE_PROPERTY_NO_RESIZE) ? FALSE : TRUE,
"affects-font", (flags & GTK_STYLE_PROPERTY_AFFECTS_FONT) ? TRUE : FALSE,
"animated", (flags & GTK_STYLE_PROPERTY_ANIMATED) ? TRUE : FALSE,
"inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
"initial-value", initial_value,
@@ -159,7 +164,7 @@ assign_border (GtkCssStyleProperty *property,
const GtkBorder *border = g_value_get_boxed (value);
if (border == NULL)
return _gtk_css_value_ref (_gtk_css_style_property_get_initial_value (property));
return _gtk_css_initial_value_new ();
else
return _gtk_css_border_value_new (_gtk_css_number_value_new (border->top, GTK_CSS_PX),
_gtk_css_number_value_new (border->right, GTK_CSS_PX),
@@ -645,15 +650,17 @@ static GtkCssValue *
font_size_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
gdouble d;
GtkCssValue *value;
if (!_gtk_css_parser_try_double (parser, &d))
{
_gtk_css_parser_error (parser, "Expected a number");
return NULL;
}
value = _gtk_css_font_size_value_try_parse (parser);
if (value)
return value;
return _gtk_css_number_value_new (d, GTK_CSS_PX);
return _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_LENGTH
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_POSITIVE_ONLY
| GTK_CSS_NUMBER_AS_PIXELS);
}
static GtkCssValue *
@@ -863,7 +870,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("color",
GTK_CSS_PROPERTY_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
color_parse,
color_query,
color_assign,
@@ -871,19 +878,18 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-size",
GTK_CSS_PROPERTY_FONT_SIZE,
G_TYPE_DOUBLE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_AFFECTS_FONT,
font_size_parse,
query_length_as_double,
assign_length_from_double,
/* XXX: This should be 'normal' */
_gtk_css_number_value_new (10.0, GTK_CSS_PX));
_gtk_css_font_size_value_new (GTK_CSS_FONT_SIZE_MEDIUM));
/* properties that aren't referenced when computing values
* start here */
gtk_css_style_property_register ("background-color",
GTK_CSS_PROPERTY_BACKGROUND_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
color_parse,
color_query,
color_assign,
@@ -892,7 +898,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-family",
GTK_CSS_PROPERTY_FONT_FAMILY,
G_TYPE_STRV,
GTK_STYLE_PROPERTY_INHERIT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
font_family_parse,
font_family_query,
font_family_assign,
@@ -900,7 +906,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-style",
GTK_CSS_PROPERTY_FONT_STYLE,
PANGO_TYPE_STYLE,
GTK_STYLE_PROPERTY_INHERIT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
parse_pango_style,
query_pango_style,
assign_pango_style,
@@ -908,7 +914,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-variant",
GTK_CSS_PROPERTY_FONT_VARIANT,
PANGO_TYPE_VARIANT,
GTK_STYLE_PROPERTY_INHERIT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
parse_pango_variant,
query_pango_variant,
assign_pango_variant,
@@ -916,7 +922,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-weight",
GTK_CSS_PROPERTY_FONT_WEIGHT,
PANGO_TYPE_WEIGHT,
GTK_STYLE_PROPERTY_INHERIT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
parse_pango_weight,
query_pango_weight,
assign_pango_weight,
@@ -925,7 +931,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("text-shadow",
GTK_CSS_PROPERTY_TEXT_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
shadow_value_parse,
NULL,
NULL,
@@ -934,7 +940,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("icon-shadow",
GTK_CSS_PROPERTY_ICON_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
shadow_value_parse,
NULL,
NULL,
@@ -943,7 +949,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("box-shadow",
GTK_CSS_PROPERTY_BOX_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
shadow_value_parse,
NULL,
NULL,
@@ -1019,7 +1025,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-style",
GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1035,7 +1041,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-left-style",
GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1051,7 +1057,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-bottom-style",
GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1067,7 +1073,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-right-style",
GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1084,7 +1090,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-left-radius",
GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
border_corner_radius_value_parse,
NULL,
NULL,
@@ -1093,7 +1099,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-right-radius",
GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
border_corner_radius_value_parse,
NULL,
NULL,
@@ -1102,7 +1108,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-bottom-right-radius",
GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
border_corner_radius_value_parse,
NULL,
NULL,
@@ -1111,7 +1117,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-bottom-left-radius",
GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
border_corner_radius_value_parse,
NULL,
NULL,
@@ -1121,7 +1127,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("outline-style",
GTK_CSS_PROPERTY_OUTLINE_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1137,7 +1143,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("outline-offset",
GTK_CSS_PROPERTY_OUTLINE_OFFSET,
G_TYPE_INT,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
outline_parse,
query_length_as_int,
assign_length_from_int,
@@ -1146,7 +1152,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-clip",
GTK_CSS_PROPERTY_BACKGROUND_CLIP,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_css_area,
NULL,
NULL,
@@ -1154,7 +1160,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-origin",
GTK_CSS_PROPERTY_BACKGROUND_ORIGIN,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_css_area,
NULL,
NULL,
@@ -1162,7 +1168,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-size",
GTK_CSS_PROPERTY_BACKGROUND_SIZE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
background_size_parse,
NULL,
NULL,
@@ -1170,7 +1176,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-position",
GTK_CSS_PROPERTY_BACKGROUND_POSITION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
background_position_parse,
NULL,
NULL,
@@ -1180,7 +1186,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-color",
GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
color_parse,
color_query,
color_assign,
@@ -1188,7 +1194,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-right-color",
GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
color_parse,
color_query,
color_assign,
@@ -1196,7 +1202,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-bottom-color",
GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
color_parse,
color_query,
color_assign,
@@ -1204,7 +1210,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-left-color",
GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
color_parse,
color_query,
color_assign,
@@ -1212,7 +1218,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("outline-color",
GTK_CSS_PROPERTY_OUTLINE_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
color_parse,
color_query,
color_assign,
@@ -1221,7 +1227,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-repeat",
GTK_CSS_PROPERTY_BACKGROUND_REPEAT,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
background_repeat_value_parse,
NULL,
NULL,
@@ -1230,7 +1236,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-image",
GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
CAIRO_GOBJECT_TYPE_PATTERN,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
background_image_value_parse,
background_image_value_query,
background_image_value_assign,
@@ -1239,7 +1245,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-image-source",
GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
CAIRO_GOBJECT_TYPE_PATTERN,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
css_image_value_parse,
css_image_value_query,
css_image_value_assign,
@@ -1247,7 +1253,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-image-repeat",
GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
border_image_repeat_parse,
NULL,
NULL,
@@ -1257,7 +1263,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-image-slice",
GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE,
GTK_TYPE_BORDER,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
border_image_slice_parse,
query_border,
assign_border,
@@ -1268,7 +1274,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-image-width",
GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH,
GTK_TYPE_BORDER,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
border_image_width_parse,
query_border,
assign_border,
@@ -1280,7 +1286,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("transition-property",
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
transition_property_parse,
NULL,
NULL,
@@ -1288,7 +1294,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("transition-duration",
GTK_CSS_PROPERTY_TRANSITION_DURATION,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
transition_time_parse,
NULL,
NULL,
@@ -1296,7 +1302,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("transition-timing-function",
GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
transition_timing_function_parse,
NULL,
NULL,
@@ -1305,7 +1311,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("transition-delay",
GTK_CSS_PROPERTY_TRANSITION_DELAY,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
transition_time_parse,
NULL,
NULL,
@@ -1314,7 +1320,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-name",
GTK_CSS_PROPERTY_ANIMATION_NAME,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
transition_property_parse,
NULL,
NULL,
@@ -1322,7 +1328,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-duration",
GTK_CSS_PROPERTY_ANIMATION_DURATION,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
transition_time_parse,
NULL,
NULL,
@@ -1330,7 +1336,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-timing-function",
GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
transition_timing_function_parse,
NULL,
NULL,
@@ -1339,7 +1345,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-iteration-count",
GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
iteration_count_parse,
NULL,
NULL,
@@ -1347,7 +1353,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-direction",
GTK_CSS_PROPERTY_ANIMATION_DIRECTION,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_css_direction,
NULL,
NULL,
@@ -1355,7 +1361,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-play-state",
GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_css_play_state,
NULL,
NULL,
@@ -1363,7 +1369,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-delay",
GTK_CSS_PROPERTY_ANIMATION_DELAY,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
transition_time_parse,
NULL,
NULL,
@@ -1371,7 +1377,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-fill-mode",
GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
G_TYPE_NONE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
parse_css_fill_mode,
NULL,
NULL,
@@ -1380,7 +1386,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("engine",
GTK_CSS_PROPERTY_ENGINE,
GTK_TYPE_THEMING_ENGINE,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
engine_parse,
engine_query,
engine_assign,
@@ -1390,7 +1396,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("gtk-key-bindings",
GTK_CSS_PROPERTY_GTK_KEY_BINDINGS,
G_TYPE_PTR_ARRAY,
0,
GTK_STYLE_PROPERTY_NO_RESIZE,
bindings_value_parse,
bindings_value_query,
bindings_value_assign,
+9 -1
View File
@@ -49,6 +49,8 @@ struct _GtkCssStyleProperty
guint id;
guint inherit :1;
guint animated :1;
guint affects_size :1;
guint affects_font :1;
GtkCssStylePropertyParseFunc parse_value;
GtkCssStylePropertyQueryFunc query_value;
@@ -71,6 +73,8 @@ GtkCssStyleProperty * _gtk_css_style_property_lookup_by_id (guint
gboolean _gtk_css_style_property_is_inherit (GtkCssStyleProperty *property);
gboolean _gtk_css_style_property_is_animated (GtkCssStyleProperty *property);
gboolean _gtk_css_style_property_affects_size (GtkCssStyleProperty *property);
gboolean _gtk_css_style_property_affects_font (GtkCssStyleProperty *property);
guint _gtk_css_style_property_get_id (GtkCssStyleProperty *property);
GtkCssValue * _gtk_css_style_property_get_initial_value
(GtkCssStyleProperty *property);
@@ -78,7 +82,11 @@ GtkCssValue * _gtk_css_style_property_get_initial_value
void _gtk_css_style_property_print_value (GtkCssStyleProperty *property,
GtkCssValue *value,
GString *string);
gboolean _gtk_css_style_property_changes_affect_size
(const GtkBitmask *changes);
gboolean _gtk_css_style_property_changes_affect_font
(const GtkBitmask *changes);
G_END_DECLS
+17 -1
View File
@@ -50,7 +50,9 @@ typedef enum { /*< skip >*/
/* add more */
GTK_CSS_CHANGE_SOURCE = (1 << 16),
GTK_CSS_CHANGE_ANIMATE = (1 << 17),
GTK_CSS_CHANGE_FORCE_INVALIDATE = (1 << 18)
GTK_CSS_CHANGE_FORCE_INVALIDATE = (1 << 18),
GTK_CSS_CHANGE_RESERVED_BIT = (1 << 31) /* Used internally in gtkcssselector.c */
} GtkCssChange;
#define GTK_CSS_CHANGE_ANY ((1 << 19) - 1)
@@ -161,6 +163,20 @@ typedef enum /*< skip >*/ {
GTK_CSS_FILL_BOTH
} GtkCssFillMode;
typedef enum /*< skip >*/ {
/* relative font sizes */
GTK_CSS_FONT_SIZE_SMALLER,
GTK_CSS_FONT_SIZE_LARGER,
/* absolute font sizes */
GTK_CSS_FONT_SIZE_XX_SMALL,
GTK_CSS_FONT_SIZE_X_SMALL,
GTK_CSS_FONT_SIZE_SMALL,
GTK_CSS_FONT_SIZE_MEDIUM,
GTK_CSS_FONT_SIZE_LARGE,
GTK_CSS_FONT_SIZE_X_LARGE,
GTK_CSS_FONT_SIZE_XX_LARGE
} GtkCssFontSize;
/* for the order in arrays */
typedef enum /*< skip >*/ {
GTK_CSS_TOP,
+13 -12
View File
@@ -17,6 +17,7 @@
#include "config.h"
#include "gtkprivate.h"
#include "gtkcssvalueprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
@@ -45,7 +46,7 @@ _gtk_css_value_alloc (const GtkCssValueClass *klass,
GtkCssValue *
_gtk_css_value_ref (GtkCssValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
gtk_internal_return_val_if_fail (value != NULL, NULL);
g_atomic_int_add (&value->ref_count, 1);
@@ -93,10 +94,10 @@ _gtk_css_value_compute (GtkCssValue *value,
{
GtkCssDependencies fallback;
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
gtk_internal_return_val_if_fail (value != NULL, NULL);
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
if (dependencies == NULL)
dependencies = &fallback;
@@ -109,8 +110,8 @@ gboolean
_gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
g_return_val_if_fail (value1 != NULL, FALSE);
g_return_val_if_fail (value2 != NULL, FALSE);
gtk_internal_return_val_if_fail (value1 != NULL, FALSE);
gtk_internal_return_val_if_fail (value2 != NULL, FALSE);
if (value1 == value2)
return TRUE;
@@ -141,8 +142,8 @@ _gtk_css_value_transition (GtkCssValue *start,
guint property_id,
double progress)
{
g_return_val_if_fail (start != NULL, FALSE);
g_return_val_if_fail (end != NULL, FALSE);
gtk_internal_return_val_if_fail (start != NULL, FALSE);
gtk_internal_return_val_if_fail (end != NULL, FALSE);
if (start->class != end->class)
return NULL;
@@ -155,7 +156,7 @@ _gtk_css_value_to_string (const GtkCssValue *value)
{
GString *string;
g_return_val_if_fail (value != NULL, NULL);
gtk_internal_return_val_if_fail (value != NULL, NULL);
string = g_string_new (NULL);
_gtk_css_value_print (value, string);
@@ -175,8 +176,8 @@ void
_gtk_css_value_print (const GtkCssValue *value,
GString *string)
{
g_return_if_fail (value != NULL);
g_return_if_fail (string != NULL);
gtk_internal_return_if_fail (value != NULL);
gtk_internal_return_if_fail (string != NULL);
value->class->print (value, string);
}
+1 -1
View File
@@ -602,7 +602,7 @@ custom_paper_printer_data_func (GtkCellLayout *cell_layout,
if (printer)
g_object_set (cell, "text", gtk_printer_get_name (printer), NULL);
else
g_object_set (cell, "text", _("Margins from Printer..."), NULL);
g_object_set (cell, "text", _("Margins from Printer"), NULL);
if (printer)
g_object_unref (printer);
+3 -19
View File
@@ -3216,19 +3216,14 @@ gtk_entry_get_preferred_width (GtkWidget *widget,
PangoFontMetrics *metrics;
GtkBorder borders;
PangoContext *context;
GtkStyleContext *style_context;
GtkStateFlags state;
gint icon_widths = 0;
gint icon_width, i;
gint width;
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
gtk_style_context_get_font (style_context, state),
pango_context_get_font_description (context),
pango_context_get_language (context));
_gtk_entry_get_borders (entry, &borders);
@@ -3269,8 +3264,6 @@ gtk_entry_get_preferred_height (GtkWidget *widget,
GtkEntryPrivate *priv = entry->priv;
PangoFontMetrics *metrics;
GtkBorder borders;
GtkStyleContext *style_context;
GtkStateFlags state;
PangoContext *context;
gint height;
PangoLayout *layout;
@@ -3278,11 +3271,8 @@ gtk_entry_get_preferred_height (GtkWidget *widget,
layout = gtk_entry_ensure_layout (entry, TRUE);
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
gtk_style_context_get_font (style_context, state),
pango_context_get_font_description (context),
pango_context_get_language (context));
priv->ascent = pango_font_metrics_get_ascent (metrics);
@@ -4875,8 +4865,6 @@ gtk_entry_style_updated (GtkWidget *widget)
gtk_entry_update_cached_style_values (entry);
gtk_entry_recompute (entry);
icon_theme_changed (entry);
}
@@ -6574,8 +6562,6 @@ gtk_entry_move_adjustments (GtkEntry *entry)
GtkAdjustment *adjustment;
PangoContext *context;
PangoFontMetrics *metrics;
GtkStyleContext *style_context;
GtkStateFlags state;
GtkBorder borders;
gint x, layout_x;
gint char_width;
@@ -6594,11 +6580,9 @@ gtk_entry_move_adjustments (GtkEntry *entry)
/* Approximate width of a char, so user can see what is ahead/behind */
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
gtk_style_context_get_font (style_context, state),
pango_context_get_font_description (context),
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics) / PANGO_SCALE;
+4 -2
View File
@@ -1251,6 +1251,7 @@ get_next_site (GtkExpander *expander,
case GTK_DIR_RIGHT:
return FOCUS_WIDGET;
}
break;
case FOCUS_WIDGET:
switch (direction)
{
@@ -1264,8 +1265,8 @@ get_next_site (GtkExpander *expander,
return FOCUS_LABEL;
case GTK_DIR_RIGHT:
return ltr ? FOCUS_LABEL : FOCUS_NONE;
break;
}
break;
case FOCUS_LABEL:
switch (direction)
{
@@ -1279,8 +1280,8 @@ get_next_site (GtkExpander *expander,
return FOCUS_CHILD;
case GTK_DIR_RIGHT:
return ltr ? FOCUS_CHILD : FOCUS_WIDGET;
break;
}
break;
case FOCUS_CHILD:
switch (direction)
{
@@ -1293,6 +1294,7 @@ get_next_site (GtkExpander *expander,
case GTK_DIR_RIGHT:
return FOCUS_NONE;
}
break;
}
g_assert_not_reached ();
+3 -2
View File
@@ -1032,8 +1032,9 @@ gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
* @chooser: a #GtkFileChooser
*
* Gets the filename for the currently selected file in
* the file selector. If multiple files are selected,
* one of the filenames will be returned at random.
* the file selector. The filename is returned as an absolute path. If
* multiple files are selected, one of the filenames will be returned at
* random.
*
* If the file chooser is in folder mode, this function returns the selected
* folder.
+1 -1
View File
@@ -2043,7 +2043,7 @@ model_add_other (GtkFileChooserButton *button)
gtk_list_store_insert (store, &iter, pos);
gtk_list_store_set (store, &iter,
ICON_COLUMN, NULL,
DISPLAY_NAME_COLUMN, _("Other..."),
DISPLAY_NAME_COLUMN, _("Other…"),
TYPE_COLUMN, ROW_TYPE_OTHER,
DATA_COLUMN, NULL,
IS_FOLDER_COLUMN, FALSE,
+7 -7
View File
@@ -3386,7 +3386,7 @@ shortcuts_build_popup_menu (GtkFileChooserDefault *impl)
gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_shortcuts_popup_menu), item);
item = gtk_menu_item_new_with_label (_("Rename..."));
item = gtk_menu_item_new_with_label (_("Rename…"));
impl->browse_shortcuts_popup_menu_rename_item = item;
g_signal_connect (item, "activate",
G_CALLBACK (rename_shortcut_cb), impl);
@@ -3865,7 +3865,7 @@ copy_file_clear_cb (GtkClipboard *clipboard,
g_slist_free (selected_files);
}
/* Callback used when the "Copy file's location" menu item is activated */
/* Callback used when the "Copy files location" menu item is activated */
static void
copy_file_location_cb (GtkMenuItem *item,
GtkFileChooserDefault *impl)
@@ -4107,7 +4107,7 @@ file_list_drag_motion_cb (GtkWidget *widget,
return TRUE;
}
/* Sensitizes the "Copy file's location" context menu item if there is actually
/* Sensitizes the "Copy files location" context menu item if there is actually
* a selection active.
*/
static void
@@ -4176,7 +4176,7 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
impl->browse_files_popup_menu_visit_file_item = file_list_add_image_menu_item (impl, GTK_STOCK_DIRECTORY, _("_Visit this file"),
G_CALLBACK (visit_file_cb));
impl->browse_files_popup_menu_copy_file_location_item = file_list_add_image_menu_item (impl, GTK_STOCK_COPY, _("_Copy file's location"),
impl->browse_files_popup_menu_copy_file_location_item = file_list_add_image_menu_item (impl, GTK_STOCK_COPY, _("_Copy files location"),
G_CALLBACK (copy_file_location_cb));
impl->browse_files_popup_menu_add_shortcut_item = file_list_add_image_menu_item (impl, GTK_STOCK_ADD, _("_Add to Bookmarks"),
@@ -8187,7 +8187,7 @@ find_good_size_from_style (GtkWidget *widget,
{
GtkStyleContext *context;
GtkStateFlags state;
int font_size;
double font_size;
GdkScreen *screen;
double resolution;
@@ -8204,8 +8204,8 @@ find_good_size_from_style (GtkWidget *widget,
else
resolution = 96.0; /* wheeee */
font_size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
font_size = PANGO_PIXELS (font_size) * resolution / 72.0;
gtk_style_context_get (context, state, "font-size", &font_size, NULL);
font_size = font_size * resolution / 72.0 + 0.5;
*width = font_size * NUM_CHARS;
*height = font_size * NUM_LINES;
+18
View File
@@ -183,3 +183,21 @@ _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
}
}
void
_gtk_hsla_shade (GtkHSLA *dest,
const GtkHSLA *src,
double factor)
{
g_return_if_fail (dest != NULL);
g_return_if_fail (src != NULL);
dest->hue = src->hue;
dest->lightness = src->lightness * factor;
dest->lightness = CLAMP (dest->lightness, 0.0, 1.0);
dest->saturation = src->saturation * factor;
dest->saturation = CLAMP (dest->saturation, 0.0, 1.0);
dest->alpha = src->alpha;
}
+4
View File
@@ -42,6 +42,10 @@ void _gtk_hsla_init_from_rgba (GtkHSLA *hsla,
void _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
const GtkHSLA *hsla);
void _gtk_hsla_shade (GtkHSLA *dest,
const GtkHSLA *src,
double factor);
G_END_DECLS
#endif /* __GTK_HSLA_PRIVATE_H__ */
+501 -100
View File
@@ -24,6 +24,7 @@
#endif
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <glib.h>
#include <glib/gstdio.h>
@@ -160,9 +161,18 @@ typedef enum
HAS_ICON_FILE = 1 << 3
} IconSuffix;
#define INFO_CACHE_LRU_SIZE 32
#if 0
#define DEBUG_CACHE(args) g_print args
#else
#define DEBUG_CACHE(args)
#endif
struct _GtkIconThemePrivate
{
GHashTable *info_cache;
GList *info_cache_lru;
gchar *current_theme;
gchar *fallback_theme;
gchar **search_path;
@@ -197,10 +207,31 @@ struct _GtkIconThemePrivate
gulong reset_styles_idle;
};
typedef struct {
gchar **icon_names;
gint size;
GtkIconLookupFlags flags;
} IconInfoKey;
typedef struct _SymbolicPixbufCache SymbolicPixbufCache;
struct _SymbolicPixbufCache {
GdkPixbuf *pixbuf;
GdkPixbuf *proxy_pixbuf;
GdkRGBA fg;
GdkRGBA success_color;
GdkRGBA warning_color;
GdkRGBA error_color;
SymbolicPixbufCache *next;
};
struct _GtkIconInfo
{
/* Information about the source
*/
IconInfoKey key;
GtkIconTheme *in_cache;
gchar *filename;
GFile *icon_file;
GLoadableIcon *loadable;
@@ -231,9 +262,12 @@ struct _GtkIconInfo
* the icon.
*/
GdkPixbuf *pixbuf;
GdkPixbuf *proxy_pixbuf;
GError *load_error;
gdouble scale;
SymbolicPixbufCache *symbolic_pixbuf_cache;
GtkRequisition *symbolic_pixbuf_size;
};
@@ -330,6 +364,8 @@ static BuiltinIcon *find_builtin_icon (const gchar *icon_name,
gint size,
gint *min_difference_p,
gboolean *has_larger_p);
static void remove_from_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info);
static guint signal_changed = 0;
@@ -339,6 +375,46 @@ static GHashTable *icon_theme_builtin_icons;
GtkIconCache *_builtin_cache = NULL;
static GList *builtin_dirs = NULL;
static guint
icon_info_key_hash (gconstpointer _key)
{
const IconInfoKey *key = _key;
guint h = 0;
int i;
for (i = 0; key->icon_names[i] != NULL; i++)
h ^= g_str_hash (key->icon_names[i]);
h ^= key->size * 0x10001;
h ^= key->flags * 0x1000010;
return h;
}
static gboolean
icon_info_key_equal (gconstpointer _a,
gconstpointer _b)
{
const IconInfoKey *a = _a;
const IconInfoKey *b = _b;
int i;
if (a->size != b->size)
return FALSE;
if (a->flags != b->flags)
return FALSE;
for (i = 0;
a->icon_names[i] != NULL &&
b->icon_names[i] != NULL; i++)
{
if (strcmp (a->icon_names[i], b->icon_names[i]) != 0)
return FALSE;
}
return a->icon_names[i] == NULL && b->icon_names[i] == NULL;
}
G_DEFINE_TYPE (GtkIconTheme, gtk_icon_theme, G_TYPE_OBJECT)
/**
@@ -641,6 +717,25 @@ pixbuf_supports_svg (void)
return found_svg;
}
/* The icon info was removed from the icon_info_hash hash table */
static void
icon_info_uncached (GtkIconInfo *icon_info)
{
GtkIconTheme *icon_theme = icon_info->in_cache;
DEBUG_CACHE (("removing %p (%s %d 0x%x) from cache (icon_them: %p) (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
icon_theme,
icon_theme != NULL ? g_hash_table_size (icon_theme->priv->info_cache) : 0));
icon_info->in_cache = NULL;
if (icon_theme != NULL)
remove_from_lru_cache (icon_theme, icon_info);
}
static void
gtk_icon_theme_init (GtkIconTheme *icon_theme)
{
@@ -653,6 +748,9 @@ gtk_icon_theme_init (GtkIconTheme *icon_theme)
GtkIconThemePrivate);
icon_theme->priv = priv;
priv->info_cache = g_hash_table_new_full (icon_info_key_hash, icon_info_key_equal, NULL,
(GDestroyNotify)icon_info_uncached);
priv->custom_theme = FALSE;
xdg_data_dirs = g_get_system_data_dirs ();
@@ -712,6 +810,8 @@ do_theme_change (GtkIconTheme *icon_theme)
{
GtkIconThemePrivate *priv = icon_theme->priv;
g_hash_table_remove_all (priv->info_cache);
if (!priv->themes_valid)
return;
@@ -755,6 +855,9 @@ gtk_icon_theme_finalize (GObject *object)
icon_theme = GTK_ICON_THEME (object);
priv = icon_theme->priv;
g_hash_table_destroy (priv->info_cache);
g_assert (priv->info_cache_lru == NULL);
if (priv->reset_styles_idle)
{
g_source_remove (priv->reset_styles_idle);
@@ -1306,6 +1409,173 @@ ensure_valid_themes (GtkIconTheme *icon_theme)
priv->loading_themes = FALSE;
}
/* The LRU cache is a short list of IconInfos that are kept
alive even though their IconInfo would otherwise have
been freed, so that we can avoid reloading these
constantly.
We put infos on the lru list when nothing otherwise
references the info. So, when we get a cache hit
we remove it from the list, and when the proxy
pixmap is released we put it on the list.
*/
static void
ensure_lru_cache_space (GtkIconTheme *icon_theme)
{
GtkIconThemePrivate *priv = icon_theme->priv;
GList *l;
/* Remove last item if LRU full */
l = g_list_nth (priv->info_cache_lru, INFO_CACHE_LRU_SIZE - 1);
if (l)
{
GtkIconInfo *icon_info = l->data;
DEBUG_CACHE (("removing (due to out of space) %p (%s %d 0x%x) from LRU cache (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_list_length (priv->info_cache_lru)));
priv->info_cache_lru = g_list_delete_link (priv->info_cache_lru, l);
gtk_icon_info_free (icon_info);
}
}
static void
add_to_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info)
{
GtkIconThemePrivate *priv = icon_theme->priv;
DEBUG_CACHE (("adding %p (%s %d 0x%x) to LRU cache (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_list_length (priv->info_cache_lru)));
g_assert (g_list_find (priv->info_cache_lru, icon_info) == NULL);
ensure_lru_cache_space (icon_theme);
/* prepend new info to LRU */
priv->info_cache_lru = g_list_prepend (priv->info_cache_lru,
gtk_icon_info_copy (icon_info));
}
static void
ensure_in_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info)
{
GtkIconThemePrivate *priv = icon_theme->priv;
GList *l;
l = g_list_find (priv->info_cache_lru, icon_info);
if (l)
{
/* Move to front of LRU if already in it */
priv->info_cache_lru = g_list_remove_link (priv->info_cache_lru, l);
priv->info_cache_lru = g_list_concat (l, priv->info_cache_lru);
}
else
add_to_lru_cache (icon_theme, icon_info);
}
static void
remove_from_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info)
{
GtkIconThemePrivate *priv = icon_theme->priv;
if (g_list_find (priv->info_cache_lru, icon_info))
{
DEBUG_CACHE (("removing %p (%s %d 0x%x) from LRU cache (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_list_length (priv->info_cache_lru)));
priv->info_cache_lru = g_list_remove (priv->info_cache_lru, icon_info);
gtk_icon_info_free (icon_info);
}
}
static SymbolicPixbufCache *
symbolic_pixbuf_cache_new (GdkPixbuf *pixbuf,
const GdkRGBA *fg,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color,
SymbolicPixbufCache *next)
{
SymbolicPixbufCache *cache;
cache = g_new0 (SymbolicPixbufCache, 1);
cache->pixbuf = g_object_ref (pixbuf);
if (fg)
cache->fg = *fg;
if (success_color)
cache->success_color = *success_color;
if (warning_color)
cache->warning_color = *warning_color;
if (error_color)
cache->error_color = *error_color;
cache->next = next;
return cache;
}
static gboolean
rgba_matches (const GdkRGBA *a, const GdkRGBA *b)
{
GdkRGBA transparent = { 0 };
/* For matching we treat unset colors as transparent rather
than default, which works as well, because transparent
will never be used for real symbolic icon colors */
if (a == NULL)
a = &transparent;
return
fabs(a->red - b->red) < 0.0001 &&
fabs(a->green - b->green) < 0.0001 &&
fabs(a->blue - b->blue) < 0.0001 &&
fabs(a->alpha - b->alpha) < 0.0001;
}
static SymbolicPixbufCache *
symbolic_pixbuf_cache_matches (SymbolicPixbufCache *cache,
const GdkRGBA *fg,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color)
{
while (cache != NULL)
{
if (rgba_matches (fg, &cache->fg) &&
rgba_matches (success_color, &cache->success_color) &&
rgba_matches (warning_color, &cache->warning_color) &&
rgba_matches (error_color, &cache->error_color))
return cache;
cache = cache->next;
}
return NULL;
}
static void
symbolic_pixbuf_cache_free (SymbolicPixbufCache *cache)
{
SymbolicPixbufCache *next;
while (cache != NULL)
{
next = cache->next;
g_object_unref (cache->pixbuf);
g_free (cache);
cache = next;
}
}
static GtkIconInfo *
choose_icon (GtkIconTheme *icon_theme,
const gchar *icon_names[],
@@ -1319,9 +1589,31 @@ choose_icon (GtkIconTheme *icon_theme,
gboolean allow_svg;
gboolean use_builtin;
gint i;
IconInfoKey key;
priv = icon_theme->priv;
ensure_valid_themes (icon_theme);
key.icon_names = (char **)icon_names;
key.size = size;
key.flags = flags;
icon_info = g_hash_table_lookup (priv->info_cache, &key);
if (icon_info != NULL)
{
DEBUG_CACHE (("cache hit %p (%s %d 0x%x) (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_hash_table_size (priv->info_cache)));
icon_info = gtk_icon_info_copy (icon_info);
remove_from_lru_cache (icon_theme, icon_info);
return icon_info;
}
if (flags & GTK_ICON_LOOKUP_NO_SVG)
allow_svg = FALSE;
else if (flags & GTK_ICON_LOOKUP_FORCE_SVG)
@@ -1330,8 +1622,6 @@ choose_icon (GtkIconTheme *icon_theme,
allow_svg = priv->pixbuf_supports_svg;
use_builtin = flags & GTK_ICON_LOOKUP_USE_BUILTIN;
ensure_valid_themes (icon_theme);
/* for symbolic icons, do a search in all registered themes first;
* a theme that inherits them from a parent theme might provide
@@ -1417,10 +1707,21 @@ choose_icon (GtkIconTheme *icon_theme,
}
out:
if (icon_info)
if (icon_info)
{
icon_info->desired_size = size;
icon_info->forced_size = (flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0;
icon_info->key.icon_names = g_strdupv ((char **)icon_names);
icon_info->key.size = size;
icon_info->key.flags = flags;
icon_info->in_cache = icon_theme;
DEBUG_CACHE (("adding %p (%s %d 0x%x) to cache (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_hash_table_size (priv->info_cache)));
g_hash_table_insert (priv->info_cache, &icon_info->key, icon_info);
}
else
{
@@ -2735,7 +3036,12 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
icon_info->ref_count--;
if (icon_info->ref_count > 0)
return;
if (icon_info->in_cache)
g_hash_table_remove (icon_info->in_cache->priv->info_cache, &icon_info->key);
g_strfreev (icon_info->key.icon_names);
g_free (icon_info->filename);
g_clear_object (&icon_info->icon_file);
@@ -2749,6 +3055,8 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
if (icon_info->symbolic_pixbuf_size)
gtk_requisition_free (icon_info->symbolic_pixbuf_size);
symbolic_pixbuf_cache_free (icon_info->symbolic_pixbuf_cache);
g_slice_free (GtkIconInfo, icon_info);
}
@@ -3095,6 +3403,22 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
return TRUE;
}
static void
proxy_pixbuf_destroy (guchar *pixels, gpointer data)
{
GtkIconInfo *icon_info = data;
GtkIconTheme *icon_theme = icon_info->in_cache;
g_assert (icon_info->proxy_pixbuf != NULL);
icon_info->proxy_pixbuf = NULL;
/* Keep it alive a bit longer */
if (icon_theme != NULL)
ensure_in_lru_cache (icon_theme, icon_info);
gtk_icon_info_free (icon_info);
}
/**
* gtk_icon_info_load_icon:
* @icon_info: a #GtkIconInfo structure from gtk_icon_theme_lookup_icon()
@@ -3140,7 +3464,28 @@ gtk_icon_info_load_icon (GtkIconInfo *icon_info,
return NULL;
}
return g_object_ref (icon_info->pixbuf);
/* Instead of returning the pixbuf directly we
return a proxy to it that we don't own (but that
shares the data with the one we own). This way
we can know when it is freed and ensure the
IconInfo is alive (and thus cached) while
the pixbuf is still alive. */
if (icon_info->proxy_pixbuf != NULL)
return g_object_ref (icon_info->proxy_pixbuf);
icon_info->proxy_pixbuf =
gdk_pixbuf_new_from_data (gdk_pixbuf_get_pixels (icon_info->pixbuf),
gdk_pixbuf_get_colorspace (icon_info->pixbuf),
gdk_pixbuf_get_has_alpha (icon_info->pixbuf),
gdk_pixbuf_get_bits_per_sample (icon_info->pixbuf),
gdk_pixbuf_get_width (icon_info->pixbuf),
gdk_pixbuf_get_height (icon_info->pixbuf),
gdk_pixbuf_get_rowstride (icon_info->pixbuf),
proxy_pixbuf_destroy,
gtk_icon_info_copy (icon_info));
return icon_info->proxy_pixbuf;
}
static gchar *
@@ -3162,40 +3507,109 @@ gdk_rgba_to_css (const GdkRGBA *color)
(gint)(color->blue * 255));
}
static void
proxy_symbolic_pixbuf_destroy (guchar *pixels, gpointer data)
{
GtkIconInfo *icon_info = data;
GtkIconTheme *icon_theme = icon_info->in_cache;
SymbolicPixbufCache *symbolic_cache;
for (symbolic_cache = icon_info->symbolic_pixbuf_cache;
symbolic_cache != NULL;
symbolic_cache = symbolic_cache->next)
{
if (symbolic_cache->proxy_pixbuf != NULL &&
gdk_pixbuf_get_pixels (symbolic_cache->proxy_pixbuf) == pixels)
break;
}
g_assert (symbolic_cache != NULL);
g_assert (symbolic_cache->proxy_pixbuf != NULL);
symbolic_cache->proxy_pixbuf = NULL;
/* Keep it alive a bit longer */
if (icon_theme != NULL)
ensure_in_lru_cache (icon_theme, icon_info);
gtk_icon_info_free (icon_info);
}
static GdkPixbuf *
symbolic_cache_get_proxy (SymbolicPixbufCache *symbolic_cache,
GtkIconInfo *icon_info)
{
if (symbolic_cache->proxy_pixbuf)
return g_object_ref (symbolic_cache->proxy_pixbuf);
symbolic_cache->proxy_pixbuf =
gdk_pixbuf_new_from_data (gdk_pixbuf_get_pixels (symbolic_cache->pixbuf),
gdk_pixbuf_get_colorspace (symbolic_cache->pixbuf),
gdk_pixbuf_get_has_alpha (symbolic_cache->pixbuf),
gdk_pixbuf_get_bits_per_sample (symbolic_cache->pixbuf),
gdk_pixbuf_get_width (symbolic_cache->pixbuf),
gdk_pixbuf_get_height (symbolic_cache->pixbuf),
gdk_pixbuf_get_rowstride (symbolic_cache->pixbuf),
proxy_symbolic_pixbuf_destroy,
gtk_icon_info_copy (icon_info));
return symbolic_cache->proxy_pixbuf;
}
static GdkPixbuf *
_gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info,
const gchar *css_fg,
const gchar *css_success,
const gchar *css_warning,
const gchar *css_error,
const GdkRGBA *fg,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color,
GError **error)
{
GInputStream *stream;
GdkPixbuf *pixbuf;
gchar *css_fg;
gchar *css_success;
gchar *css_warning;
gchar *css_error;
gchar *data;
gchar *success, *warning, *err;
gchar *width, *height, *uri;
SymbolicPixbufCache *symbolic_cache;
symbolic_cache = symbolic_pixbuf_cache_matches (icon_info->symbolic_pixbuf_cache,
fg, success_color, warning_color, error_color);
if (symbolic_cache)
return symbolic_cache_get_proxy (symbolic_cache, icon_info);
/* css_fg can't possibly have failed, otherwise
* that would mean we have a broken style */
g_return_val_if_fail (css_fg != NULL, NULL);
g_return_val_if_fail (fg != NULL, NULL);
success = warning = err = NULL;
css_fg = gdk_rgba_to_css (fg);
css_success = css_warning = css_error = NULL;
if (warning_color)
css_warning = gdk_rgba_to_css (warning_color);
if (error_color)
css_error = gdk_rgba_to_css (error_color);
if (success_color)
css_success = gdk_rgba_to_css (success_color);
if (!css_success)
{
GdkColor success_default_color = { 0, 0x4e00, 0x9a00, 0x0600 };
success = gdk_color_to_css (&success_default_color);
css_success = gdk_color_to_css (&success_default_color);
}
if (!css_warning)
{
GdkColor warning_default_color = { 0, 0xf500, 0x7900, 0x3e00 };
warning = gdk_color_to_css (&warning_default_color);
css_warning = gdk_color_to_css (&warning_default_color);
}
if (!css_error)
{
GdkColor error_default_color = { 0, 0xcc00, 0x0000, 0x0000 };
err = gdk_color_to_css (&error_default_color);
css_error = gdk_color_to_css (&error_default_color);
}
if (!icon_info->symbolic_pixbuf_size)
@@ -3233,21 +3647,22 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info,
" fill: ", css_fg," !important;\n"
" }\n"
" .warning {\n"
" fill: ", css_warning ? css_warning : warning," !important;\n"
" fill: ", css_warning, " !important;\n"
" }\n"
" .error {\n"
" fill: ", css_error ? css_error : err," !important;\n"
" fill: ", css_error ," !important;\n"
" }\n"
" .success {\n"
" fill: ", css_success ? css_success : success," !important;\n"
" fill: ", css_success, " !important;\n"
" }\n"
" </style>\n"
" <xi:include href=\"", uri, "\"/>\n"
"</svg>",
NULL);
g_free (warning);
g_free (err);
g_free (success);
g_free (css_fg);
g_free (css_warning);
g_free (css_error);
g_free (css_success);
g_free (width);
g_free (height);
g_free (uri);
@@ -3261,7 +3676,16 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info,
error);
g_object_unref (stream);
return pixbuf;
if (pixbuf != NULL)
{
icon_info->symbolic_pixbuf_cache =
symbolic_pixbuf_cache_new (pixbuf, fg, success_color, warning_color, error_color,
icon_info->symbolic_pixbuf_cache);
return symbolic_cache_get_proxy (icon_info->symbolic_pixbuf_cache, icon_info);
}
return NULL;
}
/**
@@ -3310,11 +3734,6 @@ gtk_icon_info_load_symbolic (GtkIconInfo *icon_info,
gboolean *was_symbolic,
GError **error)
{
GdkPixbuf *pixbuf;
gchar *css_fg;
gchar *css_success;
gchar *css_warning;
gchar *css_error;
gchar *icon_uri;
gboolean is_symbolic;
@@ -3334,29 +3753,10 @@ gtk_icon_info_load_symbolic (GtkIconInfo *icon_info,
if (!is_symbolic)
return gtk_icon_info_load_icon (icon_info, error);
css_fg = gdk_rgba_to_css (fg);
css_success = css_warning = css_error = NULL;
if (warning_color)
css_warning = gdk_rgba_to_css (warning_color);
if (error_color)
css_error = gdk_rgba_to_css (error_color);
if (success_color)
css_success = gdk_rgba_to_css (success_color);
pixbuf = _gtk_icon_info_load_symbolic_internal (icon_info,
css_fg, css_success,
css_warning, css_error,
error);
g_free (css_fg);
g_free (css_warning);
g_free (css_success);
g_free (css_error);
return pixbuf;
return _gtk_icon_info_load_symbolic_internal (icon_info,
fg, success_color,
warning_color, error_color,
error);
}
/**
@@ -3390,11 +3790,15 @@ gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info,
gboolean *was_symbolic,
GError **error)
{
GdkPixbuf *pixbuf;
GdkRGBA *color = NULL;
GdkRGBA rgba;
gchar *css_fg = NULL, *css_success;
gchar *css_warning, *css_error;
GdkRGBA fg;
GdkRGBA *fgp;
GdkRGBA success_color;
GdkRGBA *success_colorp;
GdkRGBA warning_color;
GdkRGBA *warning_colorp;
GdkRGBA error_color;
GdkRGBA *error_colorp;
GtkStateFlags state;
gchar *icon_uri;
gboolean is_symbolic;
@@ -3415,36 +3819,40 @@ gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info,
if (!is_symbolic)
return gtk_icon_info_load_icon (icon_info, error);
fgp = success_colorp = warning_colorp = error_colorp = NULL;
state = gtk_style_context_get_state (context);
gtk_style_context_get (context, state, "color", &color, NULL);
if (color)
{
css_fg = gdk_rgba_to_css (color);
fg = *color;
fgp = &fg;
gdk_rgba_free (color);
}
css_success = css_warning = css_error = NULL;
if (gtk_style_context_lookup_color (context, "success_color", &success_color))
success_colorp = &success_color;
if (gtk_style_context_lookup_color (context, "success_color", &rgba))
css_success = gdk_rgba_to_css (&rgba);
if (gtk_style_context_lookup_color (context, "warning_color", &warning_color))
warning_colorp = &warning_color;
if (gtk_style_context_lookup_color (context, "warning_color", &rgba))
css_warning = gdk_rgba_to_css (&rgba);
if (gtk_style_context_lookup_color (context, "error_color", &error_color))
error_colorp = &error_color;
if (gtk_style_context_lookup_color (context, "error_color", &rgba))
css_error = gdk_rgba_to_css (&rgba);
return _gtk_icon_info_load_symbolic_internal (icon_info,
fgp, success_colorp,
warning_colorp, error_colorp,
error);
}
pixbuf = _gtk_icon_info_load_symbolic_internal (icon_info,
css_fg, css_success,
css_warning, css_error,
error);
g_free (css_fg);
g_free (css_success);
g_free (css_warning);
g_free (css_error);
return pixbuf;
static GdkRGBA *
color_to_rgba (GdkColor *color, GdkRGBA *rgba)
{
rgba->red = color->red / 65535.0;
rgba->green = color->green / 65535.0;
rgba->blue = color->blue / 65535.0;
rgba->alpha = 1.0;
return rgba;
}
/**
@@ -3479,13 +3887,14 @@ gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info,
gboolean *was_symbolic,
GError **error)
{
GdkPixbuf *pixbuf;
GdkColor success_color;
GdkColor warning_color;
GdkColor error_color;
GdkColor *fg;
gchar *css_fg, *css_success;
gchar *css_warning, *css_error;
GdkColor color;
GdkRGBA fg;
GdkRGBA success_color;
GdkRGBA *success_colorp;
GdkRGBA warning_color;
GdkRGBA *warning_colorp;
GdkRGBA error_color;
GdkRGBA *error_colorp;
gchar *icon_uri;
gboolean is_symbolic;
@@ -3505,31 +3914,23 @@ gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info,
if (!is_symbolic)
return gtk_icon_info_load_icon (icon_info, error);
fg = &style->fg[state];
css_fg = gdk_color_to_css (fg);
color_to_rgba (&style->fg[state], &fg);
css_success = css_warning = css_error = NULL;
success_colorp = warning_colorp = error_colorp = NULL;
if (gtk_style_lookup_color (style, "success_color", &success_color))
css_success = gdk_color_to_css (&success_color);
if (gtk_style_lookup_color (style, "success_color", &color))
success_colorp = color_to_rgba (&color, &success_color);
if (gtk_style_lookup_color (style, "warning_color", &warning_color))
css_warning = gdk_color_to_css (&warning_color);
if (gtk_style_lookup_color (style, "warning_color", &color))
warning_colorp = color_to_rgba (&color, &warning_color);
if (gtk_style_lookup_color (style, "error_color", &error_color))
css_error = gdk_color_to_css (&error_color);
if (gtk_style_lookup_color (style, "error_color", &color))
error_colorp = color_to_rgba (&color, &error_color);
pixbuf = _gtk_icon_info_load_symbolic_internal (icon_info,
css_fg, css_success,
css_warning, css_error,
error);
g_free (css_fg);
g_free (css_success);
g_free (css_warning);
g_free (css_error);
return pixbuf;
return _gtk_icon_info_load_symbolic_internal (icon_info,
&fg, success_colorp,
warning_colorp, error_colorp,
error);
}
/**
+38 -12
View File
@@ -371,28 +371,54 @@ check_quartz_special_cases (GtkIMContextSimple *context_simple,
gint n_compose)
{
GtkIMContextSimplePrivate *priv = context_simple->priv;
guint value = 0;
if (n_compose == 2 &&
priv->compose_buffer[1] == GDK_KEY_space)
if (n_compose == 2)
{
gunichar value = 0;
switch (priv->compose_buffer[0])
{
case GDK_KEY_dead_doubleacute:
value = '"'; break;
}
switch (priv->compose_buffer[1])
{
case GDK_KEY_dead_doubleacute:
case GDK_KEY_space:
value = GDK_KEY_quotedbl; break;
if (value > 0)
{
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
priv->compose_buffer[0] = 0;
case 'a': value = GDK_KEY_adiaeresis; break;
case 'A': value = GDK_KEY_Adiaeresis; break;
case 'e': value = GDK_KEY_ediaeresis; break;
case 'E': value = GDK_KEY_Ediaeresis; break;
case 'i': value = GDK_KEY_idiaeresis; break;
case 'I': value = GDK_KEY_Idiaeresis; break;
case 'o': value = GDK_KEY_odiaeresis; break;
case 'O': value = GDK_KEY_Odiaeresis; break;
case 'u': value = GDK_KEY_udiaeresis; break;
case 'U': value = GDK_KEY_Udiaeresis; break;
case 'y': value = GDK_KEY_ydiaeresis; break;
case 'Y': value = GDK_KEY_Ydiaeresis; break;
}
break;
GTK_NOTE (MISC, g_print ("quartz: U+%04X\n", value));
return TRUE;
case GDK_KEY_dead_acute:
switch (priv->compose_buffer[1])
{
case 'c': value = GDK_KEY_ccedilla; break;
case 'C': value = GDK_KEY_Ccedilla; break;
}
break;
}
}
if (value > 0)
{
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple),
gdk_keyval_to_unicode (value));
priv->compose_buffer[0] = 0;
GTK_NOTE (MISC, g_print ("quartz: U+%04X\n", value));
return TRUE;
}
return FALSE;
}
+7 -51
View File
@@ -384,9 +384,6 @@ static void gtk_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_label_state_flags_changed (GtkWidget *widget,
GtkStateFlags prev_state);
static void gtk_label_style_updated (GtkWidget *widget);
static void gtk_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
static gint gtk_label_draw (GtkWidget *widget,
cairo_t *cr);
static gboolean gtk_label_focus (GtkWidget *widget,
@@ -566,9 +563,7 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->destroy = gtk_label_destroy;
widget_class->size_allocate = gtk_label_size_allocate;
widget_class->state_flags_changed = gtk_label_state_flags_changed;
widget_class->style_updated = gtk_label_style_updated;
widget_class->query_tooltip = gtk_label_query_tooltip;
widget_class->direction_changed = gtk_label_direction_changed;
widget_class->draw = gtk_label_draw;
widget_class->realize = gtk_label_realize;
widget_class->unrealize = gtk_label_unrealize;
@@ -1852,6 +1847,9 @@ gtk_label_screen_changed (GtkWidget *widget,
GtkSettings *settings;
gboolean shortcuts_connected;
/* The PangoContext is replaced when the screen changes, so clear the layouts */
gtk_label_clear_layout (GTK_LABEL (widget));
if (!gtk_widget_has_screen (widget))
return;
@@ -3136,23 +3134,6 @@ gtk_label_clear_layout (GtkLabel *label)
}
}
static PangoFontMetrics *
get_font_metrics (PangoContext *context, GtkWidget *widget)
{
GtkStyleContext *style_context;
const PangoFontDescription *font;
PangoFontMetrics *retval;
style_context = gtk_widget_get_style_context (widget);
font = gtk_style_context_get_font (style_context, GTK_STATE_FLAG_NORMAL);
retval = pango_context_get_metrics (context,
font,
pango_context_get_language (context));
return retval;
}
/**
* gtk_label_get_measuring_layout:
* @label: the label
@@ -3384,7 +3365,7 @@ gtk_label_ensure_layout (GtkLabel *label)
pango_attr_list_insert (attrs, attribute);
}
}
else if (priv->markup_attrs && priv->markup_attrs)
else if (priv->markup_attrs || priv->attrs)
attrs = pango_attr_list_new ();
else
attrs = NULL;
@@ -3485,7 +3466,9 @@ get_char_pixels (GtkWidget *label,
gint char_width, digit_width;
context = pango_layout_get_context (layout);
metrics = get_font_metrics (context, GTK_WIDGET (label));
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
pango_font_metrics_unref (metrics);
@@ -3826,37 +3809,10 @@ gtk_label_state_flags_changed (GtkWidget *widget,
gtk_label_update_cursor (label);
}
/* We have to clear the layout, fonts etc. may have changed */
gtk_label_clear_layout (label);
if (GTK_WIDGET_CLASS (gtk_label_parent_class)->state_flags_changed)
GTK_WIDGET_CLASS (gtk_label_parent_class)->state_flags_changed (widget, prev_state);
}
static void
gtk_label_style_updated (GtkWidget *widget)
{
GtkLabel *label = GTK_LABEL (widget);
GTK_WIDGET_CLASS (gtk_label_parent_class)->style_updated (widget);
/* We have to clear the layout, fonts etc. may have changed */
gtk_label_clear_layout (label);
}
static void
gtk_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
if (priv->layout)
pango_layout_context_changed (priv->layout);
GTK_WIDGET_CLASS (gtk_label_parent_class)->direction_changed (widget, previous_dir);
}
static void
get_layout_location (GtkLabel *label,
gint *xp,
+6 -4
View File
@@ -2437,10 +2437,12 @@ list_store_start_element (GMarkupParseContext *context,
else if (strcmp (element_name, "row") == 0)
;
else if (strcmp (element_name, "column") == 0)
for (i = 0; names[i]; i++)
if (strcmp (names[i], "type") == 0)
data->column_type_names = g_slist_prepend (data->column_type_names,
g_strdup (values[i]));
{
for (i = 0; names[i]; i++)
if (strcmp (names[i], "type") == 0)
data->column_type_names = g_slist_prepend (data->column_type_names,
g_strdup (values[i]));
}
else if (strcmp (element_name, "columns") == 0)
;
else if (strcmp (element_name, "data") == 0)
+56 -83
View File
@@ -641,15 +641,6 @@ gtk_menu_class_init (GtkMenuClass *class)
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-padding",
P_("Vertical Padding"),
P_("Extra space at the top and bottom of the menu"),
0,
G_MAXINT,
1,
GTK_PARAM_READABLE));
/**
* GtkMenu:reserve-toggle-size:
*
@@ -671,6 +662,15 @@ gtk_menu_class_init (GtkMenuClass *class)
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkMenu:horizontal-padding:
*
* Extra space at the left and right edges of the menu.
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("horizontal-padding",
P_("Horizontal Padding"),
@@ -678,7 +678,27 @@ gtk_menu_class_init (GtkMenuClass *class)
0,
G_MAXINT,
0,
GTK_PARAM_READABLE));
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
/**
* GtkMenu:vertical-padding:
*
* Extra space at the top and bottom of the menu.
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-padding",
P_("Vertical Padding"),
P_("Extra space at the top and bottom of the menu"),
0,
G_MAXINT,
1,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-offset",
@@ -2510,8 +2530,6 @@ gtk_menu_realize (GtkWidget *widget)
gint border_width;
GtkWidget *child;
GList *children;
guint vertical_padding;
guint horizontal_padding;
GtkBorder arrow_border, padding;
g_return_if_fail (GTK_IS_MENU (widget));
@@ -2542,19 +2560,14 @@ gtk_menu_realize (GtkWidget *widget)
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
context = gtk_widget_get_style_context (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
gtk_widget_get_allocation (widget, &allocation);
attributes.x = border_width + padding.left + horizontal_padding;
attributes.y = border_width + padding.top + vertical_padding;
attributes.x = border_width + padding.left;
attributes.y = border_width + padding.top;
attributes.width = allocation.width -
(2 * (border_width + horizontal_padding)) - padding.left - padding.right;
(2 * border_width) - padding.left - padding.right;
attributes.height = allocation.height -
(2 * (border_width + vertical_padding)) - padding.top - padding.bottom;
(2 * border_width) - padding.top - padding.bottom;
get_arrows_border (menu, &arrow_border);
attributes.y += arrow_border.top;
@@ -2572,9 +2585,9 @@ gtk_menu_realize (GtkWidget *widget)
attributes.x = 0;
attributes.y = 0;
attributes.width = allocation.width + (2 * (border_width + horizontal_padding)) +
attributes.width = allocation.width + (2 * border_width) +
padding.left + padding.right;
attributes.height = priv->requested_height - (2 * (border_width + vertical_padding)) +
attributes.height = priv->requested_height - (2 * border_width) +
padding.top + padding.bottom;
attributes.width = MAX (1, attributes.width);
@@ -2690,7 +2703,6 @@ calculate_line_heights (GtkMenu *menu,
GtkMenuShell *menu_shell;
GtkWidget *child, *widget;
GList *children;
guint horizontal_padding;
guint border_width;
guint n_columns;
gint n_heights;
@@ -2708,13 +2720,10 @@ calculate_line_heights (GtkMenu *menu,
n_columns = gtk_menu_get_n_columns (menu);
avail_width = for_width - (2 * priv->toggle_size + priv->accel_size) * n_columns;
gtk_widget_style_get (GTK_WIDGET (menu),
"horizontal-padding", &horizontal_padding,
NULL);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
avail_width -= (border_width + horizontal_padding) * 2 + padding.left + padding.right;
avail_width -= (border_width) * 2 + padding.left + padding.right;
for (children = menu_shell->priv->children; children; children = children->next)
{
@@ -2770,8 +2779,6 @@ gtk_menu_size_allocate (GtkWidget *widget,
gint x, y, i;
gint width, height;
guint border_width;
guint vertical_padding;
guint horizontal_padding;
GtkBorder padding;
g_return_if_fail (GTK_IS_MENU (widget));
@@ -2783,11 +2790,6 @@ gtk_menu_size_allocate (GtkWidget *widget,
gtk_widget_set_allocation (widget, allocation);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
@@ -2798,16 +2800,15 @@ gtk_menu_size_allocate (GtkWidget *widget,
NULL);
/* refresh our cached height request */
priv->requested_height = (2 * (border_width + vertical_padding)) +
padding.top + padding.bottom;
priv->requested_height = (2 * border_width) + padding.top + padding.bottom;
for (i = 0; i < priv->heights_length; i++)
priv->requested_height += priv->heights[i];
x = border_width + padding.left + horizontal_padding;
y = border_width + padding.top + vertical_padding;
width = allocation->width - (2 * (border_width + horizontal_padding)) -
x = border_width + padding.left;
y = border_width + padding.top;
width = allocation->width - (2 * border_width) -
padding.left - padding.right;
height = allocation->height - (2 * (border_width + vertical_padding)) -
height = allocation->height - (2 * border_width) -
padding.top - padding.bottom;
if (menu_shell->priv->active)
@@ -2937,22 +2938,18 @@ get_arrows_visible_area (GtkMenu *menu,
GtkArrowPlacement arrow_placement;
GtkWidget *widget = GTK_WIDGET (menu);
guint border_width;
guint vertical_padding;
guint horizontal_padding;
gint scroll_arrow_height;
GtkBorder menu_padding;
gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
"scroll-arrow-vlength", &scroll_arrow_height,
"arrow-placement", &arrow_placement,
NULL);
get_menu_padding (widget, &menu_padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
border->x = border_width + menu_padding.left + horizontal_padding;
border->y = border_width + menu_padding.top + vertical_padding;
border->x = border_width + menu_padding.left;
border->y = border_width + menu_padding.top;
border->width = gdk_window_get_width (gtk_widget_get_window (widget));
border->height = gdk_window_get_height (gtk_widget_get_window (widget));
@@ -3137,7 +3134,6 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
GList *children;
guint max_toggle_size;
guint max_accel_width;
guint horizontal_padding;
guint border_width;
gint child_min, child_nat;
gint min_width, nat_width;
@@ -3226,16 +3222,10 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
nat_width += 2 * max_toggle_size + max_accel_width;
nat_width *= gtk_menu_get_n_columns (menu);
gtk_widget_style_get (GTK_WIDGET (menu),
"horizontal-padding", &horizontal_padding,
NULL);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
min_width += (2 * (border_width + horizontal_padding)) +
padding.left + padding.right;
nat_width += (2 * (border_width + horizontal_padding)) +
padding.left + padding.right;
min_width += (2 * border_width) + padding.left + padding.right;
nat_width += (2 * border_width) + padding.left + padding.right;
priv->toggle_size = max_toggle_size;
priv->accel_size = max_accel_width;
@@ -3277,16 +3267,14 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
GtkMenu *menu = GTK_MENU (widget);
GtkMenuPrivate *priv = menu->priv;
guint *min_heights, *nat_heights;
guint vertical_padding, border_width;
guint border_width;
gint n_heights, i;
gint min_height, nat_height;
gtk_widget_style_get (widget, "vertical-padding", &vertical_padding, NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
get_menu_padding (widget, &padding);
min_height = nat_height = (border_width + vertical_padding) * 2 +
padding.top + padding.bottom;
min_height = nat_height = (2 * border_width) + padding.top + padding.bottom;
n_heights =
calculate_line_heights (menu, for_size, &min_heights, &nat_heights);
@@ -3868,7 +3856,6 @@ get_arrows_sensitive_area (GtkMenu *menu,
GdkWindow *window;
gint width, height;
guint border;
guint vertical_padding;
gint win_x, win_y;
gint scroll_arrow_height;
GtkBorder padding;
@@ -3878,12 +3865,11 @@ get_arrows_sensitive_area (GtkMenu *menu,
height = gdk_window_get_height (window);
gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
"scroll-arrow-vlength", &scroll_arrow_height,
"arrow-placement", &arrow_placement,
NULL);
border = gtk_container_get_border_width (GTK_CONTAINER (menu)) + vertical_padding;
border = gtk_container_get_border_width (GTK_CONTAINER (menu));
get_menu_padding (widget, &padding);
gdk_window_get_position (window, &win_x, &win_y);
@@ -4845,8 +4831,6 @@ gtk_menu_scroll_to (GtkMenu *menu,
gint view_width, view_height;
gint border_width;
gint menu_height;
guint vertical_padding;
guint horizontal_padding;
gboolean double_arrows;
widget = GTK_WIDGET (menu);
@@ -4858,23 +4842,17 @@ gtk_menu_scroll_to (GtkMenu *menu,
view_width = gtk_widget_get_allocated_width (widget);
view_height = gtk_widget_get_allocated_height (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
get_menu_padding (widget, &padding);
double_arrows = get_double_arrows (menu);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
view_width -= (2 * (border_width + horizontal_padding)) + padding.left + padding.right;
view_height -= (2 * (border_width + vertical_padding)) + padding.top + padding.bottom;
menu_height = priv->requested_height - (2 * (border_width + vertical_padding)) -
padding.top - padding.bottom;
view_width -= (2 * border_width) + padding.left + padding.right;
view_height -= (2 * border_width) + padding.top + padding.bottom;
menu_height = priv->requested_height - (2 * border_width) - padding.top - padding.bottom;
x = border_width + padding.left + horizontal_padding;
y = border_width + padding.top + vertical_padding;
x = border_width + padding.left;
y = border_width + padding.top;
if (double_arrows && !priv->tearoff_active)
{
@@ -5071,23 +5049,18 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
if (compute_child_offset (menu, menu_item,
&child_offset, &child_height, &last_child))
{
guint vertical_padding;
gboolean double_arrows;
GtkBorder padding;
y = priv->scroll_offset;
height = gdk_window_get_height (gtk_widget_get_window (widget));
gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
NULL);
double_arrows = get_double_arrows (menu);
get_menu_padding (widget, &padding);
height -= 2 * gtk_container_get_border_width (GTK_CONTAINER (menu)) +
padding.top + padding.bottom +
2 * vertical_padding;
padding.top + padding.bottom;
if (child_offset < y)
{
/* Ignore the enter event we might get if the pointer
+48 -33
View File
@@ -51,9 +51,6 @@
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
#define BORDER_SPACING 0
#define DEFAULT_IPADDING 1
/* Properties */
enum {
PROP_0,
@@ -219,14 +216,24 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
GTK_SHADOW_OUT,
GTK_PARAM_READABLE));
/**
* GtkMenuBar:internal-padding:
*
* Amount of border space between the menubar shadow and the menu items
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("internal-padding",
P_("Internal padding"),
P_("Amount of border space between the menubar shadow and the menu items"),
0,
G_MAXINT,
DEFAULT_IPADDING,
GTK_PARAM_READABLE));
0,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
}
@@ -332,10 +339,12 @@ gtk_menu_bar_size_request (GtkWidget *widget,
GtkMenuShell *menu_shell;
GtkWidget *child;
GList *children;
gint ipadding;
guint border_width;
gboolean use_toggle_size, use_maximize;
gint child_minimum, child_natural;
GtkStyleContext *context;
GtkBorder border;
GtkStateFlags flags;
*minimum = 0;
*natural = 0;
@@ -391,19 +400,28 @@ gtk_menu_bar_size_request (GtkWidget *widget,
}
}
gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
context = gtk_widget_get_style_context (widget);
flags = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, flags, &border);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
*minimum += border.left + border.right;
*natural += border.left + border.right;
}
else
{
*minimum += border.top + border.bottom;
*natural += border.top + border.bottom;
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
*minimum += (border_width + ipadding + BORDER_SPACING) * 2;
*natural += (border_width + ipadding + BORDER_SPACING) * 2;
*minimum += border_width * 2;
*natural += border_width * 2;
if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
{
GtkStyleContext *context;
GtkBorder border;
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_border (context, gtk_widget_get_state_flags (widget),
&border);
gtk_style_context_get_border (context, flags, &border);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
@@ -462,7 +480,6 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
GtkWidget *child;
GList *children;
GtkAllocation remaining_space;
gint ipadding;
guint border_width;
GArray *requested_sizes;
gint toggle_size;
@@ -484,28 +501,26 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
if (menu_shell->priv->children)
{
gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
GtkStyleContext *context;
GtkStateFlags flags;
GtkBorder border;
context = gtk_widget_get_style_context (widget);
flags = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, flags, &border);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
remaining_space.x = (border_width +
ipadding +
BORDER_SPACING);
remaining_space.y = (border_width +
ipadding +
BORDER_SPACING);
remaining_space.x = (border_width + border.left);
remaining_space.y = (border_width + border.top);
remaining_space.width = allocation->width -
2 * (border_width + ipadding + BORDER_SPACING);
2 * (border_width) - border.left - border.right;
remaining_space.height = allocation->height -
2 * (border_width + ipadding + BORDER_SPACING);
2 * (border_width) - border.top - border.bottom;
if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
{
GtkStyleContext *context;
GtkBorder border;
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_border (context, gtk_widget_get_state_flags (widget),
&border);
gtk_style_context_get_border (context, flags, &border);
remaining_space.x += border.left;
remaining_space.y += border.top;
+22 -104
View File
@@ -464,14 +464,24 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
GTK_PARAM_READABLE),
gtk_rc_property_parse_enum);
/**
* GtkMenuItem:horizontal-padding:
*
* Padding to left and right of the menu item.
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("horizontal-padding",
"Horizontal Padding",
"Padding to left and right of the menu item",
0,
G_MAXINT,
3,
GTK_PARAM_READABLE));
0,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("toggle-spacing",
@@ -748,8 +758,6 @@ get_arrow_size (GtkWidget *widget,
gint *size,
gint *spacing)
{
GtkStyleContext *style_context;
GtkStateFlags state;
PangoContext *context;
PangoFontMetrics *metrics;
gfloat arrow_scaling;
@@ -766,11 +774,9 @@ get_arrow_size (GtkWidget *widget,
*spacing = arrow_spacing;
context = gtk_widget_get_pango_context (child);
style_context = gtk_widget_get_style_context (child);
state = gtk_widget_get_state_flags (child);
metrics = pango_context_get_metrics (context,
gtk_style_context_get_font (style_context, state),
pango_context_get_font_description (context),
pango_context_get_language (context));
*size = (PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
@@ -804,19 +810,15 @@ gtk_menu_item_accel_width_foreach (GtkWidget *widget,
static gint
get_minimum_width (GtkWidget *widget)
{
GtkStyleContext *style_context;
GtkStateFlags state;
PangoContext *context;
PangoFontMetrics *metrics;
gint width;
gint width_chars;
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
gtk_style_context_get_font (style_context, state),
pango_context_get_font_description (context),
pango_context_get_language (context));
width = pango_font_metrics_get_approximate_char_width (metrics);
@@ -839,35 +841,16 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget,
GtkWidget *child;
GtkWidget *parent;
guint accel_width;
guint horizontal_padding;
guint border_width;
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
gint min_width, nat_width;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
min_width = nat_width = 0;
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
bin = GTK_BIN (widget);
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
{
pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent));
child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
}
else
{
pack_dir = GTK_PACK_DIRECTION_LTR;
child_pack_dir = GTK_PACK_DIRECTION_LTR;
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
context = gtk_widget_get_style_context (widget);
@@ -875,13 +858,8 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget,
gtk_style_context_get_padding (context, state, &padding);
min_width = (border_width * 2) + padding.left + padding.right;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
min_width += 2 * horizontal_padding;
nat_width = min_width;
child = gtk_bin_get_child (bin);
if (child != NULL && gtk_widget_get_visible (child))
@@ -936,10 +914,7 @@ gtk_menu_item_real_get_height (GtkWidget *widget,
GtkWidget *child;
GtkWidget *parent;
guint accel_width;
guint horizontal_padding;
guint border_width;
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
gint min_height, nat_height;
gint avail_size = 0;
@@ -949,39 +924,16 @@ gtk_menu_item_real_get_height (GtkWidget *widget,
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
bin = GTK_BIN (widget);
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
{
pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent));
child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
}
else
{
pack_dir = GTK_PACK_DIRECTION_LTR;
child_pack_dir = GTK_PACK_DIRECTION_LTR;
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
min_height = (border_width * 2) + padding.top + padding.bottom;
if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
(child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT))
min_height += 2 * horizontal_padding;
if (for_size != -1)
{
avail_size = for_size;
avail_size -= (border_width * 2) + padding.left + padding.right;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
avail_size -= 2 * horizontal_padding;
}
nat_height = min_height;
@@ -1492,7 +1444,6 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
GtkBin *bin;
GtkAllocation child_allocation;
GtkTextDirection direction;
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
GtkWidget *child;
GtkWidget *parent;
@@ -1507,12 +1458,10 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
{
pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent));
child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
}
else
{
pack_dir = GTK_PACK_DIRECTION_LTR;
child_pack_dir = GTK_PACK_DIRECTION_LTR;
}
@@ -1524,17 +1473,12 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
guint horizontal_padding;
guint border_width;
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
child_allocation.x = border_width + padding.left;
child_allocation.y = border_width + padding.top;
@@ -1544,19 +1488,6 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
child_allocation.height = allocation->height - (border_width * 2) -
padding.top - padding.bottom;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
{
child_allocation.x += horizontal_padding;
child_allocation.width -= 2 * horizontal_padding;
}
else if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
(child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT))
{
child_allocation.y += horizontal_padding;
child_allocation.height -= 2 * horizontal_padding;
}
if (child_pack_dir == GTK_PACK_DIRECTION_LTR ||
child_pack_dir == GTK_PACK_DIRECTION_RTL)
{
@@ -1726,26 +1657,20 @@ gtk_menu_item_draw (GtkWidget *widget,
{
gint arrow_x, arrow_y;
gint arrow_size;
guint horizontal_padding;
GtkTextDirection direction;
gdouble angle;
direction = gtk_widget_get_direction (widget);
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
get_arrow_size (widget, child, &arrow_size, NULL);
if (direction == GTK_TEXT_DIR_LTR)
{
arrow_x = x + w - horizontal_padding - arrow_size;
arrow_x = x + w - arrow_size;
angle = G_PI / 2;
}
else
{
arrow_x = x + horizontal_padding;
arrow_x = x;
angle = (3 * G_PI) / 2;
}
@@ -1757,24 +1682,22 @@ gtk_menu_item_draw (GtkWidget *widget,
{
gboolean wide_separators;
gint separator_height;
guint horizontal_padding;
gtk_widget_style_get (widget,
"wide-separators", &wide_separators,
"separator-height", &separator_height,
"horizontal-padding", &horizontal_padding,
NULL);
if (wide_separators)
gtk_render_frame (context, cr,
x + horizontal_padding + padding.left,
x + padding.left,
y + padding.top,
w - (2 * horizontal_padding) - padding.left - padding.right,
w - padding.left - padding.right,
separator_height);
else
gtk_render_line (context, cr,
x + horizontal_padding + padding.left,
x + padding.left,
y + padding.top,
x + w - horizontal_padding - padding.right - 1,
x + w - padding.right - 1,
y + padding.top);
}
@@ -2125,8 +2048,6 @@ get_offsets (GtkMenu *menu,
gint *horizontal_offset,
gint *vertical_offset)
{
gint vertical_padding;
gint horizontal_padding;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
@@ -2134,8 +2055,6 @@ get_offsets (GtkMenu *menu,
gtk_widget_style_get (GTK_WIDGET (menu),
"horizontal-offset", horizontal_offset,
"vertical-offset", vertical_offset,
"horizontal-padding", &horizontal_padding,
"vertical-padding", &vertical_padding,
NULL);
context = gtk_widget_get_style_context (GTK_WIDGET (menu));
@@ -2143,8 +2062,7 @@ get_offsets (GtkMenu *menu,
gtk_style_context_get_padding (context, state, &padding);
*vertical_offset -= padding.top;
*vertical_offset -= vertical_padding;
*horizontal_offset += horizontal_padding;
*horizontal_offset += padding.left;
}
static void
+1 -1
View File
@@ -1107,7 +1107,7 @@ gtk_menu_shell_leave_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
if (event->mode == GDK_CROSSING_GTK_GRAB ||
event->mode == GDK_CROSSING_GTK_GRAB ||
event->mode == GDK_CROSSING_GTK_UNGRAB ||
event->mode == GDK_CROSSING_STATE_CHANGED)
return TRUE;
+5 -12
View File
@@ -81,16 +81,6 @@ _gtk_modifier_style_init (GtkModifierStyle *modifier_style)
priv->style = gtk_style_properties_new ();
}
static GtkStyleProperties *
gtk_modifier_style_get_style (GtkStyleProvider *provider,
GtkWidgetPath *path)
{
GtkModifierStylePrivate *priv;
priv = GTK_MODIFIER_STYLE (provider)->priv;
return g_object_ref (priv->style);
}
static gboolean
gtk_modifier_style_get_style_property (GtkStyleProvider *provider,
GtkWidgetPath *path,
@@ -129,11 +119,10 @@ gtk_modifier_style_get_style_property (GtkStyleProvider *provider,
static void
gtk_modifier_style_provider_init (GtkStyleProviderIface *iface)
{
iface->get_style = gtk_modifier_style_get_style;
iface->get_style_property = gtk_modifier_style_get_style_property;
}
static GtkSymbolicColor *
static GtkCssValue *
gtk_modifier_style_provider_get_color (GtkStyleProviderPrivate *provider,
const char *name)
{
@@ -267,12 +256,16 @@ _gtk_modifier_style_map_color (GtkModifierStyle *style,
priv = style->priv;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (color)
symbolic_color = gtk_symbolic_color_new_literal (color);
gtk_style_properties_map_color (priv->style,
name, symbolic_color);
G_GNUC_END_IGNORE_DEPRECATIONS;
g_signal_emit (style, signals[CHANGED], 0);
_gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (style));
}
+2
View File
@@ -2504,6 +2504,7 @@ gtk_notebook_size_allocate (GtkWidget *widget,
{
case GTK_POS_TOP:
child_allocation.y += priv->cur_page->requisition.height;
/* fall thru */
case GTK_POS_BOTTOM:
child_allocation.height =
MAX (1, child_allocation.height -
@@ -2511,6 +2512,7 @@ gtk_notebook_size_allocate (GtkWidget *widget,
break;
case GTK_POS_LEFT:
child_allocation.x += priv->cur_page->requisition.width;
/* fall thru */
case GTK_POS_RIGHT:
child_allocation.width =
MAX (1, child_allocation.width -
+1 -1
View File
@@ -842,7 +842,7 @@ page_name_func (GtkCellLayout *cell_layout,
g_object_unref (page_setup);
}
else
g_object_set (cell, "text", _("Manage Custom Sizes..."), NULL);
g_object_set (cell, "text", _("Manage Custom Sizes"), NULL);
}
+2 -2
View File
@@ -1913,7 +1913,7 @@ selected_printer_changed (GtkTreeSelection *selection,
set_busy_cursor (dialog, TRUE);
gtk_list_store_set (GTK_LIST_STORE (priv->printer_list),
g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter"),
PRINTER_LIST_COL_STATE, _("Getting printer information..."),
PRINTER_LIST_COL_STATE, _("Getting printer information"),
-1);
return;
}
@@ -3326,7 +3326,7 @@ page_name_func (GtkCellLayout *cell_layout,
g_object_unref (page_setup);
}
else
g_object_set (cell, "text", _("Manage Custom Sizes..."), NULL);
g_object_set (cell, "text", _("Manage Custom Sizes"), NULL);
}
static void
+10
View File
@@ -37,6 +37,16 @@ G_BEGIN_DECLS
#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
#ifdef G_DISABLE_CAST_CHECKS
/* This is true for debug no and minimum */
#define gtk_internal_return_if_fail(__expr) G_STMT_START{ (void)0; }G_STMT_END
#define gtk_internal_return_val_if_fail(__expr, __val) G_STMT_START{ (void)0; }G_STMT_END
#else
/* This is true for debug yes */
#define gtk_internal_return_if_fail(__expr) g_return_if_fail(__expr)
#define gtk_internal_return_val_if_fail(__expr, __val) g_return_val_if_fail(__expr, __val)
#endif
const gchar * _gtk_get_datadir (void);
const gchar * _gtk_get_libdir (void);
const gchar * _gtk_get_sysconfdir (void);
+3 -3
View File
@@ -556,15 +556,15 @@ gtk_progress_bar_get_preferred_width (GtkWidget *widget,
if (priv->ellipsize)
{
const PangoFontDescription *font_desc;
PangoContext *context;
PangoFontMetrics *metrics;
gint char_width;
/* The minimum size for ellipsized text is ~ 3 chars */
context = pango_layout_get_context (layout);
font_desc = gtk_style_context_get_font (style_context, state);
metrics = pango_context_get_metrics (context, font_desc, pango_context_get_language (context));
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
+4 -5
View File
@@ -922,7 +922,7 @@ set_default_size (GtkRecentChooserDefault *impl)
GtkScrolledWindow *scrollw;
GtkWidget *widget;
gint width, height;
gint font_size;
double font_size;
GdkScreen *screen;
gint monitor_num;
GtkRequisition req;
@@ -935,11 +935,10 @@ set_default_size (GtkRecentChooserDefault *impl)
state = gtk_widget_get_state_flags (widget);
/* Size based on characters and the icon size */
font_size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
font_size = PANGO_PIXELS (font_size);
gtk_style_context_get (context, state, "font-size", &font_size, NULL);
width = impl->icon_size + font_size * NUM_CHARS;
height = (impl->icon_size + font_size) * NUM_LINES;
width = impl->icon_size + font_size * NUM_CHARS + 0.5;
height = (impl->icon_size + font_size) * NUM_LINES + 0.5;
/* Use at least the requisition size... */
gtk_widget_get_preferred_size (widget, &req, NULL);
+1 -1
View File
@@ -284,7 +284,7 @@ _gtk_rounded_box_guess_length (const GtkRoundedBox *box,
GtkCssSide side)
{
double length;
GtkCssCorner before, after;
GtkCssSide before, after;
before = side;
after = (side + 1) % 4;
+4
View File
@@ -1196,7 +1196,9 @@ gtk_scale_draw (GtkWidget *widget,
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_MARK);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR);
gtk_render_line (context, cr, x1, y1, x1, y2);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SEPARATOR);
if (mark->markup)
{
@@ -1247,7 +1249,9 @@ gtk_scale_draw (GtkWidget *widget,
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_MARK);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR);
gtk_render_line (context, cr, x1, y1, x2, y1);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SEPARATOR);
if (mark->markup)
{
+17 -456
View File
@@ -32,7 +32,6 @@
#include "gtkprivate.h"
#include "gtkcssproviderprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtksymboliccolor.h"
#include "gtktypebuiltins.h"
#include "gtkversion.h"
@@ -115,7 +114,6 @@ struct _GtkSettingsPrivate
GdkScreen *screen;
GtkCssProvider *theme_provider;
GtkCssProvider *key_theme_provider;
GtkStyleProperties *style;
};
typedef enum
@@ -241,15 +239,9 @@ static void settings_update_cursor_theme (GtkSettings *setting
static void settings_update_resolution (GtkSettings *settings);
static void settings_update_font_options (GtkSettings *settings);
static gboolean settings_update_fontconfig (GtkSettings *settings);
static void settings_update_color_scheme (GtkSettings *settings);
static void settings_update_theme (GtkSettings *settings);
static void settings_update_key_theme (GtkSettings *settings);
static void merge_color_scheme (GtkSettings *settings,
const GValue *value,
GtkSettingsSource source);
static gchar *get_color_scheme (GtkSettings *settings);
static GHashTable *get_color_hash (GtkSettings *settings);
static void gtk_settings_load_from_key_file (GtkSettings *settings,
const gchar *path,
GtkSettingsSource source);
@@ -694,6 +686,9 @@ gtk_settings_class_init (GtkSettingsClass *class)
* </programlisting>
*
* Since: 2.10
*
* Deprecated: 3.8: Color scheme support was dropped and is no longer supported.
* You can still set this property, but it will be ignored.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-color-scheme",
@@ -869,6 +864,8 @@ gtk_settings_class_init (GtkSettingsClass *class)
* setting, mapping color names to #GdkColor<!-- -->s.
*
* Since: 2.10
*
* Deprecated: 3.8: Will always return an empty hash table.
*/
result = settings_install_property_parser (class,
g_param_spec_boxed ("color-hash",
@@ -1412,149 +1409,29 @@ gtk_settings_class_init (GtkSettingsClass *class)
g_type_class_add_private (class, sizeof (GtkSettingsPrivate));
}
static void
settings_ensure_style (GtkSettings *settings)
{
GtkSettingsPrivate *priv = settings->priv;
PangoFontDescription *font_desc;
gchar *font_name, *color_scheme;
gchar **colors;
guint i;
if (priv->style)
return;
priv->style = gtk_style_properties_new ();
g_object_get (settings,
"gtk-font-name", &font_name,
"gtk-color-scheme", &color_scheme,
NULL);
colors = g_strsplit_set (color_scheme, "\n;", -1);
for (i = 0; colors[i]; i++)
{
GtkSymbolicColor *color;
gchar *name, *pos;
GdkRGBA col;
if (!*colors[i])
continue;
name = colors[i];
pos = strchr (colors[i], ':');
if (!pos)
continue;
/* Set NUL after color name */
*pos = '\0';
pos++;
/* Find start of color string */
while (*pos == ' ')
pos++;
if (!*pos || !gdk_rgba_parse (&col, pos))
continue;
color = gtk_symbolic_color_new_literal (&col);
gtk_style_properties_map_color (priv->style, name, color);
gtk_symbolic_color_unref (color);
}
font_desc = pango_font_description_from_string (font_name);
/* Unset normal attributes from this description,
* so they do not override theme values */
if (pango_font_description_get_weight (font_desc) == PANGO_WEIGHT_NORMAL)
pango_font_description_unset_fields (font_desc,
PANGO_FONT_MASK_WEIGHT);
if (pango_font_description_get_stretch (font_desc) == PANGO_STRETCH_NORMAL)
pango_font_description_unset_fields (font_desc,
PANGO_FONT_MASK_STRETCH);
if (pango_font_description_get_variant (font_desc) == PANGO_VARIANT_NORMAL)
pango_font_description_unset_fields (font_desc,
PANGO_FONT_MASK_VARIANT);
if (pango_font_description_get_style (font_desc) == PANGO_STYLE_NORMAL)
pango_font_description_unset_fields (font_desc,
PANGO_FONT_MASK_STYLE);
gtk_style_properties_set (priv->style, 0,
"font", font_desc,
NULL);
pango_font_description_free (font_desc);
g_strfreev (colors);
g_free (color_scheme);
g_free (font_name);
}
static GtkStyleProperties *
gtk_settings_get_style (GtkStyleProvider *provider,
GtkWidgetPath *path)
{
GtkSettings *settings;
settings = GTK_SETTINGS (provider);
settings_ensure_style (settings);
return g_object_ref (settings->priv->style);
}
static void
gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
{
iface->get_style = gtk_settings_get_style;
}
static GtkSymbolicColor *
gtk_settings_style_provider_get_color (GtkStyleProviderPrivate *provider,
const char *name)
{
GtkSettings *settings = GTK_SETTINGS (provider);
settings_ensure_style (settings);
return _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style), name);
}
static void
gtk_settings_style_provider_lookup (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
GtkCssLookup *lookup)
{
GtkSettings *settings = GTK_SETTINGS (provider);
settings_ensure_style (settings);
_gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style),
matcher,
lookup);
}
static GtkCssChange
gtk_settings_style_provider_get_change (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher)
const GtkCssMatcher *matcher)
{
GtkSettings *settings = GTK_SETTINGS (provider);
return 0;
}
settings_ensure_style (settings);
return _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style),
matcher);
static GtkSettings *
gtk_settings_style_provider_get_settings (GtkStyleProviderPrivate *provider)
{
return GTK_SETTINGS (provider);
}
static void
gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface)
{
iface->get_color = gtk_settings_style_provider_get_color;
iface->lookup = gtk_settings_style_provider_lookup;
iface->get_settings = gtk_settings_style_provider_get_settings;
iface->get_change = gtk_settings_style_provider_get_change;
}
@@ -1576,8 +1453,6 @@ gtk_settings_finalize (GObject *object)
settings_update_provider (priv->screen, &priv->theme_provider, NULL);
settings_update_provider (priv->screen, &priv->key_theme_provider, NULL);
g_clear_object (&priv->style);
G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object);
}
@@ -1661,7 +1536,6 @@ gtk_settings_get_for_screen (GdkScreen *screen)
settings_update_cursor_theme (settings);
settings_update_resolution (settings);
settings_update_font_options (settings);
settings_update_color_scheme (settings);
}
return settings;
@@ -1698,9 +1572,6 @@ gtk_settings_set_property (GObject *object,
g_value_copy (value, &priv->property_values[property_id - 1].value);
priv->property_values[property_id - 1].source = GTK_SETTINGS_SOURCE_APPLICATION;
if (pspec->param_id == PROP_COLOR_SCHEME)
merge_color_scheme (settings, value, GTK_SETTINGS_SOURCE_APPLICATION);
}
static void
@@ -1718,10 +1589,9 @@ gtk_settings_get_property (GObject *object,
switch (property_id)
{
case PROP_COLOR_HASH:
g_value_set_boxed (value, get_color_hash (settings));
return;
case PROP_COLOR_SCHEME:
g_value_take_string (value, get_color_scheme (settings));
g_value_take_boxed (value,
g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) gdk_color_free));
return;
default: ;
}
@@ -1788,14 +1658,6 @@ gtk_settings_get_property (GObject *object,
static void
settings_invalidate_style (GtkSettings *settings)
{
GtkSettingsPrivate *priv = settings->priv;
if (priv->style)
{
g_object_unref (priv->style);
priv->style = NULL;
}
_gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (settings));
}
@@ -1819,11 +1681,6 @@ gtk_settings_notify (GObject *object,
case PROP_DOUBLE_CLICK_DISTANCE:
settings_update_double_click (settings);
break;
case PROP_COLOR_SCHEME:
settings_update_color_scheme (settings);
settings_invalidate_style (settings);
gtk_style_context_reset_widgets (priv->screen);
break;
case PROP_FONT_NAME:
settings_invalidate_style (settings);
gtk_style_context_reset_widgets (priv->screen);
@@ -1945,9 +1802,6 @@ apply_queued_setting (GtkSettings *settings,
if (_gtk_settings_parse_convert (parser, &qvalue->public.value,
pspec, &tmp_value))
{
if (pspec->param_id == PROP_COLOR_SCHEME)
merge_color_scheme (settings, &tmp_value, qvalue->source);
if (priv->property_values[pspec->param_id - 1].source <= qvalue->source)
{
g_value_copy (&tmp_value, &priv->property_values[pspec->param_id - 1].value);
@@ -2578,28 +2432,13 @@ _gtk_settings_handle_event (GdkEventSetting *event)
GdkScreen *screen;
GtkSettings *settings;
GParamSpec *pspec;
guint property_id;
screen = gdk_window_get_screen (event->window);
settings = gtk_settings_get_for_screen (screen);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), event->name);
if (pspec)
{
property_id = pspec->param_id;
if (property_id == PROP_COLOR_SCHEME)
{
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_STRING);
if (!gdk_screen_get_setting (screen, pspec->name, &value))
g_value_set_static_string (&value, "");
merge_color_scheme (settings, &value, GTK_SETTINGS_SOURCE_XSETTING);
g_value_unset (&value);
}
g_object_notify (G_OBJECT (settings), pspec->name);
}
g_object_notify (G_OBJECT (settings), pspec->name);
}
static void
@@ -2847,54 +2686,6 @@ settings_update_resolution (GtkSettings *settings)
gdk_screen_set_resolution (priv->screen, dpi);
}
typedef struct
{
GHashTable *color_hash;
GHashTable *tables[GTK_SETTINGS_SOURCE_APPLICATION + 1];
gchar *lastentry[GTK_SETTINGS_SOURCE_APPLICATION + 1];
} ColorSchemeData;
static void
color_scheme_data_free (ColorSchemeData *data)
{
gint i;
g_hash_table_unref (data->color_hash);
for (i = 0; i <= GTK_SETTINGS_SOURCE_APPLICATION; i++)
{
if (data->tables[i])
g_hash_table_unref (data->tables[i]);
g_free (data->lastentry[i]);
}
g_slice_free (ColorSchemeData, data);
}
static void
settings_update_color_scheme (GtkSettings *settings)
{
if (!g_object_get_data (G_OBJECT (settings), "gtk-color-scheme"))
{
GtkSettingsPrivate *priv = settings->priv;
ColorSchemeData *data;
GValue value = G_VALUE_INIT;
data = g_slice_new0 (ColorSchemeData);
data->color_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) gdk_color_free);
g_object_set_data_full (G_OBJECT (settings), "gtk-color-scheme",
data, (GDestroyNotify) color_scheme_data_free);
g_value_init (&value, G_TYPE_STRING);
if (priv->screen && gdk_screen_get_setting (priv->screen, "gtk-color-scheme", &value))
{
merge_color_scheme (settings, &value, GTK_SETTINGS_SOURCE_XSETTING);
g_value_unset (&value);
}
}
}
static void
settings_update_provider (GdkScreen *screen,
GtkCssProvider **old,
@@ -2979,236 +2770,6 @@ settings_update_key_theme (GtkSettings *settings)
g_free (key_theme_name);
}
static gboolean
add_color_to_hash (gchar *name,
GdkColor *color,
GHashTable *target)
{
GdkColor *old;
old = g_hash_table_lookup (target, name);
if (!old || !gdk_color_equal (old, color))
{
g_hash_table_insert (target, g_strdup (name), gdk_color_copy (color));
return TRUE;
}
return FALSE;
}
static gboolean
add_colors_to_hash_from_string (GHashTable *hash,
const gchar *colors)
{
gchar *s, *p, *name;
GdkColor color;
gboolean changed = FALSE;
gchar *copy;
copy = g_strdup (colors);
s = copy;
while (s && *s)
{
name = s;
p = strchr (s, ':');
if (p)
{
*p = '\0';
p++;
}
else
break;
while (*p == ' ')
p++;
s = p;
while (*s)
{
if (*s == '\n' || *s == ';')
{
*s = '\0';
s++;
break;
}
s++;
}
if (gdk_color_parse (p, &color))
changed |= add_color_to_hash (name, &color, hash);
}
g_free (copy);
return changed;
}
static gboolean
update_color_hash (ColorSchemeData *data,
const gchar *str,
GtkSettingsSource source)
{
gboolean changed = FALSE;
gint i;
GHashTable *old_hash;
GHashTableIter iter;
gpointer name;
gpointer color;
if ((str == NULL || *str == '\0') &&
(data->lastentry[source] == NULL || data->lastentry[source][0] == '\0'))
return FALSE;
if (str && data->lastentry[source] && strcmp (str, data->lastentry[source]) == 0)
return FALSE;
/* For the THEME source we merge the values rather than over-writing
* them, since multiple rc files might define independent sets of colors
*/
if ((source != GTK_SETTINGS_SOURCE_THEME) &&
data->tables[source] && g_hash_table_size (data->tables[source]) > 0)
{
g_hash_table_unref (data->tables[source]);
data->tables[source] = NULL;
changed = TRUE; /* We can't rely on the code below since str might be "" */
}
if (data->tables[source] == NULL)
data->tables[source] = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
(GDestroyNotify) gdk_color_free);
g_free (data->lastentry[source]);
data->lastentry[source] = g_strdup (str);
changed |= add_colors_to_hash_from_string (data->tables[source], str);
if (!changed)
return FALSE;
/* Rebuild the merged hash table. */
if (data->color_hash)
{
old_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) gdk_color_free);
g_hash_table_iter_init (&iter, data->color_hash);
while (g_hash_table_iter_next (&iter, &name, &color))
{
g_hash_table_insert (old_hash, name, color);
g_hash_table_iter_steal (&iter);
}
}
else
{
old_hash = NULL;
}
for (i = 0; i <= GTK_SETTINGS_SOURCE_APPLICATION; i++)
{
if (data->tables[i])
g_hash_table_foreach (data->tables[i], (GHFunc) add_color_to_hash,
data->color_hash);
}
if (old_hash)
{
/* now check if the merged hash has changed */
changed = FALSE;
if (g_hash_table_size (old_hash) != g_hash_table_size (data->color_hash))
changed = TRUE;
else
{
GHashTableIter iter;
gpointer key, value, new_value;
g_hash_table_iter_init (&iter, old_hash);
while (g_hash_table_iter_next (&iter, &key, &value))
{
new_value = g_hash_table_lookup (data->color_hash, key);
if (!new_value || !gdk_color_equal (value, new_value))
{
changed = TRUE;
break;
}
}
}
g_hash_table_unref (old_hash);
}
else
changed = TRUE;
return changed;
}
static void
merge_color_scheme (GtkSettings *settings,
const GValue *value,
GtkSettingsSource source)
{
ColorSchemeData *data;
const gchar *colors;
g_object_freeze_notify (G_OBJECT (settings));
colors = g_value_get_string (value);
settings_update_color_scheme (settings);
data = (ColorSchemeData *) g_object_get_data (G_OBJECT (settings),
"gtk-color-scheme");
if (update_color_hash (data, colors, source))
g_object_notify (G_OBJECT (settings), "color-hash");
g_object_thaw_notify (G_OBJECT (settings));
}
static GHashTable *
get_color_hash (GtkSettings *settings)
{
ColorSchemeData *data;
settings_update_color_scheme (settings);
data = (ColorSchemeData *)g_object_get_data (G_OBJECT (settings),
"gtk-color-scheme");
return data->color_hash;
}
static void
append_color_scheme (gpointer key,
gpointer value,
gpointer data)
{
gchar *name = (gchar *)key;
GdkColor *color = (GdkColor *)value;
GString *string = (GString *)data;
g_string_append_printf (string, "%s: #%04x%04x%04x\n",
name, color->red, color->green, color->blue);
}
static gchar *
get_color_scheme (GtkSettings *settings)
{
ColorSchemeData *data;
GString *string;
settings_update_color_scheme (settings);
data = (ColorSchemeData *) g_object_get_data (G_OBJECT (settings),
"gtk-color-scheme");
string = g_string_new ("");
g_hash_table_foreach (data->color_hash, append_color_scheme, string);
return g_string_free (string, FALSE);
}
GdkScreen *
_gtk_settings_get_screen (GtkSettings *settings)
+17 -8
View File
@@ -152,17 +152,18 @@ G_STATIC_ASSERT (GTK_SIZE_GROUP_VERTICAL == (1 << GTK_ORIENTATION_VERTICAL));
G_STATIC_ASSERT (GTK_SIZE_GROUP_BOTH == (GTK_SIZE_GROUP_HORIZONTAL | GTK_SIZE_GROUP_VERTICAL));
static void
add_widget_to_closure (GHashTable *set,
add_widget_to_closure (GHashTable *widgets,
GHashTable *groups,
GtkWidget *widget,
GtkOrientation orientation)
{
GSList *tmp_groups, *tmp_widgets;
gboolean hidden;
if (g_hash_table_lookup (set, widget))
if (g_hash_table_lookup (widgets, widget))
return;
g_hash_table_insert (set, widget, widget);
g_hash_table_add (widgets, widget);
hidden = !gtk_widget_is_visible (widget);
for (tmp_groups = _gtk_widget_get_sizegroups (widget); tmp_groups; tmp_groups = tmp_groups->next)
@@ -170,14 +171,19 @@ add_widget_to_closure (GHashTable *set,
GtkSizeGroup *tmp_group = tmp_groups->data;
GtkSizeGroupPrivate *tmp_priv = tmp_group->priv;
if (g_hash_table_lookup (groups, tmp_group))
continue;
if (tmp_priv->ignore_hidden && hidden)
continue;
if (!(tmp_priv->mode & (1 << orientation)))
continue;
g_hash_table_add (groups, tmp_group);
for (tmp_widgets = tmp_priv->widgets; tmp_widgets; tmp_widgets = tmp_widgets->next)
add_widget_to_closure (set, tmp_widgets->data, orientation);
add_widget_to_closure (widgets, groups, tmp_widgets->data, orientation);
}
}
@@ -185,13 +191,16 @@ GHashTable *
_gtk_size_group_get_widget_peers (GtkWidget *for_widget,
GtkOrientation orientation)
{
GHashTable *result;
GHashTable *widgets, *groups;
result = g_hash_table_new (g_direct_hash, g_direct_equal);
widgets = g_hash_table_new (g_direct_hash, g_direct_equal);
groups = g_hash_table_new (g_direct_hash, g_direct_equal);
add_widget_to_closure (result, for_widget, orientation);
add_widget_to_closure (widgets, groups, for_widget, orientation);
return result;
g_hash_table_unref (groups);
return widgets;
}
static void
+29 -26
View File
@@ -91,16 +91,6 @@ gtk_style_cascade_iter_init (GtkStyleCascade *cascade,
return gtk_style_cascade_iter_next (cascade, iter);
}
static GtkStyleProperties *
gtk_style_cascade_get_style (GtkStyleProvider *provider,
GtkWidgetPath *path)
{
/* This function is not used anymore by GTK and nobody
* else is ever supposed to call it */
g_warn_if_reached ();
return NULL;
}
static gboolean
gtk_style_cascade_get_style_property (GtkStyleProvider *provider,
GtkWidgetPath *path,
@@ -127,30 +117,42 @@ gtk_style_cascade_get_style_property (GtkStyleProvider *provider,
return FALSE;
}
static GtkIconFactory *
gtk_style_cascade_get_icon_factory (GtkStyleProvider *provider,
GtkWidgetPath *path)
{
/* If anyone ever implements get_icon_factory(), I'll
* look at this function. Until then I'll just: */
return NULL;
}
static void
gtk_style_cascade_provider_iface_init (GtkStyleProviderIface *iface)
{
iface->get_style = gtk_style_cascade_get_style;
iface->get_style_property = gtk_style_cascade_get_style_property;
iface->get_icon_factory = gtk_style_cascade_get_icon_factory;
}
static GtkSymbolicColor *
static GtkSettings *
gtk_style_cascade_get_settings (GtkStyleProviderPrivate *provider)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascadeIter iter;
GtkSettings *settings;
GtkStyleProvider *item;
for (item = gtk_style_cascade_iter_init (cascade, &iter);
item;
item = gtk_style_cascade_iter_next (cascade, &iter))
{
if (!GTK_IS_STYLE_PROVIDER_PRIVATE (item))
continue;
settings = _gtk_style_provider_private_get_settings (GTK_STYLE_PROVIDER_PRIVATE (item));
if (settings)
return settings;
}
return NULL;
}
static GtkCssValue *
gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
const char *name)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascadeIter iter;
GtkSymbolicColor *symbolic;
GtkCssValue *color;
GtkStyleProvider *item;
for (item = gtk_style_cascade_iter_init (cascade, &iter);
@@ -159,9 +161,9 @@ gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
{
if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
{
symbolic = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name);
if (symbolic)
return symbolic;
color = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name);
if (color)
return color;
}
else
{
@@ -254,6 +256,7 @@ static void
gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface)
{
iface->get_color = gtk_style_cascade_get_color;
iface->get_settings = gtk_style_cascade_get_settings;
iface->get_keyframes = gtk_style_cascade_get_keyframes;
iface->lookup = gtk_style_cascade_lookup;
iface->get_change = gtk_style_cascade_get_change;
+63 -39
View File
@@ -24,11 +24,11 @@
#include "gtkstylecontextprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssenginevalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkdebug.h"
#include "gtkgradientprivate.h"
#include "gtkstylepropertiesprivate.h"
#include "gtktypebuiltins.h"
#include "gtkthemingengineprivate.h"
@@ -36,7 +36,6 @@
#include "gtkwidget.h"
#include "gtkwindow.h"
#include "gtkprivate.h"
#include "gtksymboliccolorprivate.h"
#include "gtkiconfactory.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
@@ -45,6 +44,9 @@
#include "gtksettings.h"
#include "gtksettingsprivate.h"
#include "deprecated/gtkgradientprivate.h"
#include "deprecated/gtksymboliccolorprivate.h"
/**
* SECTION:gtkstylecontext
* @Short_description: Rendering UI elements
@@ -370,7 +372,7 @@ struct _GtkStyleContextPrivate
GtkCssChange relevant_changes;
GtkCssChange pending_changes;
guint invalidating_context : 1;
const GtkBitmask *invalidating_context;
guint invalid : 1;
};
@@ -2220,17 +2222,6 @@ _gtk_style_context_peek_property (GtkStyleContext *context,
return _gtk_css_computed_values_get_value (data->store, property_id);
}
double
_gtk_style_context_get_number (GtkStyleContext *context,
guint property_id,
double one_hundred_percent)
{
GtkCssValue *value;
value = _gtk_style_context_peek_property (context, property_id);
return _gtk_css_number_value_get (value, one_hundred_percent);
}
const GValue *
_gtk_style_context_peek_style_property (GtkStyleContext *context,
GType widget_type,
@@ -2282,6 +2273,8 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
widget_path,
state, pspec, &pcache->value))
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
/* Resolve symbolic colors to GdkColor/GdkRGBA */
if (G_VALUE_TYPE (&pcache->value) == GTK_TYPE_SYMBOLIC_COLOR)
{
@@ -2297,7 +2290,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
else
g_value_init (&pcache->value, GDK_TYPE_COLOR);
if (_gtk_style_context_resolve_color (context, color, &rgba, NULL))
if (_gtk_style_context_resolve_color (context, _gtk_symbolic_color_get_css_value (color), &rgba, NULL))
{
if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA)
g_value_set_boxed (&pcache->value, &rgba);
@@ -2318,6 +2311,8 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
gtk_symbolic_color_unref (color);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
if (priv->widget)
gtk_widget_path_free (widget_path);
@@ -2703,7 +2698,7 @@ gtk_style_context_get_junction_sides (GtkStyleContext *context)
gboolean
_gtk_style_context_resolve_color (GtkStyleContext *context,
GtkSymbolicColor *color,
GtkCssValue *color,
GdkRGBA *result,
GtkCssDependencies *dependencies)
{
@@ -2713,11 +2708,11 @@ _gtk_style_context_resolve_color (GtkStyleContext *context,
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (result != NULL, FALSE);
val = _gtk_symbolic_color_resolve_full (color,
GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade),
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
val = _gtk_css_color_value_resolve (color,
GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade),
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
if (val == NULL)
return FALSE;
@@ -2741,17 +2736,17 @@ gtk_style_context_lookup_color (GtkStyleContext *context,
const gchar *color_name,
GdkRGBA *color)
{
GtkSymbolicColor *sym_color;
GtkCssValue *value;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
g_return_val_if_fail (color_name != NULL, FALSE);
g_return_val_if_fail (color != NULL, FALSE);
sym_color = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade), color_name);
if (sym_color == NULL)
value = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade), color_name);
if (value == NULL)
return FALSE;
return _gtk_style_context_resolve_color (context, sym_color, color, NULL);
return _gtk_style_context_resolve_color (context, value, color, NULL);
}
/**
@@ -2965,7 +2960,8 @@ gtk_style_context_update_cache (GtkStyleContext *context,
}
static void
gtk_style_context_do_invalidate (GtkStyleContext *context)
gtk_style_context_do_invalidate (GtkStyleContext *context,
const GtkBitmask *changes)
{
GtkStyleContextPrivate *priv;
@@ -2977,11 +2973,11 @@ gtk_style_context_do_invalidate (GtkStyleContext *context)
if (priv->invalidating_context)
return;
priv->invalidating_context = TRUE;
priv->invalidating_context = changes;
g_signal_emit (context, signals[CHANGED], 0);
priv->invalidating_context = FALSE;
priv->invalidating_context = NULL;
}
static GtkBitmask *
@@ -3171,7 +3167,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
}
if (!_gtk_bitmask_is_empty (changes) || (change & GTK_CSS_CHANGE_FORCE_INVALIDATE))
gtk_style_context_do_invalidate (context);
gtk_style_context_do_invalidate (context, changes);
change = _gtk_css_change_for_child (change);
for (list = priv->children; list; list = list->next)
@@ -3220,10 +3216,18 @@ _gtk_style_context_queue_invalidate (GtkStyleContext *context,
void
gtk_style_context_invalidate (GtkStyleContext *context)
{
GtkBitmask *changes;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
gtk_style_context_clear_cache (context);
gtk_style_context_do_invalidate (context);
changes = _gtk_bitmask_new ();
changes = _gtk_bitmask_invert_range (changes,
0,
_gtk_css_style_property_get_n_properties ());
gtk_style_context_do_invalidate (context, changes);
_gtk_bitmask_free (changes);
}
/**
@@ -3464,6 +3468,9 @@ gtk_style_context_get_margin (GtkStyleContext *context,
* freed.
*
* Since: 3.0
*
* Deprecated: 3.8: Use gtk_style_context_get() for "font" or
* subproperties instead.
**/
const PangoFontDescription *
gtk_style_context_get_font (GtkStyleContext *context,
@@ -3482,15 +3489,12 @@ gtk_style_context_get_font (GtkStyleContext *context,
/* Yuck, fonts are created on-demand but we don't return a ref.
* Do bad things to achieve this requirement */
description = g_object_get_data (G_OBJECT (data->store), "font-cache-for-get_font");
if (description == NULL)
{
gtk_style_context_get (context, state, "font", &description, NULL);
g_object_set_data_full (G_OBJECT (data->store),
"font-cache-for-get_font",
description,
(GDestroyNotify) pango_font_description_free);
}
gtk_style_context_get (context, state, "font", &description, NULL);
g_object_set_data_full (G_OBJECT (data->store),
"font-cache-for-get_font",
description,
(GDestroyNotify) pango_font_description_free);
return description;
}
@@ -4497,6 +4501,26 @@ gtk_draw_insertion_cursor (GtkWidget *widget,
draw_arrow);
}
/**
* _gtk_style_context_get_changes:
* @context: the context to query
*
* Queries the context for the changes for the currently executing
* GtkStyleContext::invalidate signal. If no signal is currently
* emitted, this function returns %NULL.
*
* FIXME 4.0: Make this part of the signal.
*
* Returns: %NULL or the currently invalidating changes
**/
const GtkBitmask *
_gtk_style_context_get_changes (GtkStyleContext *context)
{
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
return context->priv->invalidating_context;
}
static AtkAttributeSet *
add_attribute (AtkAttributeSet *attributes,
AtkTextAttribute attr,
+2
View File
@@ -879,6 +879,8 @@ void gtk_style_context_get_background_color (GtkStyleContext *context,
void gtk_style_context_get_border_color (GtkStyleContext *context,
GtkStateFlags state,
GdkRGBA *color);
GDK_DEPRECATED_IN_3_8_FOR(gtk_style_context_get)
const PangoFontDescription *
gtk_style_context_get_font (GtkStyleContext *context,
GtkStateFlags state);
+4 -5
View File
@@ -20,7 +20,6 @@
#include "gtkstylecontext.h"
#include "gtkstyleproviderprivate.h"
#include "gtksymboliccolor.h"
#include "gtkbitmaskprivate.h"
#include "gtkcssvalueprivate.h"
@@ -28,11 +27,11 @@ G_BEGIN_DECLS
void _gtk_style_context_set_widget (GtkStyleContext *context,
GtkWidget *widget);
const GtkBitmask *
_gtk_style_context_get_changes (GtkStyleContext *context);
GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context,
guint property_id);
double _gtk_style_context_get_number (GtkStyleContext *context,
guint property_id,
double one_hundred_percent);
const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
GType widget_type,
GtkStateFlags state,
@@ -46,7 +45,7 @@ void _gtk_style_context_queue_invalidate (GtkStyleContext *c
gboolean _gtk_style_context_check_region_name (const gchar *str);
gboolean _gtk_style_context_resolve_color (GtkStyleContext *context,
GtkSymbolicColor *color,
GtkCssValue *color,
GdkRGBA *result,
GtkCssDependencies *dependencies);
void _gtk_style_context_get_cursor_color (GtkStyleContext *context,
+25 -14
View File
@@ -24,9 +24,7 @@
#include <cairo-gobject.h>
#include "gtkstyleprovider.h"
#include "gtksymboliccolor.h"
#include "gtkthemingengine.h"
#include "gtkgradient.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtkcsstypedvalueprivate.h"
#include "gtkcsstypesprivate.h"
@@ -36,9 +34,11 @@
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkintl.h"
#include "gtkwin32themeprivate.h"
#include "deprecated/gtkgradient.h"
#include "deprecated/gtksymboliccolorprivate.h"
/**
* SECTION:gtkstyleproperties
* @Short_description: Store for style property information
@@ -279,25 +279,26 @@ gtk_style_properties_finalize (GObject *object)
G_OBJECT_CLASS (gtk_style_properties_parent_class)->finalize (object);
}
static GtkStyleProperties *
gtk_style_properties_get_style (GtkStyleProvider *provider,
GtkWidgetPath *path)
{
/* Return style set itself */
return g_object_ref (provider);
}
static void
gtk_style_properties_provider_init (GtkStyleProviderIface *iface)
{
iface->get_style = gtk_style_properties_get_style;
}
static GtkSymbolicColor *
static GtkCssValue *
gtk_style_properties_provider_get_color (GtkStyleProviderPrivate *provider,
const char *name)
{
return gtk_style_properties_lookup_color (GTK_STYLE_PROPERTIES (provider), name);
GtkSymbolicColor *symbolic;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
symbolic = gtk_style_properties_lookup_color (GTK_STYLE_PROPERTIES (provider), name);
if (symbolic == NULL)
return NULL;
return _gtk_symbolic_color_get_css_value (symbolic);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
static void
@@ -376,6 +377,8 @@ gtk_style_properties_new (void)
* gtk_style_properties_lookup_color()
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
void
gtk_style_properties_map_color (GtkStyleProperties *props,
@@ -390,6 +393,8 @@ gtk_style_properties_map_color (GtkStyleProperties *props,
priv = props->priv;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (G_UNLIKELY (!priv->color_map))
priv->color_map = g_hash_table_new_full (g_str_hash,
g_str_equal,
@@ -400,6 +405,8 @@ gtk_style_properties_map_color (GtkStyleProperties *props,
g_strdup (name),
gtk_symbolic_color_ref (color));
G_GNUC_END_IGNORE_DEPRECATIONS;
_gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
}
@@ -414,6 +421,8 @@ gtk_style_properties_map_color (GtkStyleProperties *props,
* Returns: (transfer none): The mapped color
*
* Since: 3.0
*
* Deprecated: 3.8: #GtkSymbolicColor is deprecated.
**/
GtkSymbolicColor *
gtk_style_properties_lookup_color (GtkStyleProperties *props,
@@ -870,7 +879,9 @@ gtk_style_properties_merge (GtkStyleProperties *props,
g_hash_table_lookup (priv->color_map, name))
continue;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_style_properties_map_color (props, name, color);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
}
+4
View File
@@ -66,17 +66,21 @@ typedef gboolean (* GtkStylePropertyParser) (const gchar *string,
GType gtk_style_properties_get_type (void) G_GNUC_CONST;
/* Next 2 are implemented in gtkcsscustomproperty.c */
GDK_DEPRECATED_IN_3_8
void gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
GParamSpec *pspec);
GDK_DEPRECATED_IN_3_8
gboolean gtk_style_properties_lookup_property (const gchar *property_name,
GtkStylePropertyParser *parse_func,
GParamSpec **pspec);
GtkStyleProperties * gtk_style_properties_new (void);
GDK_DEPRECATED_IN_3_8
void gtk_style_properties_map_color (GtkStyleProperties *props,
const gchar *name,
GtkSymbolicColor *color);
GDK_DEPRECATED_IN_3_8
GtkSymbolicColor * gtk_style_properties_lookup_color (GtkStyleProperties *props,
const gchar *name);
-1
View File
@@ -21,7 +21,6 @@
#include "gtkstyleproperties.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtksymboliccolorprivate.h"
G_BEGIN_DECLS
+5
View File
@@ -66,6 +66,9 @@ gtk_style_provider_iface_init (gpointer g_iface)
* style settings affecting @path
*
* Since: 3.0
*
* Deprecated: 3.8: Will always return %NULL for all GTK-provided style providers
* as the interface cannot correctly work the way CSS is specified.
**/
GtkStyleProperties *
gtk_style_provider_get_style (GtkStyleProvider *provider,
@@ -132,6 +135,8 @@ gtk_style_provider_get_style_property (GtkStyleProvider *provider,
* Returns: (transfer none): The icon factory to use for @path, or %NULL
*
* Since: 3.0
*
* Deprecated: 3.8: Will always return %NULL for all GTK-provided style providers.
**/
GtkIconFactory *
gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,
+2
View File
@@ -109,6 +109,7 @@ struct _GtkStyleProviderIface
GType gtk_style_provider_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_8
GtkStyleProperties *gtk_style_provider_get_style (GtkStyleProvider *provider,
GtkWidgetPath *path);
@@ -118,6 +119,7 @@ gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider,
GParamSpec *pspec,
GValue *value);
GDK_DEPRECATED_IN_3_8_FOR(NULL)
GtkIconFactory * gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,
GtkWidgetPath *path);
+16 -1
View File
@@ -44,7 +44,7 @@ _gtk_style_provider_private_default_init (GtkStyleProviderPrivateInterface *ifac
}
GtkSymbolicColor *
GtkCssValue *
_gtk_style_provider_private_get_color (GtkStyleProviderPrivate *provider,
const char *name)
{
@@ -125,3 +125,18 @@ _gtk_style_provider_private_changed (GtkStyleProviderPrivate *provider)
g_signal_emit (provider, signals[CHANGED], 0);
}
GtkSettings *
_gtk_style_provider_private_get_settings (GtkStyleProviderPrivate *provider)
{
GtkStyleProviderPrivateInterface *iface;
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
if (!iface->get_settings)
return NULL;
return iface->get_settings (provider);
}

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