Commit Graph

72 Commits

Author SHA1 Message Date
Sophie Herold
a546ae32d7 Remove all nicks and blurbs from param specs
Those property features don't seem to be in use anywhere.
They are redundant since the docs cover the same information
and more. They also created unnecessary translation work.

Closes #4904
2022-05-11 18:16:29 +02:00
Benjamin Otte
bffa5dfddd listview: Fix return_if_fail()s 2022-02-26 20:35:44 +01:00
Matthias Clasen
4a0d3d7acc docs: Reduce redundancy
Remove a boatload of "or %NULL" from nullable parameters
and return values. gi-docgen generates suitable text from
the annotation that we don't need to duplicate.

This adds a few missing nullable annotations too.
2021-05-20 20:45:06 -04:00
Matthias Clasen
7fe0610b68 introspection: Stop using allow-none
allow-none has been deprecated for a long time
already. Instead use optional and nullable everywhere.
2021-05-20 19:17:49 -04:00
Matthias Clasen
ab6a5be0f8 Fix documentation syntax
Properties use : in their link syntax.
2021-05-20 19:16:59 -04:00
Alexander Mikhaylenko
d56711b5d8 listitemwidget: Have .activatable style class if the item is activatable
Match GtkListBox, so it's possible to use the same styles for them.

Update GtkListView and GtkGridView docs to reflect that, fix a few gtk-doc
formatting leftovers along the way.
2021-05-17 18:10:35 +05:00
Matthias Clasen
5568025f1d listview: Convert docs 2021-03-11 16:37:35 +00:00
Benjamin Otte
71e616d17e listview: Use the correct scroll policy
Use the horizontal policy for horizontal decisions, not the vertical
one.

This broke in 0011ce949c.
2020-12-24 06:38:45 +01:00
Matthias Clasen
341244203f docs: Document more accessible roles
GtkListView and GtkGridView were missing this as well.
2020-10-20 22:53:30 -04:00
Matthias Clasen
9c28ecb0da Merge branch 'a11y/atspi' into 'master'
A11y/atspi

See merge request GNOME/gtk!2698
2020-10-15 14:59:24 +00:00
Matthias Clasen
c7bf33a3de columnview: Set accessible roles
Use the TREE_GRID, ROW, COLUMN_HEADER and GRID_CELL roles
for the various widgets involved in a GtkColumnView. To
enable this, we subclass GtkListView for the internal
list in the column view.
2020-10-15 00:16:25 -04:00
Matthias Clasen
6d562b6176 listview: Set accessible roles
Use the LIST and LIST_ITEM roles for GtkListView
and its children. Use the GRID and GRID_CELL roles
for GtkGridView and its children.
2020-10-14 23:34:51 -04:00
Timm Bäder
eca3eab96f Remove unneeded gtkstylecontext.h includes 2020-10-14 15:06:12 -04:00
Andreas Persson
e0134aaf15 docs: Update list widgets docs
Removed sentence that claimed the view will wrap the model in a
GtkSingleSelection, as it's no longer true. Fixed the code example in
GtkListView for the same reason. Fixed a small typo in GtkDropDown docs.
2020-09-06 17:19:24 +02:00
Matthias Clasen
b628338db3 list widgets: Simplify the constructors
Now that both arguments to the _new_with_factory() constructors
are nullable, there's no good reason to keep a separate _new()
around. Just make gtk_list_view_new() and gtk_grid_view_new()
take both a model and a factory.
2020-09-01 12:24:06 -04:00
Matthias Clasen
8d79a32c50 list widgets: Use selection models in the api
Change the apis in GtkListView, GtkColumnView and
GtkGridView to be explicitly about GtkSelectionModel,
to make it obvious that the widgets handle selection.

Update all users.
2020-08-31 17:15:05 -04:00
Matthias Clasen
221786dda3 lists: Mention list style classes in docs
Document that GtkListView, GtkColumnView and GtkListBox
support .rich-list, .navigation-sidebar and .data-table
style classes.
2020-08-13 16:30:21 -04:00
Matthias Clasen
43000abeff listview: Revise constructors
Make both gtk_list_view_new and gtk_list_view_new_with_factory
take a model as first argument, and make all arguments
allow-none and transfer full.

Update all callers.
2020-07-26 18:27:23 -04:00
Timm Bäder
f1b010af66 Add .view to view widgets 2020-06-27 10:51:06 +02:00
Benjamin Otte
a5949960bc listbase: Compute rubberband region on-demand
Instead of storing the active items as we go, compute the affected items
whenever the rubberband changes and in particular when the rubberband
ends.
That way, the rubberband is guaranteed to select a rectangle even
after scrolling very far.

This is achieved by having a get_items_in_rect() vfunc that selects all
the items in the rubberbanded rectangle and returns them as a bitset.
2020-06-26 07:13:32 +02:00
Benjamin Otte
ec4a489093 listview: Allocate rubberband at end of size_allocate()
Otherwise the rubberband uses the wrong scroll offsets.
2020-06-26 07:13:32 +02:00
Benjamin Otte
c2b0330c56 listbase: Move a common function from the children into GtkListBase
We want to use it for the rubberband later.
2020-06-26 07:13:32 +02:00
Matthias Clasen
2437c5a0ae listview: Add an example to the docs
The example is an excerpt from the applauncher
demo in gtk4-demo.
2020-06-05 08:22:48 -04:00
Matthias Clasen
ed985640e8 docs: Expand list widget docs
Begin to flesh out the long descriptions for GtkListView,
GtkGridView and GtkColumnView.
2020-06-04 15:33:53 -04:00
Matthias Clasen
51c6ce1734 list widgets: Document css structure
We didn't fill in this expected part of the widget
documentation yet.
2020-06-04 10:05:17 -04:00
Matthias Clasen
f9287941b4 Change css names of list widget
The new names are

