Commit Graph

1451 Commits

Author SHA1 Message Date
Jasper St. Pierre
4da945dc4b widget: Don't queue redraws for properties that don't affect anything
Properties like transition-property might change when hovering over
something, even if the property itself does not change. These properties
don't affect drawing, so don't queue redraws for them.
2015-08-02 12:57:31 -07:00
Matthias Clasen
9f24b54786 Code cleanup
Use g_slist_free_full more consistently. This commit just converts
the obvious cases where g_slist_forall is directly followed by
g_slist_free.
2015-07-31 22:23:35 -04:00
Timm Bäder
56051b0bd8 GtkWidget: Fix set_font_map docs
A typo and non-matching parameter names.
2015-07-23 17:59:17 +02:00
Matthias Clasen
e7fe194b2d GtkWidget: Add custom font map support
This allows to use a custom font map for parts of the widget
hierarchy - this can be used for application-specific fonts.

https://bugzilla.gnome.org/show_bug.cgi?id=751812
2015-07-19 16:58:43 -04:00
Matthias Clasen
28e1ed4f2a Fix warnings in the font options code
This code gets called before a screen is set.
2015-07-01 23:36:29 -07:00
Matthias Clasen
a0e8d8db0b Improve the font options support
Instead of just overwriting the default options, merge the per-widget
font options with the defaults.

https://bugzilla.gnome.org/show_bug.cgi?id=751811
2015-07-01 19:15:56 -07:00
Cosimo Cecchi
d6b8261622 widget: don't call gtk_style_context_set_background()
We don't need to do this here anymore, since widgets typically render
their backgrounds now.
2015-07-01 16:09:23 -07:00
Christoph Reiter
5d17b0af54 GtkWindow: don't increase the preferred size for empty windows if there is a size request set.
This fixes a reftest broken by commit 84e99b20ac

https://bugzilla.gnome.org/show_bug.cgi?id=751341
2015-07-01 09:32:19 -07:00
Arc Riley
15c73a2b1a Add gtk_widget_set_font_options and gtk_widget_get_font_options
This allows a widget to override global font_options, such as hinting and
subpixel order. The widget's PangoContext is updated when this is set.

Some update code from gtk_widget_update_pango_context was moved to
update_pango_context so that gtk_widget_update_pango_context runs it.

http://bugzilla.gnome.org/show_bug.cgi?id=751677
2015-07-01 07:34:32 -07:00
Piotr Drąg
1600d54012 docs: Fix some minor typos in comments in GtkWidget 2015-06-11 15:50:15 +02:00
Benjamin Otte
1cc8de2412 widget: Clarify docs on gtk_widget_set_double_buffered()
Also make them more scary so people really really don't use it as a
random knob when trying to make things go fast.

//bugzilla.gnome.org/show_bug.cgi?id=750505
2015-06-08 20:29:24 +02:00
Matthias Clasen
165861323a widget: Fix compiler warnings
Fix warnings due to -Wdeclaration-after-statement and -Wshadow.
2015-06-02 09:08:16 -04:00
Matthias Clasen
569d5ad763 GtkBuilder: Export the template parsing entry point
This will let gtk-builder-tool validate templates.
2015-04-30 06:19:10 -04:00
Matthias Clasen
c9040ab038 GtkWidget: Use _gtk_builder_lookup_object 2015-04-27 23:09:35 -04:00
Matthias Clasen
b53b38ff32 GtkWidget: Use the new helpers
Instead of issuing g_warning, fill the provided GError.
This lets us test this error handling, and is the right
thing to do. Use the new GtkBuilder helpers and
g_markup_collect_attributes to do so.
2015-04-27 01:15:24 -04:00
Matthias Clasen
cd8b19dcb0 docs: Add an cross-reference to template docs 2015-04-26 10:19:26 -04:00
Benjamin Otte
fdc620cd56 cssnode: Clear widget path more aggressively
When recomputing CSS, we need a correct widget path in the fallback mode
where we're still using widget paths.
So we need to invalidate it everytime it actually changes, and not just
when emitting the style-updated signal.

Fixes css-match-regions reftest.
2015-03-24 04:23:07 +01:00
Matthias Clasen
eea16f03f5 Stop using GDK_POINTER_MOTION_HINT_MASK in widgets
It is deprecated and no longer needed, and,as observed in
https://bugzilla.gnome.org/show_bug.cgi?id=746253 it
interferes with turning off event compression.
2015-03-22 17:33:38 -04:00
Benjamin Otte
7395dddd47 csswidgetnode: Avoid creating a stylecontext
If the widget doesn't have a style context, don't create one. Instead,
call functions on the widget directly.
2015-03-18 15:23:33 +01:00
Benjamin Otte
dbe5058b86 cssnode: Add API to query the timestamp
... and pass it to the API that computes new styles.

