listitemmanager: Add a type to tiles

There's only one type for now, but hey, you have to start somewhere.
This commit is contained in:
Benjamin Otte 2023-04-05 02:49:03 +02:00
parent 7856c52882
commit 35543f60d9
2 changed files with 11 additions and 1 deletions

View File

@ -621,6 +621,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
tile = gtk_rb_tree_insert_before (self->items, tile);
tile->type = GTK_LIST_TILE_ITEM;
tile->n_items = n_items;
gtk_rb_tree_node_mark_dirty (tile);
@ -632,7 +633,8 @@ gtk_list_item_manager_merge_list_items (GtkListItemManager *self,
GtkListTile *first,
GtkListTile *second)
{
if (first->widget || second->widget)
if (first->widget || second->widget ||
first->type != GTK_LIST_TILE_ITEM || second->type != GTK_LIST_TILE_ITEM)
return FALSE;
first->n_items += second->n_items;
@ -666,8 +668,10 @@ gtk_list_tile_split (GtkListItemManager *self,
GtkListTile *result;
g_assert (n_items <= tile->n_items);
g_assert (tile->type == GTK_LIST_TILE_ITEM);
result = gtk_rb_tree_insert_after (self->items, tile);
result->type = GTK_LIST_TILE_ITEM;
result->n_items = tile->n_items - n_items;
tile->n_items = n_items;
gtk_rb_tree_node_mark_dirty (tile);

View File

@ -43,8 +43,14 @@ typedef struct _GtkListTile GtkListTile;
typedef struct _GtkListTileAugment GtkListTileAugment;
typedef struct _GtkListItemTracker GtkListItemTracker;
typedef enum
{
GTK_LIST_TILE_ITEM
} GtkListTileType;
struct _GtkListTile
{
GtkListTileType type;
GtkWidget *widget;
guint n_items;
/* area occupied by tile. May be empty if tile has no allcoation */