Merge branch 'drop-filler-tiles' into 'main'

Drop the FILLER tile type

See merge request GNOME/gtk!5993
This commit is contained in:
Benjamin Otte 2023-05-20 17:18:53 +00:00
commit 3beaf0962c
5 changed files with 28 additions and 77 deletions

View File

@ -756,14 +756,8 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
min_row_height = ceil ((double) height / GTK_GRID_VIEW_MAX_VISIBLE_ROWS);
gtk_list_base_get_border_spacing (GTK_LIST_BASE (self), &xspacing, &yspacing);
/* before we start: gc tiles */
for (tile = gtk_list_tile_gc (self->item_manager, gtk_list_item_manager_get_first (self->item_manager));
tile != NULL && tile->type == GTK_LIST_TILE_FILLER;
tile = gtk_list_tile_gc (self->item_manager, tile))
{};
/* step 0: exit early if list is empty */
tile = gtk_list_item_manager_get_first (self->item_manager);
tile = gtk_list_tile_gc (self->item_manager, gtk_list_item_manager_get_first (self->item_manager));
if (tile == NULL)
{
gtk_list_base_allocate (GTK_LIST_BASE (self));
@ -889,16 +883,16 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
/* Add a filler tile for empty space in the bottom right */
if (i > 0)
{
GtkListTile *filler;
tile = gtk_list_item_manager_get_last (self->item_manager);
filler = gtk_list_tile_append_filler (self->item_manager, tile);
GtkListTile *footer = gtk_list_item_manager_get_last (self->item_manager);
g_assert (gtk_list_tile_is_footer (footer));
tile = gtk_rb_tree_node_get_previous (footer);
gtk_list_tile_set_area_position (self->item_manager,
filler,
footer,
column_start (self, xspacing, i),
y);
gtk_list_tile_set_area_size (self->item_manager,
filler,
column_end (self, xspacing, self->n_columns - 1) - filler->area.x,
footer,
column_end (self, xspacing, self->n_columns - 1) - footer->area.x,
tile->area.height);
}
@ -1343,6 +1337,8 @@ gtk_grid_view_set_factory (GtkGridView *self,
if (!g_set_object (&self->factory, factory))
return;
gtk_grid_view_update_factories (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FACTORY]);
}

View File