A special timestamp of 0 means "please don't animate" and is used when
no frame clock is available for a node.
2015-03-18 15:23:32 +01:00
Benjamin Otte
2694545468 cssnode: Add visibility concept
This allows hiding nodes of invisible widgets.
And that in turn makes sure :nth-child() works as expected.
2015-03-18 15:23:31 +01:00
Benjamin Otte
b92fe2fa85 widget: Add gtk_widget_get_css_node()
and replace gtk_style_context_get_root() with it.
2015-03-18 15:23:31 +01:00
Benjamin Otte
5df01f9244 widget: Create widget path classes from proper style
We don't want to add the current classes to the widget path - which
might potentially be different after a gtk_style_context_save() - but
the root node's ones. So what better thing to do than actually using the
root node?
2015-03-18 15:23:30 +01:00
Benjamin Otte
5edc6d94d1 widget: Use correct type for widgetpath creation
This is relevant when the widget path is created while the widget is
still constructing. G_OBJECT_TYPE(widget) might not point to the final
type yet.
2015-03-18 15:23:30 +01:00
Benjamin Otte
ffb410f11e widget: Create the CssNode
... and pass it to the style context instead of having the style context
create it for us.
2015-03-18 15:23:30 +01:00
Benjamin Otte
efda30c495 stylecontext: Don't queue animate tick callbacks anymore
Instead, just mark nodes permanently as invalid.
2015-03-18 15:23:30 +01:00
Benjamin Otte
8e1017db35 stylecontext: Export gtk_style_context_get_root()
.. in the private header. This avoids tiny wrapper functions.
2015-03-18 15:23:29 +01:00
Benjamin Otte
721dce73e0 stylecontext: Handle parent in CssNode code
Make CssNode a real tree with a DOM-like API.
2015-03-18 15:23:29 +01:00
Matthias Clasen
855c4dc0ce unrealize: Don't ref twice
After the recent change to add an outermost ref/unref pair,
we can do away with the inner one.
2015-03-16 11:54:38 -04:00
Carlos Garnacho
b4e61b759b widget: Take a ref during ::unrealize emission
In order to prevent invalid memory access/crashes if the widget is
destroyed in a callback of that signal.

https://bugzilla.gnome.org/show_bug.cgi?id=745829
2015-03-16 16:27:06 +01:00
Carlos Garnacho
f5f6ad9981 widget: Take a ref during ::unmap emission
This ensures the widget data stays live long enough to perform invariants
check after emission if the widget happens to be destroyed on a callback.

https://bugzilla.gnome.org/show_bug.cgi?id=745829
2015-03-16 16:22:25 +01:00
Emmanuele Bassi
6950116678 docs: Reword the deprecation notice for gtk_widget_override_*
They are a bit terse, and they should point to the preferred way of
overriding the theme, i.e. using a GtkStyleProvider for your
application, and custom style classes.
2015-03-08 14:39:18 +00:00
Matthias Clasen
1f3328c096 Avoid calling g_object_ref on NULL
gtk_widget_set_visual() allows NULL for the visual, so be
careful ot to ref it unconditionally.
2015-03-07 17:48:11 -05:00
Carlos Garnacho
08494f86a0 widget: Improve hack to ignore drags from widgets using motion events
Postpone until the last moment whether the target widget still
potentially uses updates from this sequence, or window dragging
actually applies because all gestures on the target went to denied
state.

This fixes window dragging on empty space in a headerbar that is
contained in a paned (as in e.g. gedit).

https://bugzilla.gnome.org/show_bug.cgi?id=745562
2015-03-04 21:20:29 -05:00
Matthias Clasen
3569d373a2 Fix 7c4bf742e8
The objects-finalize test constructs gestures with NULL as
a widget. The recent addition of weak references was not
ready for that.
2015-03-02 20:18:15 -05:00
Carlos Garnacho
13e22e2030 gtkwindow: Move window dragging to a standalone drag gesture
The gesture is hooked to the capture phase, so it works for buttons in
header bars and whatnot. In order to be friendly to the widget it is
capturing events from, an ugly hack is in place to avoid capturing
events when the target widget has a gesture that would consume motion
events.
2015-03-02 12:03:39 +01:00
Debarshi Ray
7c4bf742e8 eventcontroller, widget: Don't crash if destroyed before the other
There are two scenarios. A widget sub-class owns a GtkEventController
and passes itself to it, or a controller owned by something else is
passed a widget.

In the second case, if the widget is destroyed before the controller,
we will have a crash when destructing the controller because we will
be accessing invalid memory. Adding a weak reference on the widget
addresses that problem.

This leads to a crash in the first case. When the widget is getting
destroyed, it will drop the reference to its own controller. The
controller will skip touching the widget because the weak reference
would have turned it to NULL. However, when the widget sub-class chains
up to GtkWidget it will try to free all the controllers in its list.
Unfortunately, all these controllers have already been destroyed. So
we need to guard against this too.

https://bugzilla.gnome.org/show_bug.cgi?id=745225
2015-03-02 11:53:52 +01:00
Philip Withnall
09bb109f01 docs: Expand input handling documentation to cover event masks
Also try and clarify a few things about event propagation. Move
input-handling.xml into gtk-doc’s expand_content_files variable so it
automatically links to widget documentation. Add links from
gtk_widget_add_events() and friends to the new documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=744054
2015-02-19 12:48:42 +00:00
Philip Withnall
b397dd04c4 gtk: Remove documentation references to the GTK_NO_WINDOW flag
It has been removed entirely, and replaced by
gtk_widget_get_has_window().

