Commit Graph

248 Commits

Author SHA1 Message Date
Matthias Clasen
ffd6baec42 gtk: Intern css names
This avoids a bunch of strdups at startup.
2017-11-17 22:49:57 -05:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Timm Bäder
3b9aa2f8d9 widget: Allow 0×0 allocations
Don't MAX the allocations with 1 anymore.
2017-10-06 14:38:07 +02:00
Timm Bäder
9125dc7069 box: Drop priv pointer 2017-10-06 14:24:52 +02:00
Timm Bäder
392af59140 box: Remove return value from box_pack
Unused.
2017-09-29 10:50:33 +02:00
Timm Bäder
ad1f5fe61a box: Remove size_allocate_no_center
GtkBox never has a center widget these days.
2017-09-29 10:49:41 +02:00
Timm Bäder
a8a755e5cd widget: Remove gtk_widget_set_redraw_on_alloc
Since gtk+ draws more than the widget and allocates more size to it than
it knows about, this flag doesn't work anymore. Removing it (or setting
it to TRUE for widgets that used to set it to FALSE) fixes drawing
invalidation when these widgets get allocated a new size.
2017-08-09 16:26:26 +02:00
Timm Bäder
36ab70ddf5 widget: Add baseline and out_clip parameters to size-allocate
Since setting a clip is mandatory for almost all widgets, we can as well
change the size-allocate signature to include a out_clip parameter, just
like GtkCssGadget did. And since we now always propagate baselines, we
might as well pass that one on to size-allocate.

This way we can also make sure to transform the clip returned from
size-allocate to parent-coordinates, i.e. the same coordinate space
priv->allocation is in.
2017-07-19 21:27:16 -04:00
Timm Bäder
1e4d11b995 box: Ignore baselines when vertical
For now.
2017-07-19 21:27:15 -04:00
Timm Bäder
99b00b4d9c sizerequest: Assert that min_size >= 0
This should generally be true, so remove the checks from gtkbox.c and
move it into gtksizerequest.c
2017-07-19 21:27:13 -04:00
Timm Bäder
a9f9ef3f53 box: Use widget children list in count_expand_children
It's still less dereferencing than the previous code.
2017-07-19 21:27:13 -04:00
Timm Bäder
e37457adf9 box: Remove gadget 2017-07-19 21:27:11 -04:00
Timm Bäder
5baaa76bac box: Remove gadget accessor 2017-07-19 21:27:11 -04:00
Timm Bäder
66b720fbb8 box: Remove gadget usage
Keep the gadget member in the private struct around for now so
GtkButtonBox doesn't break terribly.
2017-07-19 21:27:11 -04:00
Timm Bäder
7b7e85d618 box: Remove css box drawing 2017-07-19 21:27:10 -04:00
Timm Bäder
179b8b0cbc Fix gdk_rectangle_union calls
Turns out that the destination is the last parameter, not the first one.
This fixes the flickering in the first page of the widget-factory when
using the expander on page 2.
2017-04-28 11:27:09 +02:00
Timm Bäder
927f2f5c06 box: Compute clips directly
Instead of using _gtk_widget_set_simple_clip *and*
gtk_container_get_children_clip
2017-04-25 20:30:37 +02:00
Timm Bäder
fb927d1993 box: Remove center child 2017-04-25 20:30:37 +02:00
Timm Bäder
f053a63d74 container: Remove include_internals parameter from forall
with include_internals=TRUE, this is the same as the (still private)
gtk_widget_forall, or just using the children/sibling accessors in a
loop.
2017-04-25 20:30:37 +02:00
Timm Bäder
c92b7d4224 box: Remove fill child property
GtkWidget:halign and GtkWidget:valign are sufficient
2017-04-25 20:30:37 +02:00
Timm Bäder
5729ea7744 box: Remove expand child property
GtkWidget already has hexpand/vexpand properties.
2017-04-25 20:30:37 +02:00
Timm Bäder
22b493a6ac box: Make sure center_req is initialized
In case we have an invisible center widget, we never initialize it, but
later still use it.
2017-03-20 14:16:56 +01:00
Timm Bäder
f860ff8647 widget: Remove get_valign_with_baseline
This only existed for backwards compat reasons which aren't interesting
for gtk4.
2017-03-05 15:18:32 +01:00
Alexander Larsson
7bee22bcb6 Avoid some more type checks for internal calls 2017-01-11 15:27:51 +01:00
Daniel Boles
2a7171534e Box: Restore an accidentally deleted comment
Also, split a MAX() onto its own line to match the others.
2016-12-26 10:57:51 +00:00
Daniel Boles
71bbd8881f Box: avoid recalc/reassignments, improve var names
Homogeneous branches repeated the calculation/assignment of the initial
space available to children. This avoids that by shuffling some code.

