Commit Graph

137 Commits

Author SHA1 Message Date
Timm Bäder
5c99f7a670 Fix clip of more windowed widgets 2016-10-28 19:33:47 +02:00
Alexander Larsson
70935f0952 Drop support for offscreen GdkWindows
These complicate a lot of GdkWindow internals to implement features
that not a lot of apps use, and will be better achieved using gsk.
So, we just drop it all.
2016-10-25 09:54:37 +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
Matthias Clasen
ea549a3ce4 GtkListBox: Convert to indirect rendering
Note that there is a problem with the pixel cache that causes
listboxes to come out black when in a scrolled window.
2016-10-18 11:49:13 +01:00
Benjamin Otte
f8a48507a6 listbox: Use gdk_window_new_child() 2016-10-18 00:22:35 +02:00
Emmanuele Bassi
b74cd23e29 docs: Add a diagram for GtkListBox nodes
GtkListBox's API reference for CSS nodes should follow the template of
other widget classes.
2016-09-20 23:32:00 +01:00
Joaquim Rocha
f9658a2faf listbox: Select the last row on page down when there are few rows
When pressing page down doesn't retrieve a valid row (because the list
box has few rows), the last visible one should be selected instead.

https://bugzilla.gnome.org/show_bug.cgi?id=770703
2016-09-03 13:52:39 +02:00
Joaquim Rocha
adabec7d25 listbox: Avoid crashing on page down if the list has few rows
The code always assumed that getting a row at a certain 'y' was
possible but if the list box has more empty space than rows then a
valid row may not be retrieved.

https://bugzilla.gnome.org/show_bug.cgi?id=770703
2016-09-03 13:52:39 +02:00
Benjamin Otte
e1a03ead7a Use NULL for generic marshallers in g_signal_new()
glib will use the correct marshaller automatically. And as a side
effect, we also get all glib optimizations, like a va marshaller.
2016-08-29 16:20:54 +02:00
Christian Hergert
3724592efb listbox: short-circuit if no sort function is set
do_sort will crash if sort_func is not defined. Instead of adding a check
there in the hot path, just check for sort_func before invalidating the
sort of the underlying GSequence.
2016-06-20 18:51:42 -07:00
Timm Bäder
a99213100d listbox: Don't compare int to uint 2016-05-12 20:39:39 +02:00
Timm Bäder
0815b21ad4 listbox: Make sure page down/up move at least one row
When the current cursor_row is taller than the page_size we get from the
GtkAdjustment, the previous code would not actually cause any scrolling,
so make sure we just take the row after or before the cursor_row in that
case.

https://bugzilla.gnome.org/show_bug.cgi?id=765261
2016-04-21 23:11:38 -04:00
Matthias Clasen
28042ef336 listbox: Fix css node ordering
When inserting a child at the top, we were not inserting its
css node properly.

https://bugzilla.gnome.org/show_bug.cgi?id=764710
2016-04-11 07:52:39 -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
Timm Bäder
c360b5fb49 Remove more unnecessary redraws
The call to gtk_widget_set_state_flags immediately before these already
queues a redraw/allocate/resize in case they have to be queued.
2016-02-07 19:16:26 +01:00
Timm Bäder
47afccb41b GtkListBox: Optimize _get_row_at_y a bit
Use g_sequence_lookup for a binary search over the rows.
2016-01-06 16:02:59 +01:00
Timm Bäder
a9d5fa4cfe GtkListBox: get_row_at_y can return NULL 2016-01-06 16:02:58 +01:00
Matthias Clasen
4eeeb5811d listbox: Fix an oversight in the row gadget conversion 2015-12-15 14:12:50 -05:00
Matthias Clasen
29accad89a listbox: Convert to gadgets 2015-12-15 08:41:16 -05:00
Matthias Clasen
9fb3716259 listbox: Convert rows to gadgets 2015-12-15 08:41:16 -05:00
Timm Bäder
a28103cf51 Add some more missing nullable annotations 2015-12-01 13:41:35 +01:00
Florian Müllner
0a35886b0a listbox: Use :focus-on-click policy from row instead of list
Using the property from the container is inconsistent with the
:selectable and :activatable properties, which are per row.
2015-11-30 17:59:06 +01:00
Matthias Clasen
acdb7dae4e Cosmetic: Avoid an explicit state variable
Using the state of the context makes it more obviously correct.
2015-11-14 12:32:57 -05:00
Matthias Clasen
cf1adadfed listbox: Cosmetic cleanup
We don't cast these arguments anywhere else, so lets not do here
either.
2015-11-14 12:32:57 -05:00
Matthias Clasen
4f29b4a348 listbox: Add element names
The names used here are list and row.
2015-11-05 13:48:02 -05:00
Matthias Clasen
6791c1413d list box: Remove an unused static 2015-11-03 10:43:48 -05:00
Florian Müllner
de50012371 listbox: Implement :focus-on-click
Similar to buttons-in-toolbars, it can make sense for listbox rows
to not take away the focus from the main application view, for
instance when used for navigation. Support this by taking the newly
added GtkWidget:focus-on-click property into account.

https://bugzilla.gnome.org/show_bug.cgi?id=757269
2015-11-03 07:44:17 -05: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
66f0bdee0a Intern all signal names beforehand
This avoids pointless allocations
2015-09-12 12:50:39 -04:00
Matthias Clasen
5f458e4002 list box: Use g_object_notify_by_pspec everywhere
We already have the pspec at hand, so use it.
2015-09-06 17:11:35 -04:00
Timm Bäder
1405bcb32d GtkListBox: Allow a NULL callback in bind_model
When unsetting the bound model, one can pass NULL, but in that case the
create_func parameter should also be NULL.
2015-09-03 16:12:15 +02:00
Benjamin Otte
207e593075 listbox: Mark activatable rows with a .activatable style class
Do not use .button anymore.