https://bugzilla.gnome.org/show_bug.cgi?id=744054
2015-02-19 12:48:41 +00:00
Benjamin Otte
89f635fee1 css: Add -gtk-dpi CSS property hack
This property is necessary to ensure widgets automatically update after
the text scale factor is changed desktop-wide.

And if I'm already doing a property like this, I can make it
overridable. So now you can override the dpi per-widget with CSS like
GtkSwitch {
  -gtk-dpi: 48;
}
if you want to debug things.

Long-term, we want to get rid of this property and insist on dpi being
96 everywhere and people can change the font size to get larger fonts.
2015-02-05 18:57:29 +01:00
Garrett Regier
9cbf764bcd Fix VA marshaller for GtkWidget's "event-after" signal
Just a copy and paste typo from the "event" signal.

https://bugzilla.gnome.org/show_bug.cgi?id=743593
Signed-off-by: Garrett Regier <garrettregier@gmail.com>
2015-01-28 16:40:59 -05:00
Matthias Clasen
1aee4f0384 Fix a typo
commit aa1b7fab9c introduced a misuse of G_UNLIKELY in
several places. Fix all those.
2015-01-28 10:08:13 -05:00
Benjamin Otte
aa1b7fab9c css: Remove _gtk_css_style_property_changes_affect_size()
... and _gtk_css_style_property_changes_affect_font().

Replace it with _gtk_css_style_property_get_mask_affecting().
2015-01-27 05:04:34 +01:00
Benjamin Otte
3a9bf0fe1d widget: Compute clip of children properly
For widgets with a window, we need to adjust the allocation of their
children.
2015-01-22 16:25:43 +01:00
Benjamin Otte
d879a13600 widget: Correctly handle which widgets to include in the clip
Previously, we would not include any child widget on the first
allocation, which happens right after realize(), but before map(). No
widget is drawable at that point.
2015-01-22 16:25:35 +01:00
Benjamin Otte
bd31310c40 widget: Add debug spew for setting the clip 2015-01-22 16:25:30 +01:00
Benjamin Otte
dbb8d1dd07 stylecontext: Keep track of the CSS ID
This is necessary since we do the new caching and need to distinguish
between styles with different IDs.

Fixes various test cases.
2015-01-20 01:07:13 +01:00
Carlos Garnacho
b8e87d4762 widget: Free the controller list on finalize()
If this is done on dispose(), the widget may be destroyed (and its
controllers list NULLified) within _gtk_widget_run_controllers(),
causing warnings/crashes when it just tried to hop on the next
controllers.

Freeing the controllers here should be a safety net for implementations,
so it also makes sense to do this late. The widgets that choose to
free their controllers on dispose can still do so, and get
_gtk_widget_remove_controller() called for these as an indirect result.
2015-01-14 17:11:25 +01:00
Matthias Clasen
53c388b724 Some formatting cleanups 2014-12-21 22:58:23 -05:00
Benjamin Otte
42a6ae6c6c widget: Set the allocation via gtk_widget_set_allocation()
There is no good reason to assign the value directly.

Also, this fixes d23f3254b7
where widgets that chained up instead of calling
gtk_widget_set_allocation() would not draw becaues of empty clip.
2014-12-20 20:41:18 +01:00
Benjamin Otte
d23f3254b7 widget: Handle setting clip differently
(1) Get rid of supports_clip flag. All widgets (implicitly) support
clip.

(2) Don't reset the clip to { 0, 0, 0, 0 } before the "size-allocate"
signal.

(3) Make gtk_widget_set_allocation() set the clip (to the allocation).
This ensures that eveyr widget has a clip set.
Note: It overrides previous calls to gtk_widget_set_clip(), while in
3.14 this didn't happen.

(4) As the clip is set by gtk_widget_set_allocation() now, don't set
it after the "size-allocate" signal anymore.

This fixes calls to gtk_widget_queue_draw() from inside the
size_allocate vfunc.
2014-12-19 19:20:07 +01:00
Christian Hergert
661da5558c widget: add helpers to resolve GActionGroups available to GtkWidget
These functions, while added for use by the GTK inspector, are generally
useful to applications that need to resolve what action groups are
available to a particular GtkWidget.

https://bugzilla.gnome.org/show_bug.cgi?id=741386
2014-12-11 15:25:41 -08:00
Carlos Soriano
235837ad49 gtkwindow: Use actions from focused widget to activate accel
Currently we only take into account the window GActionGroup for
activating the accels.

However, the application could have some custom GActionGroup in the
chain of focused widgets that could want to activate some action if
some accel is activated while that widget is focused.

To allow applications to set accels on widgets that use custom
GActionGroups, simply use the muxer of the focused widget, which
already contains the actions of the parents.

https://bugzilla.gnome.org/show_bug.cgi?id=740682
2014-12-08 20:19:33 -08:00
Matthias Clasen
64fd964703 GtkWidget: Don't return FALSE as a pointer
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=741251
2014-12-08 09:16:24 -05:00
Matthias Clasen
06745bc0aa Add a note to the ::destroy docs
Clarify that ::destroy is not suitable for saving widget state.