GtkListView - listview row
GtkGridView - gridview child
GtkColumView - columnview header
               columnview listview row

Adwaita css has been updated to preserve
existing styles.

Fixes: #2818
2020-06-04 09:51:49 -04:00
Matthias Clasen
658e4c5357 listview: Use gtk_widget_add_css_class
No need to use the style context api for this anymore.
2020-06-03 17:51:22 -04:00
Matthias Clasen
03c2202942 Add rubberband api
Add an ::enable-rubberband property to GtkListView,
GtkGridView and GtkColumnView.
2020-06-03 13:34:27 -04:00
Matthias Clasen
14d11ebcab listbase: Use a widget for the rubberband
We no longer need to juggle manual css nodes. Just create
a widget for the rubberband, and update its allocation
as we rubberband.
2020-06-03 13:32:57 -04:00
Matthias Clasen
2c4c07c96d listview: Add single-click-activate
Add a single-click-activate property to GtkListView.
2020-05-30 19:26:46 -04:00
Benjamin Otte
e46fa81927 listbase: Take over anchor handling
With that, pretty much all code but allocating the widgets is gone from
the gridview and listview.
2020-05-30 19:26:46 -04:00
Benjamin Otte
33c6b428f7 listbase: Add vfuncs to convert positions to/from coordinates
... and use that to implement PageUp/PageDown.

With that, all keyboard handling has been moved to GtkListBase.
2020-05-30 19:26:46 -04:00
Benjamin Otte
12331e3376 listbase: Move focus moving keybindings here
The focus tracker is not yet moved because that depends on scroll_to()
support and we don't have that yet.
Whoops.
So we use a hack.
2020-05-30 19:26:46 -04:00
Benjamin Otte
2541037ec2 listbase: Move orientable implementation here 2020-05-30 19:26:46 -04:00
Benjamin Otte
9d6aa7d88e listbase: Move selection handling here 2020-05-30 19:26:46 -04:00
Benjamin Otte
0bd16308d6 listbase: Move item manager here
Nothing really changes, because both ListView and GridView still keep
self->item_manager around, but it's set up to point at the base's item
manager.

This way we can slowly move things to GtkListBase that need the item
manager (like trackers).
2020-05-30 19:26:46 -04:00
Benjamin Otte
0011ce949c listbase: Move GtkScrollable implementation
Shared code between GtkGridView and GtkListView.
2020-05-30 19:26:46 -04:00
Benjamin Otte
cc987b31ae Add GtkListBase
This is a base item for GTK's list widgets so they can share some (read:
hopefully a lot of) code.
2020-05-30 19:26:46 -04:00
Benjamin Otte
ea390a4a73 listview: Port various gridview improvements
- Handle anchor as align + top/bottom
  This fixes behavior for cells that are higher than the view
- Add gtk_list_view_adjustment_is_flipped()
  This should fix RTL handling of horizontal lists
- Fix scrolling
  This should make scrolling more reliable, particularly on short lists
  that are only a few pages long.
2020-05-30 19:26:46 -04:00
Benjamin Otte
cb2948eda6 selectionmodel: Add gtk_selection_model_user_select_item()
I'm not sure this should be public API because it's incredibly awkward.
But it should definitely be shared between list widget implementations.
2020-05-30 19:26:46 -04:00
Benjamin Otte
042e13a932 listview: Add move keybindings
My god, these are a lot.

And my god, these are complicated to get right.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2b9481ecdc listview: Add gtk_list_view_get_position_at_y() 2020-05-30 19:26:45 -04:00
Benjamin Otte
2539828eac listview: Add a focus tracker
This ensures that the row with the input focus always stays available,
even when scrolled out of view.
2020-05-30 19:26:45 -04:00
Benjamin Otte
4b6f3e0f2c listview: Implement (un)select all
Adds listitem.select-all and listitem.unselect-all actions and installs
the same keybindings as the treeview for those actions.
2020-05-30 19:26:45 -04:00
Benjamin Otte
b9eb818b57 listview: Track focus movements and update selection
When focus moves via tab/arrow, we need to select the new item.
2020-05-30 19:26:45 -04:00
Benjamin Otte
eda547fc4e listview: Implement activation
- a GtkListview::activate signal
- a GtkListItem::activatable property
- activate list items on double clicks and <Enter> presses
2020-05-30 19:26:45 -04:00
Benjamin Otte
443e44853a listview: Pass the CSS name of listitems to the manager
... instead of hardcoding "row".
2020-05-30 19:26:45 -04:00
Benjamin Otte
626c525706 listview: Expose GtkListItemFactory APIs
Due to the many different ways to set factories, it makes sense to
expose them as custom objects.

This makes the actual APIs for the list widgets simpler, because they
can just have a regular "factory" property.

As a convenience function, gtk_list_view_new_with_factory() was added
to make this whole approach easy to use from C.
2020-05-30 19:26:45 -04:00
Benjamin Otte
86ad1bec16 listview: Implement GtkOrientable 2020-05-30 19:26:45 -04:00
Benjamin Otte
cfcf0a7a8a listview: Implement extending selections
Shift-clicking to extend selections now also works, imitating the
behavior of normal clicking and Windows Explorer (but not treeview):

1. We track the last selected item (normally, not via extend-clicking).

2. When shift-selecting, we modify the range from the last selected item
   to this item the same way we modify the regular item when not using
   shift:

2a. If Ctrl is not pressed, we select the range and unselect everything
    else.

2b. If Ctrl is pressed, we make the range have the same selection state
    as the last selected item:
    - If the last selected item is selected, select the range.
    - If the last selected item is not selected, unselect the range.
2020-05-30 19:26:45 -04:00