This is for 2 reasons:
1. The styling is seperate in our themes, so it doesn't make sense to
   share the style class.
2. Due to the shared styling of .buton, listbox rows inherit all the
   special case styles that exist for buttons - such as linked buttons,
   header buttons, entry buttons, spinbutton buttons, etc. This means
   that the code has to check all these special cases all the time and
   for listbox rows, this is very slow.
2015-08-26 15:46:07 +02:00
Matthias Clasen
808ea8645a list box: Document incompatible configurations
Explain in the docs that using a model is incompatible with
using filter or sort functions.

http://bugzilla.gnome.org/show_bug.cgi?id=752615
2015-08-25 15:54:58 -04:00
Matthias Clasen
a27309c6e4 list box: Warn for nonworking configurations
GtkListBox sort and filter functionality does not work with
models. Issue a warning in this case.

http://bugzilla.gnome.org/show_bug.cgi?id=752615
2015-08-25 15:54:58 -04:00
Matthias Clasen
1d2ff9a069 list box: Make focusable headers possible
Previously we were assuming that only list box rows could occur
as focus children of a list box, and would crash if that wasn't
the case. This commit handles this case, and integrates focusable
headers into directional keynav and the focus chain.

The typical case of using separators as headers is not affected
by this change.

https://bugzilla.gnome.org/show_bug.cgi?id=753694
2015-08-21 20:51:03 -04:00
Matthias Clasen
a6bb7a9a46 list box: Shorten some static function names 2015-08-16 18:12:16 -04:00
Kalev Lember
d6f51ef7b2 listbox: Avoid using show_all on rows
Don't use gtk_widget_show_all() on row widgets because that would
unconditionally show all of its children. This might be unwanted in case
the row implementation wants to keep some of its children hidden.

This commit changes it to use show() instead of show_all() and relies on
the row widget to control the visibility of its children itself as
appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=753392
2015-08-08 16:54:31 +02:00
Jasper St. Pierre
36c0c9d0b8 listbox: Don't queue draws on the entire widget
The set_state_flags code should already queue redraws when needed.
2015-08-02 12:57:31 -07:00
Matthias Clasen
58fa3d96a8 listbox: Fix shift-selection
Selecting a range of rows with Shift-click was accidentally broken
in e6e511eb46. Make it work again.
2015-07-26 02:40:26 -04:00
Matthias Clasen
1da92c2800 GtkListBox: Improve focus scrolling
We are trying to scroll the header in view together with the
focus row. The way this is implemented works fine when scrolling
up, but falls short when scrolling down. Fix this by making sure
that both the row and the header bar visible.
2015-07-19 22:18:58 -04:00
Matthias Clasen
52c4955d21 GtkListBox: Listen for adjustment changes
We automatically pick up an adjustment from our parent
scrollable, but we failed to update it when it changes.
This is happening in the places sidebar, and it was causing
the focus-tracking to fail there, letting the focus move
out of view. With this change, the focus remains visible.
2015-07-19 22:08:36 -04:00
Matthias Clasen
361915628d list box: Remove unnecessary checks
Again, coverity takes these as clues to complain.
2015-07-17 18:40:11 -04:00
Benjamin Otte
6e4f42f97e cssnode: Change API of some functions
gtk_css_node_set_after/before() are now called
gtk_css_node_insert_after/before().

This brings them in line with other similar APIs (ie GtkListStore). And
it allows easier usage of the API (see changes to gtkbox.c).
2015-07-16 06:15:13 +02:00
Cosimo Cecchi
db76eae41a listbox: don't call gtk_style_context_set_background() 2015-07-01 16:09:22 -07:00
Carlos Soriano
e74d2b7564 gtklistboxrow: propagate in the draw vfunc
So objects connected by g_signal_connect_after actually get
the signal.
This was causing an issue in the dnd highlight, since there
a cairo rectangle is draw using g_signal_connect_after on the draw
signal.
2015-06-10 17:47:23 +02:00
Christian Hergert
aa07c40748 listbox: add support for :first-child, :last-child and others
This applies the proper CSS child ordering semantics using GtkCssNode to
GtkListBox. You can now use :first-child, :last-child, :nth-child(), and
:last-nth-child() selectors.

For example, this allows styling row separators using CSS while ignoring
the separator on the last row.

 GtkListBoxRow {
   border-bottom: 1px solid @borders;
 }
 GtkListBoxRow:last-child {
   border-bottom: none;
 }

When the sort ordering of the listbox changes, we also update the CSS
node ordering.
2015-05-29 20:03:11 -07:00
Ryan Lortie
6e03e7e80a GtkListBox: fix model binding refcount issue
As it is, GtkListBox model binding will work nicely as long as your
create_widget_func returns a floating reference on the newly-created
widget.

If you try to return a full reference (as any higher-level language
would do) then you will leak that reference.

Fix that up by converting any floating references into full references
and then unconditionally releasing the full reference after adding to
the box.

https://bugzilla.gnome.org/show_bug.cgi?id=746893
2015-03-27 12:07:17 -04:00
Rafal Luzynski
3ce3593ebf GtkListBoxRow: add g_return_if_fail to grab_focus, don't crash
Although gtk_list_box_row_grab_focus() is not a public function
it can be easily called by gtk_widget_grab_focus() with a row argument
which has been removed from the list box and has box == NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=744879
2015-02-27 06:31:06 -05:00
Philip Withnall
3d88899072 gtk: Fix various tiny typos in documentation comments
e.g. Invalid syntax in introspection annotations, typos in object names,
accidentally using a gtk-doc comment for an internal function.
2015-02-18 11:38:37 +00:00