https://bugzilla.gnome.org/show_bug.cgi?id=710793
2014-12-07 18:12:46 -05:00
Jasper St. Pierre
579c7f80a0 gtkwidget: Fix a typo preventing the CSD input shape from applying
We were setting "csd-shade" but reading from "csd-region".
2014-12-01 18:01:49 -08:00
Benjamin Otte
7ecdaaacb2 widget: Clarify some corner cases
I checked Cairo source code (actually pixman, as Cairo just passes
through) to make sure that the behavior stays identical: negative values
cause an error message from pixman, zero is allowed. Both return an
empty region which gtk_widget_queue_draw_region() would then proceed to
ignore.
2014-11-29 03:42:28 +01:00
Jasper St. Pierre
0c09d44509 gtkwidget: Remove unnecessary code in get_state_flags
Any time has_focus is called, we will call gtk_widget_update_state_flags
which will assign the state flags properly.
2014-11-25 11:04:36 -08:00
Matthias Clasen
8765970ba1 Remove a redundant call
No need to set shapes twice in a row.
2014-10-29 06:49:59 -04:00
Matthias Clasen
c9ad936011 Drop an unused variable 2014-10-29 06:49:58 -04:00
Matthias Clasen
778865f316 Fix toplevel input shape for csd windows
We need to maintain the application-set and the the csd
input shape separately, and intersect them to pass them
down.
2014-10-28 20:23:47 -04:00
Matthias Clasen
4cf6edda55 wayland: Make window opacity work
Under wayland, the compositor doesn't have a 'overall window alpha'
knob, we just need to add the alpha to the buffers we send.
Client-side alpha, if you want to call it that.

Implement this by reusing the existing alpha support for non-toplevel
widgets. As a side-effect of the implementation, windows with RGBA
visual under X will now also use per-pixel alpha, instead of
overall alpha.
2014-10-28 10:28:23 -04:00
Matthias Clasen
a55000613a Add private API to query tick callbacks
This information can be useful for debugging purposes.
2014-10-24 08:34:13 -04:00
Bastien Nocera
d0f4e73999 gtkwidget: Fix typo in comment 2014-10-21 10:10:50 +02:00
Matthias Clasen
d7b64c63e0 Improve tooltip-text/markup docs
Clarify priorities between the two,
https://bugzilla.gnome.org/show_bug.cgi?id=681185
2014-10-19 23:28:34 -04:00
Matthias Clasen
e3ef5d6fd2 GtkTooltip: Move nonexported API to a private header
This is our standard practice nowadays.
2014-10-19 22:51:21 -04:00
Alexander Larsson
d0147a6f2c Add gdk_window_mark_paint_from_clip and call from widget drawing
This is a new function that gets called every time we're drawing
some area in the Gtk paint machinery. It is a no-op right now, but
it will be required later to keep track of what areas which
we previously rendered with GL was overwritten with cairo contents.
2014-10-13 10:43:31 -04:00
Matthias Clasen
63efdca223 Deprecate GtkWidget override APIs
This is better done with css and style classes nowadays.
2014-09-30 00:08:59 -04:00
Benjamin Otte
9a8a4a8b14 widget: Don't assume opacity is 100%
... just because there is no style context instantiated yet. Instead,
instantiate a style context during realize() and ask it.

Fixes problems with dim labels not being dimmed on first show.

Testcase included.

https://bugzilla.gnome.org/show_bug.cgi?id=735240
2014-09-07 01:57:10 +02:00
Matthias Clasen
d55e3b25a7 Fix various compiler warnings
Mostly missing declarations and missing statics.
2014-09-05 21:21:49 -04:00
Benjamin Otte
01d644b7ee widget: Don't connect to GtkModifierStyle::changed
Changes to the modifier style will be picked up by the
GtkStyleProviderPrivate::changed signal. And that signal will actually
invalidate properly.
2014-08-27 17:57:10 +02:00
Benjamin Otte
b5a8b7ef3b widget: Make _gtk_set_simple_clip() take an optional content clip 2014-08-21 00:54:07 +02:00
Matthias Clasen
c9da8bf2b3 Revert "docs: Fix broken gtk-doc formatting"
This reverts commit a7562dd38f.

I prefer to not confuse gtk-doc with doc comments for private
functions.
2014-08-18 08:18:02 -04:00
Rico Tzschichholz
a7562dd38f docs: Fix broken gtk-doc formatting
Fixes broken introspection of GtkTranslateFunc
2014-08-18 13:27:05 +02:00
Matthias Clasen
d206d694fd GtkWidget: fix up docs minimally 2014-08-16 21:40:39 -04:00
Benjamin Otte
65cc3630c8 widget: Add checks for setting state flags
This is more for GTK developers to catch when they forgot to change
GTK_STATE_FLAGS_BITS after adding a new state flag than to prevent
widget developers from using the wrong flags.
2014-08-16 16:34:15 +02:00
Benjamin Otte
36a2e7ca8e css: Add a :checked pseudoclass
https://bugzilla.gnome.org/show_bug.cgi?id=733967
2014-08-16 16:34:14 +02:00
Carlos Garnacho
62507776fe widget: Include event controllers' event mask on gtk_widget_get_events()
gtk_widget_get_events() must indeed tell about events enabled purely through
a GtkEventController, those events will most surely trigger event handlers.

https://bugzilla.gnome.org/show_bug.cgi?id=734357
2014-08-12 14:28:34 +02:00
Matthias Clasen
327b097725 Trivial: Use g_clear_object more
It no longer has atomic overhead, so we can use it everywhere.
2014-08-09 10:16:27 +02:00
Benjamin Otte
52dd0f5014 widget: Add widget state when appending to widget path
Make gtk_widget_path_append_for_widget() add the state flags of the
widget, too.

