Commit Graph

196 Commits

Author SHA1 Message Date
Timm Bäder
56a58655fe Remove unnecessary gtk_widget_show calls 2017-01-22 14:38:21 +01: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
Debarshi Ray
f5818c594c listbox: Don't emit selected-rows-changed, etc. during destruction
https://bugzilla.gnome.org/show_bug.cgi?id=776012
2016-12-19 18:05:51 +01:00
Timm Bäder
31ed68dbfa listbox: Fix row hovering
GtkListBox is not a windowed widget anymore so we can't use
gtk_widget_get_window. Just directly access priv->view_window instead to
get the right window.
2016-12-03 13:19:26 +01:00
Benjamin Otte
e28d94bc8b listbox: Move the priv->gadget allocation
It used to be relative to the window, now it is relative to the widget.

That is necessary so the snapshot fuction doesn't confuse coordinate
systems.
2016-11-30 15:15:08 +01:00
Benjamin Otte
30e0bbeaaa snapshot: convert GtkListBox 2016-11-15 17:49:19 +01:00
Benjamin Otte
da207c9fdd snapshot: Add a snapshot function to GtkCssCustomGadget 2016-11-15 17:48:45 +01:00
Timm Bäder
95eed97586 listbox: Use gtk_widget_measure 2016-11-12 20:37:18 +01:00
Benjamin Otte
b7a72224e1 listbox: Turn into no-window widget 2016-11-06 14:52:56 +01:00
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
Lars Uebernickel
d825249b42 gtklistbox: add bind_model()
gtk_list_box_bind_model() binds a GListModel to a GtkListBox.

This is a first step towards having GListModel support in Gtk. It's not
useful for large models, because GtkListBox always creates all widgets
for all rows.
2015-02-12 11:22:07 +01:00
Timm Bäder
9141eeb60e GtkListBoxRow: Update the listbox's cursor row when focusing
https://bugzilla.gnome.org/show_bug.cgi?id=708320
2015-02-12 09:58:29 +01:00
Carlos Garnacho
594de00cad listbox: Free the multipress gesture on finalize 2015-01-14 17:11:25 +01:00
Matthias Clasen
e6e511eb46 GtkListBox: Fix a bug in unselection
Ensure that gtk_list_box_get_selected_row returns NULL after
gtk_list_box_unselect_all. Add a testcase that detects this
problem.
2014-10-31 22:34:09 -04:00
Matthias Clasen
291e4e107d GtkListBox: Support placeholders in ui files
This makes the gtk_list_box_set_placeholder functionality
available from GtkBuilder

https://bugzilla.gnome.org/show_bug.cgi?id=738111
2014-10-12 18:54:44 -04: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
87ad4ec2c2 GtkListBox: fix up docs 2014-08-16 21:40:39 -04:00
Timm Bäder
f09573757d GtkListBoxRow: Set clip
https://bugzilla.gnome.org/show_bug.cgi?id=734709
2014-08-14 00:13:18 -04:00
Florian Müllner
6f857f87dc listbox: Add missing ::row-selected emissions
Rows are not necessarily selected via select_row_internal(), add
the missing signal emissions there. Also the signal should be emitted
when removing the selection altogether.

https://bugzilla.gnome.org/show_bug.cgi?id=729809
2014-08-03 23:17:01 +02:00
Matthias Clasen
fffd58fca8 GtkListBox: Mention activatable and selectable in the docs 2014-07-15 23:57:34 -04:00
Matthias Clasen
0bfad993ac GtkListBox: Implement non-selectable rows
This commit changes things so that we never mark non-selectable
rows as selected.
2014-07-15 23:57:33 -04:00
Matthias Clasen
7932370ef8 GtkListBox: Style selectable rows differently
We now apply the .button style class to rows that are either
activatable or selectable. Selectable rows only get the .button
if the listbox allows selection. This implies that we need to
update row styles when the selection mode changes, or when the
row gets added to a listbox.
2014-07-15 23:56:47 -04:00
Matthias Clasen
71f589c0b0 GtkListBox: Add a GtkListBoxRow:selectable property
Having an explicit property for this will make it easier
to have a hover style only for rows which are activatable
or selectable.

