summaryrefslogtreecommitdiff
path: root/gtk/gtklistitemmanager.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix various compiler warnings with GCC 13Emmanuele Bassi2023-05-161-10/+13
| | | | | There are various null dereference warnings in GtkListItemManager that make the build noisy.
* listitemmanager: Create header items for sectionsBenjamin Otte2023-05-091-62/+142
| | | | | Now, finally, listitemmanager has all the necessary support to make section headers work.
* listitemmanager: Add GtkListItemChangeBenjamin Otte2023-05-091-256/+148
| | | | | | | ... for tracking widgets during changes. This just pulls all the different disjointed parts into one struct with a sensible API.
* listitemmanager: Add GtkListHeaderBase and vfuncsBenjamin Otte2023-05-091-3/+11
| | | | | | This is plumbing for section handling. The vfuncs don't do anything, this is just the infrastructure.
* listitemmanager: Make sections configurableBenjamin Otte2023-05-091-1/+80
| | | | | | Add a gtk_list_item_manager_set_has_sections() (default: FALSE) that requires explicit turning on for the listitemmanager to gain section support.
* listitemmanager: Add/remove sections as neededBenjamin Otte2023-05-091-44/+165
| | | | | | | When ensuring widgets, ensure that their section is known. This will be relevant when we use section widgets. Also ensure that sections that don't cover any widget get destroyed.
* listitemmanager: Add gtk_list_tile_get_next_skip()Benjamin Otte2023-05-091-25/+32
| | | | | | | ... and gtk_list_tile_get_previous_skip() and use them. Allows skipping over REMOVED and FILLER tiles which makes the code a lot more readable.
* listitemmanager: Add gtk_list_tile_set_type()Benjamin Otte2023-05-091-10/+16
|
* listitemmanager: Properly handle sections during add/removeBenjamin Otte2023-05-091-21/+233
| | | | | We don't insert sections ourselves yet, but we handle the existing one when items get added or removed.
* listitemmanager: Augment header/footer infoBenjamin Otte2023-05-091-0/+27
|
* listitemmanager: Add section tilesBenjamin Otte2023-05-091-0/+13
| | | | | For now, we just have a HEADER at the start and a FOOTER at the end. That's hard enough to get right.
* listitemmanager: Add tile typesBenjamin Otte2023-05-091-11/+70
| | | | | | We have a FILLER and a REMOVED type now. Also makes gc() more sensitive to types.
* listitemmanager: Add a type to tilesBenjamin Otte2023-05-091-1/+5
| | | | There's only one type for now, but hey, you have to start somewhere.
* listview: Move ::factory out of the item managerBenjamin Otte2023-03-231-47/+0
| | | | | It's a listitemwidget property, and the item manager manages the items, not the widgets.
* listview: Move ::single-click-activate out of the item managerBenjamin Otte2023-03-231-30/+0
| | | | | It's a listitemwidget property, and the item manager manages the items, not the widgets.
* listitemmanager: Create widgets via vfuncBenjamin Otte2023-03-231-13/+8
| | | | | We now have listitemmanager just create GtkListItemBase objects via vfunc and use them.
* listitemwidget: split out GtkListItemBaseBenjamin Otte2023-03-231-25/+26
| | | | | | | There's 2 reasons for this: 1. Adding a custom widget for columnview rows 2. Using this as base class for sections
* itemmananger: Remove the user dataBenjamin Otte2023-03-231-6/+3
| | | | Use the widget instead. They're the same anyway.
* listitemmanager: Clean up headerBenjamin Otte2023-03-231-24/+0
| | | | Remove all unused functions and an unused macro.
* gtk: Stop using g_sliceMatthias Clasen2023-03-141-2/+2
|
* listitemmanager: Add gtk_list_item_manager_get_nearest_tile()Benjamin Otte2023-03-101-21/+104
| | | | | | | | | ... and make the tile finding code use distance. This also changes how gtk_list_item_manager_get_tile_at() finds the right tile, so this is a custom commit for bisectability. gtk_list_item_manager_get_nearest_tile() isn't used yet.
* gridview: Add a filler tile for empty spaceBenjamin Otte2023-03-051-0/+6
| | | | | | | | That stupid space in the bottom right when n_items isn't a multiple of n_columns needs its own tile, or we'll get errors about not finding a tile. So make one.
* listview: Simplify a vfuncBenjamin Otte2023-03-051-1/+1
| | | | | | | | Instead of making it 2 vfuncs for getting horizontal and vertical area, make it one vfunc to get the area. Also rewrite the implementations to use the tile's area instead of trying to deduce things with fancy math.
* listitemmanager: Add a split vfunc and use itBenjamin Otte2023-03-051-92/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of randomly changing tiles, the listitemmanager gains a split vfunc that listview and gridview implement so they can keep their tile areas intact. The listitemmanager will now conform to these rules: 1. Never delete a tile. This ensures that all areas stay intact. 2. Never change the n_items of a tile other than setting them to 0. This causes "empty" areas to appear, but listview/gridview can easily check for them by checking for tile->n_items == 0. gtk_list_tile_gc() will get rid of them. 3. Adding items always creates new tiles that are added with empty area. That way they don't interrupt any existing machinery until the next allocation. 4. Adding/removing widgets has no effect on areas This is useful in particular when scrolling where new widgets are moving between tiles. When the manager moves the widgets, it may split some areas, but will not remove any existing tiles, so the whole area stays intact and the list can deal with further scroll events before an allocation. This improve the situation for #3334
* listitemmanager: Remove unused functionalityBenjamin Otte2023-03-051-12/+7
| | | | | Both ListView and GridView use GtkListTile now, so no need anymore for custom machinery.
* gridview: Redo tile managementBenjamin Otte2023-03-051-0/+93
| | | | | | | | | | | | | | | | | | | | | | | | | Instead of the custom size property, use the new tile size. Also introduce the ability to split tiles, so that gridview can split a layout that would look like (question mark denoting cells without a widget, which in this case would be a single tile) █ █ █ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? into 3 rectangular tiles like so: █ █ █ A A B B B B B B B B B B C C C This of course also means we need to be able to merge those tiles again when cells got added/deleted or the gridview was resized. For that job, gtk_list_tile_gc() exists now, which removes tiles without items and merges adjacent tiles without widgets.
* listview: Get rid of ListRow and its heightBenjamin Otte2023-03-051-0/+55
| | | | Use the tiles' area instead.
* list: Allow storing size in the ListTileBenjamin Otte2023-03-051-0/+79
| | | | | | | | | | | | | | ... and use it to handle ListView allocations. Nothing spectacular, just proof of concept. The code introduces the idea that every tile stores its area (others would call it "allocation", but I avoided that because tiles aren't widgets). This should allow moving lots of code into gtklistbase.c and not require special handling inside ListView and GridView. And that in turn hopefully makes it easier to add more features (like sections and so on.)
* list: Make GtkListTile more prominentBenjamin Otte2023-03-051-4/+4
| | | | | | | * Instead of using a gpointer to refer to it, use the GtkListTile type. * Use gtk_list_tile_get_foo() instead of gtk_list_item_manager_get_tile_foo() naming.
* list: Rename GtkListItemManagerItem => GtkListTileBenjamin Otte2023-03-051-152/+152
| | | | | That's a good description for what the job of those elements is: They're a tile in the lists scrollable area.
* listitemmanager: Clarify warningBenjamin Otte2022-05-141-1/+1
| | | | | | Lars doesn't have an opinion on this problem anymore. And when people see this warning, they should know what to do.
* listview: Fix return_if_fail()sBenjamin Otte2022-02-261-1/+1
|
* listitemmanager: Add a few assertionsMatthias Clasen2021-09-171-1/+4
| | | | This might help poor static analyzers.
* gtk: Clean up docs syntaxMatthias Clasen2021-05-221-9/+9
| | | | Replace leftover gtk-doc syntax (#Type) with backquotes.
* introspection: Stop using allow-noneMatthias Clasen2021-05-201-1/+1
| | | | | allow-none has been deprecated for a long time already. Instead use optional and nullable everywhere.
* Documentation fixesMatthias Clasen2021-05-201-7/+7
| | | | | Mostly fixing up indentation of continuation lines, and other small cleanups.
* Fix unused variable warningsMatthias Clasen2021-04-121-1/+1
| | | | | These happen for variables which are only used in assertions, when assertions are disabled.
* listview: Set accessible rolesMatthias Clasen2020-10-141-1/+5
| | | | | | Use the LIST and LIST_ITEM roles for GtkListView and its children. Use the GRID and GRID_CELL roles for GtkGridView and its children.
* listitemmanager: Do a better job on double itemsBenjamin Otte2020-07-161-13/+7
| | | | | | | Previously, we would unparent the existing item that we were about to reuse, and not the duplicate one. Change that.
* listitemmanager: Update selections properlyBenjamin Otte2020-06-081-10/+1
| | | | | | Replace a previous fix with a more correct one: Update the selected state from the model instead of reusing the old state, the model might have updated the selected state.
* listitemmanager: Handle selection-changes properlyMatthias Clasen2020-06-061-0/+9
| | | | | | | | | | | | The selection model will only emit one of items-changed or selection-changed, so when we handle an items-changed, we must assume that selection state may have changed for any of the newly added items. This fixes lingering selection state in the visible range if you change the sorting of the colors demo. Fixes: #2827
* listitemwidget: Add single-click-activateMatthias Clasen2020-05-301-0/+30
| | | | | | | Add a mode to GtkListItemWidget that activates on single click and selects on hover. Make GtkListItemManager set this on its items when its own 'property' of the same name is set.
* listitemfactory: Reorganize vfuncsBenjamin Otte2020-05-301-4/+15
| | | | | Instead of bind/rebind/update/unbind, we now just have update, and the factories get to interpret that in the way they want.
* listitem: Make this a GObjectBenjamin Otte2020-05-301-33/+23
| | | | | | | | | | | | | | | This splits GtkListItem into 2 parts: 1. GtkListItem This is purely a GObject with public API for developers who want to populate lists. There is no chance to cause conflict with GtkWidget properties that the list implementation assumed control over and defines a clear boundary. 2. GtkListItemWidget The widget part of the listitem. This is not only fully in control of the list machinery, the machinery can also use different widget implementations for different list widgets like I inted to for GtkColumnView.
* listitemmanager: Handle NULL factoryBenjamin Otte2020-05-301-7/+15
| | | | Just don't call it and create empty listitems.
* listview: Pass the CSS name of listitems to the managerBenjamin Otte2020-05-301-1/+4
| | | | ... instead of hardcoding "row".
* listitemfactory: Sanitize APIsBenjamin Otte2020-05-301-1/+2
| | | | | | | | | | | | Make sure the APIs follow a predictable path: setup bind rebind/update (0-N times) unbind teardown This is the first step towards providing multiple different factories.
* listitemmanager: Add trackersBenjamin Otte2020-05-301-207/+381
| | | | | | | | | | | | ... and replace the anchor tracking with a tracker. Trackers track an item through the list across changes and ensure that this item (and potentially siblings before/after it) are always backed by a GtkListItem and that if the item gets removed a replacement gets chosen. This is now used for tracking the anchor but can also be used to add trackers for the cursor later.
* listitemmanager: SimplifyBenjamin Otte2020-05-301-136/+59
| | | | | | | | Remove a bunch of API from the headers that isn't used anymore and then refactor code to not call it anymore. In particular, get rid of GtkListItemManagerChange and replace it with a GHashTable.
* listitemmanager: Move list of listitems hereBenjamin Otte2020-05-301-19/+657
| | | | | All the listview infrastructure moved with it, so the next step is moving that back...