This enables the ability to select pseudoclasses on all elements in a
selector.
2014-07-19 23:42:39 +02:00
Benjamin Otte
3e82d12abd widget: Remove special case for clipping
Labels now call gtk_widget_set_clip() so there is no longer a need to
exclude them from clipping.
2014-07-10 18:56:35 +02:00
Sébastien Wilmet
03b4c82f77 docs: make GtkWidget:margin-start and margin-end clearer
margin-start and margin-end have been added for RTL support, see:
https://bugzilla.gnome.org/show_bug.cgi?id=710238

So those properties are used only for the horizontal direction: left or
right, not top or bottom.

https://bugzilla.gnome.org/show_bug.cgi?id=732681
2014-07-03 14:50:22 +02:00
Emmanuele Bassi
5b571ff4b6 docs: Show examples of how to use templates API
The template documentation is lacking inlined examples on how to use the
templates API, like binding children and callbacks. This makes looking
for best practices a bit harder than it ought to be, for a feature this
useful.
2014-06-26 19:29:06 +01:00
Jasper St. Pierre
f4c2c4c667 gtkwidget: Actually mark set_double_buffered as deprecated 2014-06-23 17:53:48 -04:00
Jasper St. Pierre
24b9e91f47 Revert "gtkwidget: Widgets are now always double-buffered"
This reverts commit b875572f2a.

Apps like Abiword, gnumeric and gnome-chess, and toolkits like
ClutterGTK were all using this for various purposes, and this made them
break. Bring back this feature for now.

It still won't work under Wayland.
2014-06-23 17:50:01 -04:00
Matthias Clasen
4617fa7568 Docs: Reword deprecation notes
Mainly, make sure that deprecated properties are
documented as such. In this case: double-buffered.
2014-06-22 12:11:17 -04:00
Jasper St. Pierre
6bc251692a gtkwidget: Add a warning about set_double_buffered
As requested on the mailing list.
2014-06-21 00:31:17 -04:00
Jasper St. Pierre
b875572f2a gtkwidget: Widgets are now always double-buffered
gtk_widget_set_double_buffered is now deprecated, and we don't support
non-double-buffered widgets. This means that under normal circumstances,
paints are never outside of a begin_paint / end_paint sequence, which
natively-double-buffered backends like Wayland can't possibly support.
2014-06-20 20:41:54 -04:00
Benjamin Otte
4a6957f50d stylecontext: Remove state from _peek_style_property()
It evaluates to "current state" in all cases, so no need to special case
it.
2014-06-11 01:18:04 +02:00
Matthias Clasen
acad03f77b GtkWidget: Use G_PARAM_EXPLICIT_NOTIFY
A few properties here are special, and can't benefit from it:
those which are just shorthands, like ::margin and ::expand,
and those that have explicit -set properties, like::hexpand
and ::vexpand.
2014-06-09 13:30:54 -04:00
Carlos Garnacho
90424289fb widget: reset all controllers when the widget becomes insensitive
Widgets becoming insensitive won't receive further events, but there
could be chances the controllers don't get properly notified and reset
in those situations.
2014-06-05 16:15:54 +02:00
Carlos Garnacho
cb059bfc1b widget: Set GDK_BUTTON1_MASK on emulated pointer events
The touch_event handler was missing those when emulating pointer events
for the widgets that get GDK_TOUCH_MASK set, but have no specialized
touch handlers.
2014-06-04 13:44:56 +02:00
Carlos Garnacho
25f5da5018 widget: Ensure all gestures outside a grab scope are cancelled
This code is a product of early stages in the gestures branch, where
capturing would have an effect outside grab boundaries. But this isn't
really the case, so every gesture outside the grab scope must be reset
to avoid keeping stale data.
2014-06-03 16:13:25 +02:00
Carlos Garnacho
26ced6abad widget: Only deny a sequence if it was previously claimed
Before this change, a sequence being claimed deep in the event propagation
chain would make the sequence go denied on every ancestor, regardless of
previous state.

To make things more consistent, only deny the sequence if it was previously
claimed, so the behavior is the same for gesture groups within the widget
than for those outside the widget.

The gestures testsuite has been updated to reflect this new behavior.
2014-06-03 15:59:03 +02:00
Debarshi Ray
047d2b5f6d Update GtkImage icons when the direction is changed
Don't call gtk_widget_set_state_flags(), it filters the direction flags.
Instead, call gtk_widget_update_state_flags() directly.

https://bugzilla.gnome.org/show_bug.cgi?id=730833
2014-05-31 05:19:41 +02:00
Evan Nemerson
54ec42f035 gtk: port many nullability annotation fixes from Vala bindings
https://bugzilla.gnome.org/show_bug.cgi?id=730745
2014-05-30 13:24:20 -07:00
Evan Nemerson
07d825574f gtk: add missing type annotations ported from Vala bindings
https://bugzilla.gnome.org/show_bug.cgi?id=730745
2014-05-27 21:10:33 -07:00
Evan Nemerson
bda145b19f gtk: fix annotation syntax and missing some missing annotations
These changes clean up various errors and omissions resulting from
either slightly incorrect G-I/gtk-doc syntax or missing documentation
blocks.