Rows are selectable by default, to preserve compatibility.
2014-07-15 23:56:47 -04:00
Matthias Clasen
880c6678eb Fix documentation typos 2014-07-15 23:56:47 -04:00
Matthias Clasen
83e9e0bd8f GtkListBox: Refactor ::activatable implementation
Store the value in the row struct, and split the style updating
out into a separate function.
2014-07-15 22:42:29 -04:00
Matthias Clasen
27244fb9d7 listbox: Update docs
Multiple selection is supported now.
2014-07-14 08:48:33 -04:00
Matthias Clasen
a67570b9e0 listbox: Avoid a warning
Don't try to set an adjustment value if we don't have an adjustment.
2014-07-13 15:51:03 -04:00
Matthias Clasen
a2ac9e1baa listbox: Scroll headers on screen
The listbox code relies on the container focus adjustment handling
to scroll the cursor row on screen. But GtkContainer has no idea
about row headers, so ensure that we scroll the header on screen too.
2014-07-13 13:00:37 -04:00
Paolo Borelli
808705327d list-box: fix typo in natural size computation 2014-07-13 15:47:03 +02:00
Matthias Clasen
2b9285e52e GtkListBox: Add an activatable property for rows
This will let us theme activatable rows differently.
We also avoid emitting the ::row-activated signal for
rows that are not activatable. For compatibility reasons,
rows are activatable by default.

https://bugzilla.gnome.org/show_bug.cgi?id=733112
2014-07-13 09:26:27 -04:00
Matthias Clasen
6f6cedcc66 Trivial typo fix 2014-07-12 14:47:48 -04:00
Matthias Clasen
e31056f9b3 GtkListBox: Animate keybindings 2014-07-02 20:58:16 -04:00
Matthias Clasen
6e03ac9958 GtkListBox: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:30:50 -04:00
Carlos Garnacho
933ff62f66 listbox: Use multipress gesture for row selection/activation
This gesture replaces the button_press/release_event handlers.
2014-06-05 16:15:54 +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
Cosimo Cecchi
9eb1e1b15e listbox: don't use focus-line-width 2014-05-09 11:02:46 -07:00
Cosimo Cecchi
241b4c0c75 listbox: don't use focus padding 2014-05-09 11:02:43 -07:00
Matthias Clasen
c813765430 GtkListBox: improve the docs
The documentation was not really clear about ::row-selected
not working for multi-selection.
2014-05-08 07:33:01 -04:00
Paolo Borelli
abf10a74b7 listbox: check gsequence end iter in get_row_at_index 2014-05-04 19:45:28 +02:00
Cosimo Cecchi
24fd96d837 listbox: fix a segfault
Don't dereference a NULL pointer.
2014-05-01 19:48:41 +02:00
Benjamin Otte
d7a3e67025 listbox: Remove unneeded checks
Size vfuncs always get non-null out variables passed, so no need to
check for NULL.
2014-05-01 14:51:28 +02:00
Matthias Clasen
0d55346fbb list-box: Fix copy-paste error
The new function gtk_list_box_get_selected_rows was implemented
as gtk_list_box_get_selected_children.
2014-04-13 14:04:08 -07:00
Matthias Clasen
dbf3a0681a listbox: Emit ::row-selected as we used to
The listbox selection test was failing because we were not
emitting these signals anymore.
2014-04-13 14:04:08 -07:00
Matthias Clasen
69ef54bcd9 listbox: keep emitting ::row-selected
This was accidentally lost when multi-selection was added, causing
sidebars like the one in gnome-contacts or polari to not work any
more.
2014-04-07 23:17:56 -04:00
Matthias Clasen
125c9f207f list box: Avoid excessive signals
We were emitting the a11y ::selection-changed signal much more
often than ::selected-rows-changed. Thats not necessary.
2014-04-06 01:44:38 -04:00
Matthias Clasen
3fe243d346 list box: Cosmetic changes
Shorten variable names from list_box to box, throughout,
and use the BOX_PRIV macro everywhere.
2014-04-06 01:44:37 -04:00
Matthias Clasen
f652120347 list box: Implement multiple selection
This largely copies the flox box implementation, including the
same key bindings.
2014-04-06 01:44:36 -04:00
Matthias Clasen
463c89e540 listbox: Add multi-selection API
This commit adds API for dealing with multi-selection. It is identical
to the flow box API for this purpose. The implementation is still limited
to single-selection, and will be updated in subsequent commits.
2014-04-06 01:44:35 -04:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
William Jon McCann
e34bd4137d docs: use apostrophes in *n't 2014-02-07 13:32:47 -05:00
Carlos Garnacho
628b1f5e1c listbox: return GDK_EVENT_STOP if button events were handled
The button press/release handlers did invariably return FALSE, even
though it shouldn't if a row was found on the event coordinates. Also,
use GDK_EVENT_* defines for the return values.
2014-01-28 16:44:01 +01:00