mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
listitemmanager: Add gtk_list_tile_get_next_skip()
... 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.
This commit is contained in:
parent
88d5c9a5e1
commit
ccbe762103
@ -542,6 +542,28 @@ gtk_list_tile_get_augment (GtkListItemManager *self,
|
|||||||
return gtk_rb_tree_get_augment (self->items, tile);
|
return gtk_rb_tree_get_augment (self->items, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = gtk_rb_tree_node_get_next (tile))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = gtk_rb_tree_node_get_previous (tile))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gtk_list_tile_set_area:
|
* gtk_list_tile_set_area:
|
||||||
* @self: the list item manager
|
* @self: the list item manager
|
||||||
@ -734,16 +756,9 @@ gtk_list_item_manager_remove_items (GtkListItemManager *self,
|
|||||||
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||||
if (offset)
|
if (offset)
|
||||||
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
||||||
for (header = gtk_rb_tree_node_get_previous (tile);
|
header = gtk_list_tile_get_previous_skip (tile);
|
||||||
header->type != GTK_LIST_TILE_HEADER && header->type != GTK_LIST_TILE_UNMATCHED_HEADER;
|
if (header->type != GTK_LIST_TILE_HEADER && header->type != GTK_LIST_TILE_UNMATCHED_HEADER)
|
||||||
header = gtk_rb_tree_node_get_previous (header))
|
header = NULL;
|
||||||
{
|
|
||||||
if (header->type == GTK_LIST_TILE_ITEM)
|
|
||||||
{
|
|
||||||
header = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (n_items > 0)
|
while (n_items > 0)
|
||||||
{
|
{
|
||||||
@ -765,10 +780,6 @@ gtk_list_item_manager_remove_items (GtkListItemManager *self,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_LIST_TILE_FILLER:
|
|
||||||
case GTK_LIST_TILE_REMOVED:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GTK_LIST_TILE_ITEM:
|
case GTK_LIST_TILE_ITEM:
|
||||||
if (tile->n_items > n_items)
|
if (tile->n_items > n_items)
|
||||||
{
|
{
|
||||||
@ -783,26 +794,22 @@ gtk_list_item_manager_remove_items (GtkListItemManager *self,
|
|||||||
gtk_list_tile_set_type (tile, GTK_LIST_TILE_REMOVED);
|
gtk_list_tile_set_type (tile, GTK_LIST_TILE_REMOVED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GTK_LIST_TILE_FILLER:
|
||||||
|
case GTK_LIST_TILE_REMOVED:
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tile = gtk_rb_tree_node_get_next (tile);
|
tile = gtk_list_tile_get_next_skip (tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header)
|
if (header)
|
||||||
{
|
{
|
||||||
for (;
|
if (tile->type == GTK_LIST_TILE_FOOTER || tile->type == GTK_LIST_TILE_UNMATCHED_FOOTER)
|
||||||
tile->type != GTK_LIST_TILE_ITEM;
|
|
||||||
tile = gtk_rb_tree_node_get_next (tile))
|
|
||||||
{
|
{
|
||||||
if (tile->type == GTK_LIST_TILE_FOOTER || tile->type == GTK_LIST_TILE_UNMATCHED_FOOTER)
|
gtk_list_tile_set_type (header, GTK_LIST_TILE_REMOVED);
|
||||||
{
|
gtk_list_tile_set_type (tile, GTK_LIST_TILE_REMOVED);
|
||||||
gtk_list_tile_set_type (header, GTK_LIST_TILE_REMOVED);
|
|
||||||
gtk_list_tile_set_type (tile, GTK_LIST_TILE_REMOVED);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -859,7 +866,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
|
|||||||
|
|
||||||
if (has_sections)
|
if (has_sections)
|
||||||
{
|
{
|
||||||
GtkListTile *section = gtk_rb_tree_node_get_previous (tile);
|
GtkListTile *section = gtk_list_tile_get_previous_skip (tile);
|
||||||
|
|
||||||
if (section->type == GTK_LIST_TILE_HEADER)
|
if (section->type == GTK_LIST_TILE_HEADER)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user