https://bugzilla.gnome.org/show_bug.cgi?id=730745
2014-05-27 21:10:32 -07:00
Carlos Garnacho
505efbb3f3 widget: Change GtkCapturePhase behavior in event controllers' handling
Previously, there would be globally just a capture and a bubble phase,
with the event just going down the hierarchy once, and the up once.
GTK_PHASE_TARGET actually meaning "run within event handlers", so in
a hierarchy of 3 widgets, emission would be:

  Capture(C)
  Capture(B)
  Capture(A)
  Target(A) (if event handlers allow)
  Bubble(A)
  Target(B) (if event handlers allow)
  Bubble(B)
  Target(C) (if event handlers allow)
  Bubble(C)

This commit changes this behavior and uses GTK_PHASE_TARGET in a less
misleading way, running only on the widget that was meant to receive
the event. And GTK_PHASE_BUBBLE has taken over the execution place of
GTK_PHASE_TARGET, so the emission remains:

  Capture(C)
  Capture(B)
  Capture(A)
  Target(A)
  Bubble(A) (if event handlers allow)
  Bubble(B) (...)
  Bubble(C) (...)

As it was, GTK_PHASE_BUBBLE was useful for running event controllers
paralelly to event handlers, without modifying a single line in those.
For those mixed scenarios, Any of the other phases will have to be
used at discretion, or the event handlers eventually changed to chain
up and let the default event handlers in GtkWidget to be run.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
d05a9f9a7b gesture: Replace gtk_gesture_attach/detach with event controller API
Event controllers now auto-attach, and the GtkCapturePhase only determines
when are events dispatched, but all controllers are managed by the widget wrt
grabs.

All callers have been updated.
2014-05-27 17:47:12 +02:00
Matthias Clasen
8a6aca31a8 Typo fixes 2014-05-24 18:20:31 -04:00
Benjamin Otte
f5b1e75d93 widget: Include box-shadow in the clip
This allows all widgets that implement clip to use box shadows.
2014-05-24 16:12:21 +02:00
Benjamin Otte
0cd63faee2 widget: Add _gtk_widget_set_css_clip()
... and use it in GtkBox and GtkGrid.
2014-05-24 16:12:21 +02:00
Benjamin Otte
4f89eb05cf API: widget: Add gtk_widget_set_clip() API
And handle the fact that drawing bounds are now handled by this API and
the corresponding gtk_widget_get_clip().

Also add _gtk_widget_supports_clip() function to check if a widget has
been ported to the new world.
2014-05-24 16:12:20 +02:00
Carlos Garnacho
01d74f86a0 widget: Flip execution order of GTK_PHASE_TARGET/BUBBLE
the "bubble" phase used to run before event handlers before GTK_PHASE_TARGET
was added, in order to keep phases in the expected order, move GTK_PHASE_BUBBLE
to be run (still invariably) after event handlers.

The only behavioral change should be wrt widgets wanting mixed event handler/
gesture handling, they could previously attach the gesture to the bubble phase
and check for gtk_gesture_is_active() in the event handler to bail out, they'll
have to use GTK_PHASE_CAPTURE for that purpose from now on.
2014-05-23 19:54:33 +02:00
Matthias Clasen
a727c41e4a Add back a private api to list controllers
This will let us show them in the inspector.
2014-05-23 19:54:32 +02:00
Carlos Garnacho
f81f00ed6b widget: 3-way merge ate my g_object_ref()
Move it to the right place.
2014-05-23 19:54:32 +02:00
Carlos Garnacho
57eca4f445 widget: remove check on whether the controller was already added
Multiple calls are supposedly allowed to change the phase (although
unlikely to happen), so remove the g_return_if_fail() checking whether
the controller was already added.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
dd164502f7 widget: Hook GTK_PHASE_TARGET controllers to the default event handlers
Just call the controllers on that phase if the default widget handlers
are run.

For compatibility reasons, in the touch event handler, let the pointer
emulating touch be transformed to a pointer event as usual, in order to
have widget handlers a chance to run at all. If they have to be managed
by a controller in that phase, it'll have to be through the default pointer
event handlers.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
1c48cc253d gesture: Add GTK_PHASE_TARGET
This phase is meant to run in the default widget handlers, as opposed
to externally as in the bubble/capture phase. This will be most usually
the expected phase for every controller replacing code in event handlers
in GTK+, just so invocation and triggering order is kept unaltered.
2014-05-23 19:54:30 +02:00
Matthias Clasen
bad1dd4ac7 Be careful about the list of event controllers
We can end up with _gtk_widget_remove_controller getting called
while we are iterating over the list in _gtk_widget_run_controllers.
To avoid trouble, only mark the event controller as dead by
setting data->controller to NULL, and defer the actual freeing
and list manipulation to the loop in _gtk_widget_run_controllers.
Update other places that operate on controllers to handle
data->controller being NULL.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
fe9685bca1 widget: tighten the conditions at which a press event is emulated
Make it really sure that the event is only emitted after every gesture
that consumed the button press is done with the sequence.
The event must only be emulated if a gesture in the capture phase happened
to consume the event, be cancelled, and
2014-05-23 19:54:30 +02:00
Carlos Garnacho
6e9b054543 widget: Fix gesture event handler retval for bubbled events
Do not clobber the return value if the regular event handler happens
to return FALSE, even if the gesture meant to consume the event.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
8ab35016a6 gesture: make gtk_gesture_cancel_sequence() private 2014-05-23 19:54:29 +02:00
Carlos Garnacho
5369c77029 gesture: Simplify gesture/widget interaction public API
The propagation phase property/methods in GtkEventController are gone,
This is now set directly on the GtkWidget add/remove controller API,
which has been made private.

