Commit Graph

97 Commits

Author SHA1 Message Date
Florian Müllner
57efcabfd6 stack: Only map children when necessary
gtk_widget_set_parent() will map the widget if the parent is mapped
and the widget is both visible and child-visible. As we currently
only set the child visibility after adding the child, we immediately
map all children that are added to a mapped stack, even when they
are not actually shown. Avoid this by setting the child visibility
before adding the child, so widgets are only mapped when shown.

https://bugzilla.gnome.org/show_bug.cgi?id=766737
2016-05-21 00:56:34 +02:00
Matt Watson
175cf7e32d stack: always update window position at transition start
Sometimes on wayland we're seeing a frame draw before the first tick
callback, where the window position has not yet been updated.

With this change, the window is properly positioned as soon as
gtk_stack_start_transition returns.

https://bugzilla.gnome.org/show_bug.cgi?id=766405
2016-05-16 13:53:26 -07:00
Timm Bäder
0d8993fb24 stack: Don't underallocate the last_child 2016-05-12 20:40:06 +02:00
Timm Bäder
292e0c2663 stack: Remove some code duplication 2016-05-12 20:40:00 +02:00
Matthias Clasen
df72478375 stack: Use getter for gtk-enable-animations 2016-05-01 00:39:55 -04:00
Matt Watson
62b224a8df stack: skip first frame for animations
Not the ideal solution for this problem, but in practice leads to
much better performance on lower end hardware.

Stack does a double draw on the first frame of its animation, of
both the old contents (into a cairo surface) and the new contents.
Homogeneous stacks only need to reallocate contents on the first
frame.

On lower powered hardware where our frames will be a good deal
slower than the refresh rate anyway, we can assure a smother
experience by waiting a frame to start tweening where frame duration
will be more consistent.
2016-04-08 16:09:30 -07:00
Matt Watson
3909f818c4 stack: port to progress tracker 2016-04-08 16:09:30 -07:00
Christian Hergert
ca63330b19 stack: query preferred size for last_visible_child
When animating, we might be changing the size allocation of the previous
stack child. However, we were not querying the size in the process
meaning you would often see warnings about allocating the size without
knowing what it should be.

This simply adds an innocuous size request, since responding to last_child
sizing requests is not all that critical in the transition.

https://bugzilla.gnome.org/show_bug.cgi?id=763900
2016-03-21 11:50:27 -04:00
Matthias Clasen
bbd94b5a9f gtk: Strip newlines from g_warning and g_error
g_logv adds one for us already.
2016-02-28 12:23:12 -05:00
Timm Bäder
c5369356e8 Various documentation fixes
Always have Since: annotations at the very bottom, use the correct
ClassName::signal-name/ClassName:property-name syntax, fix a few typos
in type names, wrong function names, non-existing type names, etc.
2016-02-08 22:56:52 +01:00
Benjamin Otte
2c350f4469 stack: realize windows in correct position 2016-01-26 16:40:27 +01:00
Benjamin Otte
9d0e8401ca stack: Turn into no-window widget
Having priv->view_window be the same as widget->window does not make
sense.

And because we need to clip the content area, we need the view window.
2016-01-26 15:53:56 +01:00
Benjamin Otte
6bb8da5564 stack: Clip animation drawing
We use cairo_paint() when doing that and we don't want to overdraw the
content area.
2016-01-22 13:46:01 +01:00
Marek Černocký
f64bb38aa7 Fixed typo childen->children 2016-01-19 12:52:58 +01:00
Matthias Clasen
246fcd6563 Complete docs for gtk_stack_get_interpolate_size 2015-12-15 09:48:16 -05:00
Matthias Clasen
9c63170e70 stack: Convert to gadgets 2015-12-15 08:41:16 -05:00
Matt Watson
ae487840f0 gtkstack: remove needless queue_resize
In gtk_stack_set_transition_position we should only need to
queue_resize if we are non-homogeneous, which is already done
earlier in the function.
2015-12-10 16:51:29 -08:00
Matthias Clasen
373ce9f652 stack: Update windows before allocating children
Doing things the other way around seems to cause problems in
some cases where children want to do different things depending
on the window position.

https://bugzilla.gnome.org/show_bug.cgi?id=758563
2015-11-30 10:41:13 -05:00
Timm Bäder
f154875e08 GtkStack: Add some missing nullable annotations 2015-11-24 11:16:51 +01:00
Carlos Soriano
9f3839066e gtkstack: allow templates to override all properties
Currently GtkStack has some G_PARAM_CONSTRUCT properties. That means,
the properties are set with its default value after the initializacion
of the object.
When using GtkBuilder to build objects, GtkBuilder creates them and
after that sets the properties found on the xml definition.
However, this is not true for templates because the template is initialized
in the init() function of the actual object, and after that, the construct
properties will be set.

This is a problem when someone wants to use templates with GtkStack and
set those properties, since they will be set on the tempalt initialization
and set again to its default values afterwards.

To fix this, make those properties not G_PARAM_CONSTRUCT.

https://bugzilla.gnome.org/show_bug.cgi?id=758086
2015-11-19 14:50:09 -05:00
Matthias Clasen
14f4b7ead2 Avoid excessive property notification for GtkStack::interpolate-size
make check checks this for writable properties, and fails now that
we've made this property writable.
2015-11-09 14:53:25 -05:00
Benjamin Otte
c7491fa144 stack: Store actual widget size, not preferred size
This is just a cleanup commit, no actual bug.
2015-11-05 15:23:12 +01:00
Benjamin Otte
b6b00c31d7 stack: Queue a resize/allocate when switching children
We only allocate a size to the currently visible child, so we obviously
need to rerun allocation when the visible child changes.

