Commit Graph

163 Commits

Author SHA1 Message Date
Benjamin Otte
68a54ae81f stack: Don't draw an extra background
The gadget draws a background for us, we don't need another one.
2016-12-20 18:01:10 +01:00
Debarshi Ray
faf2295440 GtkStack: Remove redundant code
Commit 7ce96cb6ac avoids notifications
during destruction by using gtk_widget_in_destruction. Therefore this
code is no longer needed.

This reverts commit 39e7afecb1

https://bugzilla.gnome.org/show_bug.cgi?id=749012
2016-12-20 00:32:15 +01:00
Benjamin Otte
4850271ae8 API: Remove gtk_cairo_should_draw_window()
The answer is: Yes.
2016-11-23 18:48:38 +01:00
Benjamin Otte
da207c9fdd snapshot: Add a snapshot function to GtkCssCustomGadget 2016-11-15 17:48:45 +01:00
Olivier Fourdan
03b8a8a880 gtkstack: reorder size_allocate and move_window
Unlike other container widgets, GtkStack would allocate its children
prior to moving its windows, which might prevent further valid size
allocation signals to be emitted.

Re-order the size allocation of child widgets to be performed after
moving the GtkStack windows.

Thanks to Owen for spotting the real issue here.

https://bugzilla.gnome.org/show_bug.cgi?id=767713
2016-11-14 12:24:18 +01:00
Timm Bäder
0d88fe65ba stack: Use gtk_widget_measure 2016-11-12 20:37:22 +01:00
Benjamin Otte
32a5729d18 gtk: Chain up in realize()
... instead of copy/paste from gtk_widget_real_realize.
2016-11-02 07:16:08 +01:00
Timm Bäder
ee4ba18d5e stack: Don't underallocate child in interpolate-size case
In that case, we can't just rely on the stack allocation being big
enough. Especially, the child can actually be bigger than the current
stack allocation, so take that into account when positioning it.
2016-10-31 19:29:36 +01:00
Timm Bäder
8dce94c47a stack: Redraw last_visible_surface if child allocation changes
So the widget is properly aligned.
2016-10-31 19:29:36 +01:00
Timm Bäder
acbdd5c8f2 Fix clip position of windowed widgets 2016-10-28 17:56:51 +02:00
Timm Bäder
82d38e35f8 stack: Use measure() to measure child widget
Simpler code this way \o/
2016-10-28 16:33:02 +02:00
Timm Bäder
9992a616ef widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
2016-10-22 19:05:47 +02:00
Benjamin Otte
edc9a08b7c stack: Use gdk_window_new_child() 2016-10-18 00:22:35 +02:00
Benjamin Otte
4df6ddad54 API: container: Remove gtk_container_set_border_width() 2016-10-16 18:18:58 +02:00
Benjamin Otte
662001b60a API: Remove ability to set visuals on windows
And with it, gtk_widget_get_visual() and gtk_widget_set_visual() are
gone.

We now always use the RGBA visual (if available) and otherwise fall back
to the system visual.
2016-10-16 18:17:21 +02:00
Timm Bäder
0b0d4765a0 Add GtkStackAccessible
Show only the currently visible child to a11y.
2016-05-30 19:12:52 +02:00
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
Matthias Clasen
b86356bc1c GtkStack: split homogeneous
Split homogeneous into separate hhomogeneous and vhomogeneous
properties. vhomogeneous is what we want for popover menus.
2014-10-26 14:59:21 -04:00
Carlos Garnacho
8ff47570af stack: Ensure the bin window has an evmask suitable to windowless children
If a child has set_has_window == FALSE, it purely relies on the events set on
the parent window, for which the bin window used to just ensure the exposure
mask, eating all input events.

https://bugzilla.gnome.org/show_bug.cgi?id=734357
2014-08-12 14:28:34 +02:00
Benjamin Otte
02ccfb5d62 GtkStack: Render a background
https://bugzilla.gnome.org/show_bug.cgi?id=733027
2014-07-12 07:16:33 +02:00
Matthias Clasen
c1867761ca Revert "GtkStack: Render background and chain up gtk_widget_draw ()."
This reverts commit f6695b962f.
2014-07-12 00:33:19 -04:00
William Hua
f6695b962f GtkStack: Render background and chain up gtk_widget_draw ().
https://bugzilla.gnome.org/show_bug.cgi?id=733027
2014-07-11 20:46:03 -04:00
Matthias Clasen
d591341bd1 GtkStack: Avoid a few redundant notify emissions
A few of the property setters were missing the
standard checks.
2014-06-09 13:30:50 -04:00
Matthias Clasen
0a681f9224 GtkStack: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:30:49 -04:00
Matthias Clasen
3957ce4898 GtkStack: Avoid compiler warnings
gcc warns about unhandled enum values in these switch statements,
so add an empty default: case to placate the compiler.
2014-05-02 17:15:49 -04:00
Philip Chimento
5b5813fcdc stack: Add counterparts of OVER_UP_DOWN transition
The GtkStackTransitionType enum now has OVER_DOWN_UP, OVER_LEFT_RIGHT,
and OVER_RIGHT_LEFT values to complement OVER_UP_DOWN.

https://bugzilla.gnome.org/show_bug.cgi?id=726676
2014-05-02 16:54:41 -04:00
Philip Chimento
a27b0bad86 stack: More readability when adding transitions
This small refactor makes the code more readable when adding more
transition types that have left, right, up, and down variations.