The only public bit now are the new functions gtk_gesture_attach() and
gtk_gesture_detach() that will use the private API underneath.

All callers have been updated.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
f0940c962f widget: Keep a widget reference around _gtk_widget_run_controllers()
The widget may be destroyed within the loop, in reaction to the signals
sent by the controllers. Protect against that.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
134acf3fda widget: Change slightly the gesture cancellation policy in a same widget
Within a widget, if a gesture accepts a sequence, it would previously
cancel every other gesture that not in the same group. Change this to
only cancelling gestures that previously claimed the gesture, and let
gestures with state=NONE for that sequence remain like that.

This enables late recognition of gestures, even on the presence of
another gesture group that was more eager at claiming the gesture.

One usecase is user-defined panning gestures on scrolledwindows,
if ::capture-button-press is TRUE (eg. the default), the gesture is
claimed early in order to consume the button press, but that would
tipically make every other gesture group deny the sequence. With
this change, the pan gesture can keep state=NONE, and later claim
the sequence for itself if the panning gesture is recognized.

Also, do not propagate state=DENIED to every gesture in the widget,
that was unintended.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
f73f4d82e0 widget: remove GtkGesture-related signals
The utility of those signals is somewhat dubious now that there is
gtk_gesture_group(), so make that the only way to coordinate gestures.
The cooperation model offered by gtk_gesture_group() is flexible
enough,
2014-05-23 19:54:28 +02:00
Carlos Garnacho
35bed1ac14 widget: Add docs for GtkGesture-related API 2014-05-23 19:54:28 +02:00
Carlos Garnacho
7a71c16317 widget: refactor gesture integration
Listen for notify::sequence-state-changed on the controller, so the
only way to manipulate a sequence state are gtk_gesture_set_sequence_state()
and gtk_gesture_set_state().

Also, make use of gesture groups, so the sequence state is set at once
on all gestures pertaining to a single group. Within a widget, if a sequence
is claimed on one group, it is made to be denied on every other group.
2014-05-23 19:54:25 +02:00
Carlos Garnacho
38e40a55f4 widget: Add gtk_widget_set_gesture_state()
This helper function ensures the state is propagated for
all the active sequences in the given gesture.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
8e1d5f98de widget: Improve button press emulation on sequence denied
Ensure that state being set on pointer emulating touches actually
gets propagated properly on widgets with gestures that only handle
pointer events.
2014-05-23 19:54:24 +02:00
Carlos Garnacho
a56a9e4a62 widget: Reset gestures on grab-notify
If it is determined that the gesture will stop receiving
events, reset the gesture altogether.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
997f05d99b widget: Make helper gesture API take GtkGestures
GtkEventController may be certainly useful to keep event
handling self-contained in other places than gestures, but
the current widget API is highly related to gestures, so
just using GtkGesture as the argument there will be quite
more convenient. The other places where GtkEventController
make sense as a base object will better provide their own
hooks.
2014-05-23 19:54:23 +02:00
Carlos Garnacho
026b5014e8 Add: GTK_PHASE_NONE value to GtkCapturePhase.
Gestures attached with this phase will expect callers to have it
receive events through gtk_event_controller_handle_event(), but
the gesture will still be notified of sequence state changes,
grabs, etc...
2014-05-23 19:54:23 +02:00
Carlos Garnacho
36106c19d4 widget: Propagate touch/button press events when a sequence is denied
If the captured touch begin or button press event have been consumed
for the given sequence, propagate it upwards if the sequence goes from
claimed to denied, so the widgets on the way to the event widget receive
a coherent event stream now that they're going to receive events.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
a9fa0151f1 widget: Implement hierarchy-level mechanism to claim/deny sequences
The policy of sequence states has been made tighter on GtkGesture,
so gestures can never return to a "none" state, nor get out of a
"denied" state, a "claimed" sequence can go "denied" though.

The helper API at the widget level will first emit
GtkWidget::sequence-state-changed on the called widget, and then
notify through the same signal to every other widget in the captured
event chain. So the effect of that signal is twofold, on one hand
it lets the original widget set the state on its attached controllers,
and on the other hand it lets the other widgets freely adapt to the
sequence state changing elsewhere in the event widget chain.

By default, that signal updates every controller on the first usecase,
and propagates the default gesture policy to every other widget in the
chain on the second. This means that, by default:

1) Sequences start out on the "none" state, and get propagated through
   all the event widget chain.
2) If a widget in the chain denies the sequence, all other widgets are
   unaffected.
3) If a widget in the chain claims the sequence, then:
  3.1) Every widget below the claiming widget (ie. towards the event widget)
       will get the sequence cancelled.
  3.2) Every widget above the claiming widget that had the sequence as "none"
       will remain as such, if it was claimed it will go denied, but that should
       rarely happen.