@ -198,7 +198,6 @@ gtk_list_item_manager_augment_node (GtkRbTree *tree,
aug->has_footer = TRUE;
break;
case GTK_LIST_TILE_ITEM:
case GTK_LIST_TILE_FILLER:
case GTK_LIST_TILE_REMOVED:
aug->has_header = FALSE;
aug->has_footer = FALSE;
@ -633,7 +632,7 @@ static GtkListTile *
gtk_list_tile_get_next_skip (GtkListTile *tile)
{
for (tile = gtk_rb_tree_node_get_next (tile);
tile && (tile->type == GTK_LIST_TILE_FILLER || tile->type == GTK_LIST_TILE_REMOVED);
tile && tile->type == GTK_LIST_TILE_REMOVED;
tile = gtk_rb_tree_node_get_next (tile))
{ }
@ -644,7 +643,7 @@ static GtkListTile *
gtk_list_tile_get_previous_skip (GtkListTile *tile)
{
for (tile = gtk_rb_tree_node_get_previous (tile);
tile && (tile->type == GTK_LIST_TILE_FILLER || tile->type == GTK_LIST_TILE_REMOVED);
tile && tile->type == GTK_LIST_TILE_REMOVED;
tile = gtk_rb_tree_node_get_previous (tile))
{ }
@ -885,7 +884,6 @@ gtk_list_item_manager_remove_items (GtkListItemManager *self,
gtk_list_tile_set_type (tile, GTK_LIST_TILE_REMOVED);
break;
case GTK_LIST_TILE_FILLER:
case GTK_LIST_TILE_REMOVED:
default:
g_assert_not_reached ();
@ -928,7 +926,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
{
/* at end of list, pick the footer */
for (tile = gtk_rb_tree_get_last (self->items);
tile && (tile->type == GTK_LIST_TILE_REMOVED || tile->type == GTK_LIST_TILE_FILLER);
tile && tile->type == GTK_LIST_TILE_REMOVED;
tile = gtk_rb_tree_node_get_previous (tile))
{ }
@ -1029,34 +1027,6 @@ gtk_list_tile_split (GtkListItemManager *self,
return result;
}
/*
* gtk_list_tile_append_filler:
* @self: the listitemmanager
* @previous: tile to append to
*
* Appends a filler tile.
*
* Filler tiles don't refer to any items or header and exist
* just to take up space, so that finding items by position gets
* easier.
*
* They ave a special garbage-collection behavior, see
* gtk_list_tile_gc().
*
* Returns: The new filler tile
**/
GtkListTile *
gtk_list_tile_append_filler (GtkListItemManager *self,
GtkListTile *previous)
{
GtkListTile *result;
result = gtk_rb_tree_insert_after (self->items, previous);
result->type = GTK_LIST_TILE_FILLER;
return result;
}
/*
* gtk_list_tile_gc:
* @self: the listitemmanager
@ -1083,13 +1053,6 @@ gtk_list_tile_gc (GtkListItemManager *self,
if (tile == NULL)
return NULL;
if (tile->type == GTK_LIST_TILE_FILLER)
{
next = gtk_rb_tree_node_get_next (tile);
gtk_rb_tree_remove (self->items, tile);
tile = next;
}
while (tile)
{
next = gtk_rb_tree_node_get_next (tile);
@ -1113,7 +1076,6 @@ gtk_list_tile_gc (GtkListItemManager *self,
case GTK_LIST_TILE_FOOTER:
case GTK_LIST_TILE_UNMATCHED_HEADER:
case GTK_LIST_TILE_UNMATCHED_FOOTER:
case GTK_LIST_TILE_FILLER:
break;
case GTK_LIST_TILE_REMOVED:
@ -1180,7 +1142,6 @@ gtk_list_item_manager_release_items (GtkListItemManager *self,
deleted_section = TRUE;
break;
case GTK_LIST_TILE_FILLER:
case GTK_LIST_TILE_REMOVED:
default:
g_assert_not_reached ();
@ -1414,7 +1375,6 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
break;
case GTK_LIST_TILE_UNMATCHED_FOOTER:
case GTK_LIST_TILE_FILLER:
case GTK_LIST_TILE_REMOVED:
default:
g_assert_not_reached ();
@ -1660,9 +1620,7 @@ gtk_list_item_manager_clear_model (GtkListItemManager *self)
for (tile = gtk_list_tile_gc (self, gtk_list_item_manager_get_first (self));
tile;
tile = gtk_list_tile_gc (self, tile))
{
g_assert (tile->type == GTK_LIST_TILE_FILLER);
}
{ }
g_assert (gtk_rb_tree_get_root (self->items) == NULL);
}
@ -1775,7 +1733,6 @@ gtk_list_item_manager_set_has_sections (GtkListItemManager *self,
footer = tile;
break;
case GTK_LIST_TILE_ITEM:
case GTK_LIST_TILE_FILLER:
case GTK_LIST_TILE_REMOVED:
break;
default:

View File

@ -51,7 +51,6 @@ typedef enum
GTK_LIST_TILE_FOOTER,
GTK_LIST_TILE_UNMATCHED_HEADER,
GTK_LIST_TILE_UNMATCHED_FOOTER,
GTK_LIST_TILE_FILLER,
GTK_LIST_TILE_REMOVED,
} GtkListTileType;
@ -96,6 +95,17 @@ GtkListTile * gtk_list_item_manager_get_nearest_tile (GtkListItemMana
int x,
int y);
static inline gboolean
gtk_list_tile_is_header (GtkListTile *tile)
{
return tile->type == GTK_LIST_TILE_HEADER || tile->type == GTK_LIST_TILE_UNMATCHED_HEADER;
}
static inline gboolean
gtk_list_tile_is_footer (GtkListTile *tile)
{
return tile->type == GTK_LIST_TILE_FOOTER || tile->type == GTK_LIST_TILE_UNMATCHED_FOOTER;
}
guint gtk_list_tile_get_position (GtkListItemManager *self,
GtkListTile *tile);
@ -116,8 +126,6 @@ void gtk_list_tile_set_area_size (GtkListItemMana
GtkListTile * gtk_list_tile_split (GtkListItemManager *self,
GtkListTile *tile,
guint n_items);
GtkListTile * gtk_list_tile_append_filler (GtkListItemManager *self,
GtkListTile *previous);
GtkListTile * gtk_list_tile_gc (GtkListItemManager *self,
GtkListTile *tile);

View File

@ -235,7 +235,6 @@ gtk_list_view_update_factories_with (GtkListView *self,
case GTK_LIST_TILE_UNMATCHED_HEADER:
case GTK_LIST_TILE_FOOTER:
case GTK_LIST_TILE_UNMATCHED_FOOTER:
case GTK_LIST_TILE_FILLER:
case GTK_LIST_TILE_REMOVED:
g_assert (tile->widget == NULL);
break;

View File

@ -71,9 +71,6 @@ print_list_item_manager_tiles (GtkListItemManager *items)
g_string_append_c (string, ')');
break;
case GTK_LIST_TILE_FILLER:
g_string_append_c (string, '_');
break;
case GTK_LIST_TILE_REMOVED:
g_string_append_c (string, '.');
break;
@ -123,7 +120,7 @@ check_list_item_manager (GtkListItemManager *items,
case GTK_LIST_TILE_UNMATCHED_HEADER:
g_assert_cmpint (section_state, ==, NO_SECTION);
g_assert_cmpint (tile->n_items, ==, 0);
g_assert_false (tile->widget);
g_assert_null (tile->widget);
section_state = UNMATCHED_SECTION;
break;
@ -131,14 +128,14 @@ check_list_item_manager (GtkListItemManager *items,
g_assert_cmpint (section_state, ==, MATCHED_SECTION);
g_assert_cmpint (tile->n_items, ==, 0);
g_assert_true (has_sections);
g_assert_false (tile->widget);
g_assert_null (tile->widget);
section_state = NO_SECTION;
break;
case GTK_LIST_TILE_UNMATCHED_FOOTER:
g_assert_cmpint (section_state, ==, UNMATCHED_SECTION);
g_assert_cmpint (tile->n_items, ==, 0);
g_assert_false (tile->widget);
g_assert_null (tile->widget);
section_state = NO_SECTION;
break;
@ -160,14 +157,9 @@ check_list_item_manager (GtkListItemManager *items,
n_items += tile->n_items;
break;
case GTK_LIST_TILE_FILLER:
/* We don't add fillers */
g_assert_not_reached ();
break;
case GTK_LIST_TILE_REMOVED:
g_assert_cmpint (tile->n_items, ==, 0);
g_assert_false (tile->widget);
g_assert_null (tile->widget);
break;
default:
@ -245,7 +237,6 @@ check_list_item_manager (GtkListItemManager *items,
n_items += tile->n_items;
break;
case GTK_LIST_TILE_FILLER:
case GTK_LIST_TILE_REMOVED:
default:
g_assert_not_reached ();