It adds inline boolean functions to tell information about transition
types (avoiding long if clauses) and changes long chains of "else if
(transition_type == ...)" into switch statements. Both are only likely
to get longer as more transition types are added.

https://bugzilla.gnome.org/show_bug.cgi?id=726676
2014-05-02 16:54:41 -04:00
Benjamin Otte
73aa7bd2f5 widgets: Remove (GtkTickCallback) casts
Instead, make the functions conform to the prototype, so that casting
isn't needed.
2014-04-29 19:35:29 +02:00
Matthias Clasen
8195244e3b Improve GtkStack documentation
As has been pointed out in
https://bugzilla.gnome.org/show_bug.cgi?id=725711
it is a little confusing that we have the concept of
a visible child and of the child being visible itself.
2014-03-06 22:50:40 -05:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
William Jon McCann
529dafdf0b docs: don't use signal syntax for properties 2014-01-21 22:40:55 -05:00
Steve Frécinaux
49bf3cdba8 GtkStack: add gtk_stack_get_child_by_name()
This new method allows getting a widget from a GtkStack when we know its
name, and will also return NULL if there is no widget going by that
name.

Usage example would be to check if a child with a given name exists
before calling gtk_stack_set_visible_child_name().

https://bugzilla.gnome.org/show_bug.cgi?id=722588
2014-01-21 09:35:22 +01:00
Benjamin Otte
8308f4c1e9 stack: Fix crash on g_object_get("visible-child")
priv->visible_child is not a GtkWidget but a custom struct holding the
widget. So use the getter instead.
2013-11-25 03:49:35 +01:00
Jasper St. Pierre
da0ebcb7da Revert "stack: respect gtk-enable-animations setting"
It already respected enable-animations.

This reverts commit fb9ff44299.
2013-11-19 18:38:56 -05:00
Matthias Clasen
fb9ff44299 stack: respect gtk-enable-animations setting
https://bugzilla.gnome.org/show_bug.cgi?id=712632
2013-11-18 23:19:27 -05:00
Xavier Claessens
9223e3c25a GtkStack: add transition-running property
This is useful to know when the transition is done we can
remove the child from the stack.

https://bugzilla.gnome.org/show_bug.cgi?id=711494
2013-11-12 10:27:45 -05:00
David King
468fd38531 stack: Use g_object_notify_by_pspec()
https://bugzilla.gnome.org/show_bug.cgi?id=711611
2013-11-09 10:45:06 -05:00
David King
2454522b26 stack: Use g_object_class_install_properties()
https://bugzilla.gnome.org/show_bug.cgi?id=711611
2013-11-09 10:45:06 -05:00
Jasper St. Pierre
4f7170fd56 stack: Fix the slide animation if the child has a non-zero allocation position
This can happen if the child has a margin, for instance.
2013-11-01 01:53:20 -04:00
Jasper St. Pierre
3e836dd9fc stack: Scope some variables so that the code is clearer
... that the allocation magic here is for the transition of the
last visible child that's sliding out.
2013-11-01 01:53:20 -04:00
Jasper St. Pierre
ee8b3efbcf stack: Remove some confusing whitespace 2013-10-09 18:29:41 -04:00
David King
5f61183158 stack: Warn when setting a visible child which is not in the stack
https://bugzilla.gnome.org/show_bug.cgi?id=709613
2013-10-08 10:55:29 +01:00
Matthias Clasen
98b78ed5da GtkStack: Add more transition types
This adds new 'over' and 'under' transitions which work by moving
the new page over the previous one, or moving the previous page off
to reveal the new one. We also add an over/under combination that
is going to be used in GtkAboutDialog.

https://bugzilla.gnome.org/show_bug.cgi?id=707187
2013-09-25 23:54:12 -04:00
Paolo Borelli
e59c28743a Add a needs-attention child property to GtkStack
The child property is watched by the StackSwicther which in turns sets a
needs-attention css class on the corresponding button, so that the theme
can for instance show a throbbing animation if one of the hidden pages
needs the user attention.

https://bugzilla.gnome.org/show_bug.cgi?id=707153
2013-09-25 22:34:22 -04:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
Alexander Larsson
e12d3cea47 stack: Use normal opacity groups rather than weird ones in GtkWidget
Since we now do all drawing propagation on the cairo_t (rather than
exposing multiple independent times on the GdkWindows) we no longer
need the opacity 0.999 hack.
2013-07-04 13:30:51 +02:00
Alexander Larsson
06a808cf2a stack: Use new private model, remove priv pointer 2013-07-02 13:43:20 +02:00
Alexander Larsson
264cbc9e35 GtkStack: Switch order on left/right up/down transitions.
When the new child is on the left, scroll right. This makes the
thing look physically "real".
2013-06-13 20:55:05 +02:00
Alexander Larsson
418ac673a3 GtkStack: Fix drawing of sliding
We were not drawing the view window, so the old widget
was clipped for the sliding transitions.
2013-06-13 20:50:41 +02:00
Erick Pérez Castellanos
33a1c4d6e0 GtkStack: Add position-dependent slide transitions
These go left/right or up/down depending on the relative
order of the children being switched between.
2013-06-13 20:33:42 +02:00
Alexander Larsson
e2c8a95af6 GtkStack: Fix double-draw in crossfade
We should only draw the cross-fade on the bin window, not doing this
was causing us to draw it multiple times using ADD which resulted
in weird colors.
2013-05-07 16:40:24 +02:00