This behavior can be tweaked through the GtkWidget::sequence-state-changed and
GtkGesture::event-handled vmethods, although this should be very rarely done.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
76213ab209 widget: Add widget-level handling of touch sequence state.
These functions ATM do nothing but proxying the controller(s) state
with the given sequence.
2014-05-23 19:54:22 +02:00
Carlos Garnacho
f1bb0283dd widget: Hook GtkEventController to widget event processing.
A controller can be optionally hooked on the capture or the bubble
phase, so the controller will automatically receive and handle events
as they arrive without further interaction.
2014-05-23 19:54:22 +02:00
Matthias Clasen
49cf5142ba Deprecate GdkColor
It has been replaced by GdkRGBA. Time to make it official.
http://bugzilla.gnome.org/show_bug.cgi?id=636695
2014-05-22 09:09:55 -04:00
Matthias Clasen
70cb91a827 docs: syntax fix
It is just 'Deprecated:' in doc comments, not '@Deprecated:'.
2014-05-20 09:55:29 -04:00
Benjamin Otte
d260694a37 widget: Untagle if statements
Reduces the number of nested ifs and makes the code clearer.
2014-05-19 04:25:10 +02:00
Benjamin Otte
3cb5e58b1a API: Deprecate gtk_widget_region_intersect()
It's unused and would become disambiguous once we split between
allocation and draw region.
2014-05-18 02:29:56 +02:00
Benjamin Otte
2a99584c68 API: Deprecate gtk_widget_reparent() 2014-05-17 23:36:57 +02:00
Matthias Clasen
93204d3ba8 Don't lie about baselines so much
Let g_object_get (w, "valign",...) report the truth, so that the
inspector can show it without special cases.
2014-05-15 08:43:43 -04:00
Matthias Clasen
3f224a7165 Add private GtkWidget api for action groups
Similar to the just-added action muxer api for enumerating
action prefixes and for getting the action group for a
prefix.

https://bugzilla.gnome.org/show_bug.cgi?id=730095
2014-05-14 21:28:53 -04:00
Owen W. Taylor
8f9e50de80 GtkPopover: inherit actions from the relative_to widget
Make the relative_to widget the parent for a GtkPopover's
GtkActionGroup. This, for example, makes the menu model of a
GtkMenuButton find action groups attached to the button.

https://bugzilla.gnome.org/show_bug.cgi?id=729915
2014-05-12 16:39:44 -04:00
Matthias Clasen
5cd5db1f57 Remove a redundant check
gtk_widget_show/_hide already check the widget's visibility.

https://bugzilla.gnome.org/show_bug.cgi?id=728135
2014-05-11 11:56:22 -04:00
Cosimo Cecchi
b0ace67712 widget: deprecate focus-line-width style property
Nothing in GTK uses it anymore.
2014-05-09 11:02:46 -07:00
Cosimo Cecchi
e8c906966e widget: deprecate focus-line-pattern style property
Nothing in GTK uses it.
2014-05-09 11:02:44 -07:00
Cosimo Cecchi
a2decd1f2f widget: deprecate focus-padding style property
There's no use left inside GTK.
2014-05-09 11:02:44 -07:00
Cosimo Cecchi
b03c22e0c9 widget: deprecate interior-focus style property
Nothing uses it anymore inside GTK.
2014-05-09 11:02:42 -07:00
Matthias Clasen
d495ab1ca0 Small documentation update
Don't show an example that doesn't work anymore.
2014-05-05 09:41:06 -04:00
Matthias Clasen
456dffcbfd GtkWidget: Mark deprecated properties as such
The ::style, ::margin-left and ::margin-right properties are all
deprecated.
2014-05-02 19:25:27 -04:00
Benjamin Otte
db791ba3f5 widget: Remove unneeded checks
Size vfuncs always get non-null out variables passed, so no need to
check for NULL.
2014-05-01 14:51:27 +02:00
Marcus Karlsson
3d956db500 docs: fix GtkWidget::size-allocate description
The documentation for the GtkWidget::size-allocate signal is missing the
description of the "allocation" parameter. Add the missing description
to the parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=726179
2014-04-13 14:43:47 -07:00
Matthias Clasen
fee33b1a81 Clean up private headers
This commit adds a few missing private headers, and cleans up
some irregularities in the existing ones
2014-04-05 02:06:29 -04:00
Bastien Nocera
f71f7215ab all: Name more idles and timeouts
Following up from 438cd857c4,
name more timeouts and idles.

The original grep was missing checking for gdk_threads_add_*()
functions (at least for some of the files).

https://bugzilla.gnome.org/show_bug.cgi?id=726870
2014-03-26 20:09:30 -04:00
Benjamin Otte
fbf99febf3 docs: Add more information to gtk_widget_set_realized()
It's important to point out that widgets should only be marked as
realized very late in the process. Even GTK widgets don't get this
right.

https://bugzilla.gnome.org/show_bug.cgi?id=726717
2014-03-20 14:34:31 +01:00
Matthias Clasen
ac96c35230 Update documentation about link styling
The ::link-color and ::visited-link-color style properties
are ignored now. Document that.
2014-03-17 15:00:45 -04:00