Perhaps more importantly, in doing that, I ended up with some ambiguous
names, and Company and I realised how vague the pre-existing naming was.
"size" becomes "extra_space", as this is what it represents. Conversely,
"extra" becomes "size_given_to_child" (albeit still given out in two
different ways depending on whether the Box is homogeneous). My hope is
that these sections of code are now somewhat less baffling than before!
2016-12-25 23:16:14 +00:00
Daniel Boles
5d10174031 Box: Don't unnecessarily repeat a function call
The spacing was already saved in a variable just above.
2016-12-25 21:46:40 +00:00
Benjamin Otte
0dbdf0c428 gadget: Remove gtk_css_gadget_draw()
And with it, remove the draw func from custom gadgets, that has been
NULL everywhere.

All gadgets are snapshot now.
2016-12-20 18:01:12 +01:00
Benjamin Otte
75c3d193f6 box: Implement support for border-spacing 2016-12-10 04:32:55 +01:00
Benjamin Otte
5aea108802 box: Remove unused member variable 2016-12-10 04:32:55 +01:00
Benjamin Otte
8ac7918e0b snapshot: convert GtkBox 2016-11-15 17:48:45 +01:00
Benjamin Otte
da207c9fdd snapshot: Add a snapshot function to GtkCssCustomGadget 2016-11-15 17:48:45 +01:00
Timm Bäder
6488dde4fd box: Use measure() to measure child sizes 2016-10-31 12:20:41 +01:00
Timm Bäder
76ff53193a box: Mark out params of _query_packing as (optional) 2016-10-31 12:20:41 +01:00
Timm Bäder
3154d3f258 box: Remove unused private API 2016-10-31 12:20:41 +01: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
Emmanuele Bassi
137ff8ede7 box: Port from immediate to deferred rendering
Drop the ::draw() vfunc implementation in favour of the
::get_render_node() vfunc.
2016-10-18 11:49:10 +01:00
Benjamin Otte
4df6ddad54 API: container: Remove gtk_container_set_border_width() 2016-10-16 18:18:58 +02:00
Timm Bäder
f45dadadd0 box: Remove 'padding' child property 2016-10-16 18:17:21 +02:00
Timm Bäder
fb3d9022ad Remove GtkHBox 2016-10-16 18:17:21 +02:00
Christoph Reiter
4556d0f0fe gtkbox: remove unnecessary queue_compute_expand()
The expand child property does not have any effect on the
expand state of the GtkBox, so queuing a compute_expand
when changing it is not needed.

https://bugzilla.gnome.org/show_bug.cgi?id=769162
2016-08-01 09:02:04 -04:00
Matthias Clasen
bf66cd1e94 box: Only emit ::child-notify when necessary
We can easily check if the values for expand, padding and so forth
actually changed, so lets do it.
2016-05-04 15:05:08 -04:00
Matthias Clasen
6b53138a01 box: Fix rtl allocation with center widget
The code for adjusting the center widget allocation in case
of uneven sides never worked right in RTL. This was finally
noticed for tabs with close button, which commonly use a
centered label.
2016-02-20 16:45:26 -05:00
Carlos Garcia Campos
170cb01675 Revert "Remove _gtk_box_get_children"
This reverts commit 572e9a0402.

_gtk_box_get_children was not doing exactly the same than
gtk_container_get_children does, because the latter uses the forall
implementation of GtkBox that takes into account the children pack mode while
the former just iterated the list of children. This broke the order of
the buttons in a GtkButtonBox when they were packaged with PACK_END.
2016-02-12 13:29:21 +01:00
Timm Bäder
572e9a0402 Remove _gtk_box_get_children
It's doing exactly the same thing as gtk_container_get_children.
2016-02-04 13:32:34 +01:00
Matthias Clasen
7743944124 GtkBox: Documentation tweak 2016-01-13 00:39:53 -05:00
Matthias Clasen
2677eee720 box: Document child node ordering 2016-01-12 23:40:28 -05:00
Matthias Clasen
d81f8c1025 box: Add a way to get the gadget
This will be used in GtkButtonBox.
2015-12-18 07:37:52 -05:00
Matthias Clasen
9c88256441 box: Trivial doc change
All the CSS sections are named CSS nodes, so do the same here.
2015-12-15 08:41:16 -05:00
Benjamin Otte
49fea0b0f5 box: Port to gadgets 2015-12-15 08:41:16 -05:00