In the case where the stack is not homogenous, we also need to queue a
resize because our size request just changed.
2015-11-04 19:39:29 +01:00
Matthias Clasen
910f4f72ba stack: Set an element name
And it is...stack.
2015-11-03 23:20:24 -05:00
Christian Hergert
24391634b5 stack: GtkStack:interpolate-size should be read/write
It looks like the param spec for interpolate-size was
copied from the line above it, which is a read only property.

There is a setter for interpolate-size, and it is implemented in
set_property().
2015-11-03 15:13:51 -08:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Matthias Clasen
0bee97de5c stack: Convert to gtk_container_child_notify_by_pspec 2015-09-08 08:07:33 -04:00
Matthias Clasen
0f851be368 Fix a doc comment typo 2015-08-09 23:32:04 +02:00
Matthias Clasen
9711608ba3 Fix a doc comment 2015-08-05 14:20:12 -04:00
Ting-Wei Lan
50a2428739 Fix return value error in gtk_stack_get_interpolate_size 2015-07-20 21:55:40 +08:00
Timm Bäder
469db13b81 GtkStack: Add interpolate-size property
And use it to determine whether we should actually interpolate between
stack sizes or not.
2015-07-20 10:26:06 +02:00
Matthias Clasen
7ce96cb6ac GtkStack: Avoid some unnecessary complication
We already have an in-destruction flag, so use it.
2015-06-23 06:45:07 -04:00
Paolo Borelli
4e155d784d Avoid spurious operations on destroy
When the stack is destroyed we do not want to waste time running
animations and notifying listeners about which is our current
visible child.

This is not only an optimization, but it is important for the stack
switcher widgets: since they are in another branch of the hieratchy
we do not want to get notifications while the stack is being destroyed.

Based on a patch by Paolo Borelli
https://bugzilla.gnome.org/show_bug.cgi?id=724506
2015-06-21 11:32:31 -04:00
Matthias Clasen
f5b245ff04 GtkStack: Don't mix code and declarations 2015-05-30 09:43:56 -04:00
Timm Bäder
4d75d62033 GtkStack: Interpolate between size changes 2015-05-29 17:37:04 +02:00
Timm Bäder
0eddfcedb9 GtkStack: Remove some useless function calls
We will call gtk_widget_queue_resize anyway later when finishing the
(maybe non-running) transition, which will also cause the stack to be
repainted.
2015-05-29 17:37:04 +02:00
Timm Bäder
24193a38f0 GtkStack: Keep the last_visible_child around during transitions
We need it later.
2015-05-29 17:37:04 +02:00
Timm Bäder
dc55a895ed GtkStack: Misc indentation fixes 2015-05-29 17:37:04 +02:00
Timm Bäder
6d25e52a4d GtkStack: Remove useless cast 2015-05-29 17:37:04 +02:00
Timm Bäder
c0d535a718 GtkStack: Remove useless function calls
These both just use the default values anyway.
2015-05-29 17:37:04 +02:00
Timm Bäder
bdabea3ae3 GtkStack: Save last visible widget size
When interpolating the stack size, we compute the current size by using
the prefered/minimum current size and the last size. We can't use the
last_visible_surface_allocation because that is not available until the
first _draw call and it doesn't include the child's margins.
2015-05-29 17:37:04 +02:00
Timm Bäder
b3bbe99001 GtkStack: Remove gtk_widget_set_opacity call
The corresponding call with 0.999 opacity is gone, so we don't need to
reset the opacity anymore.
2015-05-29 17:37:04 +02:00
Debarshi Ray
39e7afecb1 GtkStack: Don't emit notify::visible-child during destruction
https://bugzilla.gnome.org/show_bug.cgi?id=749012
2015-05-07 15:18:20 +02:00
Christian Hergert
bb53f893e2 stack: check for widget before calling is_ancestor()
We can hit this path during the destruction case, where widget has
been released.

This fixes a lot of superfluous error messages on console.
2015-02-14 18:11:54 -08:00
Benjamin Otte
059cd3e51f stack: Remove commented out line
It always shows up in my greps and confuses me.
2015-01-07 14:26:48 +01:00
Matthias Clasen
123c6dc558 GtkStack: Improve focus handling
Add notebook-like focus handling: Keep track of the last focused
descendent of each page, and focus it again when switching back
to the page. If there is no last focused child, we move the focus
into the page as if the user had hit Tab.
2014-12-10 22:32:45 -05:00
Matthias Clasen
f71831c780 GtkStack: silently ignore visible-child-name set to NULL
This can happen when loading empty stacks in glade.
2014-11-25 00:14:47 -05:00
Matthias Clasen
cd8576ec19 GtkStack: Fix an oversight in child renaming
We currently emit a warning if you rename a child to the name
it already has. We shouldn't do that.
2014-11-18 13:37:51 +01:00
Matthias Clasen
95b075b8eb Drop unused variables
Keeps the compiler happy.
2014-11-14 11:48:50 -05:00
Matthias Clasen
c8d9e5b564 GtkStack: Remove some clumsy use of GList API
No need for g_list_next(), and don't open-code g_list_index().
2014-11-10 18:45:58 -05:00