mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
Merge branch 'wip/antoniof/fix-section-tiles' into 'main'
gtklistitemmanager fixes See merge request GNOME/gtk!6805
This commit is contained in:
commit
a7c98227e6
@ -117,7 +117,6 @@ gtk_list_item_change_release (GtkListItemChange *change,
|
||||
if (!g_hash_table_replace (change->deleted_items, gtk_list_item_base_get_item (GTK_LIST_ITEM_BASE (widget)), widget))
|
||||
{
|
||||
g_warning ("Duplicate item detected in list. Picking one randomly.");
|
||||
gtk_list_item_change_recycle (change, widget);
|
||||
}
|
||||
}
|
||||
|
||||
@ -968,10 +967,26 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
|
||||
|
||||
if (section != NULL && section->type == GTK_LIST_TILE_HEADER)
|
||||
{
|
||||
guint start, end;
|
||||
GtkListTile *footer = gtk_list_tile_get_footer (self, section);
|
||||
GtkListTile *previous_footer = gtk_list_tile_get_previous_skip (section);
|
||||
|
||||
gtk_section_model_get_section (GTK_SECTION_MODEL (self->model), position, &start, &end);
|
||||
|
||||
if (previous_footer != NULL && previous_footer->type == GTK_LIST_TILE_FOOTER &&
|
||||
position > start && position < end)
|
||||
{
|
||||
gtk_list_item_change_clear_header (change, §ion->widget);
|
||||
gtk_list_tile_set_type (section, GTK_LIST_TILE_REMOVED);
|
||||
gtk_list_tile_set_type (previous_footer, GTK_LIST_TILE_REMOVED);
|
||||
|
||||
section = gtk_list_tile_get_header (self, previous_footer);
|
||||
}
|
||||
|
||||
gtk_list_item_change_clear_header (change, §ion->widget);
|
||||
gtk_list_tile_set_type (section,
|
||||
GTK_LIST_TILE_UNMATCHED_HEADER);
|
||||
gtk_list_tile_set_type (gtk_list_tile_get_footer (self, section),
|
||||
gtk_list_tile_set_type (footer,
|
||||
GTK_LIST_TILE_UNMATCHED_FOOTER);
|
||||
}
|
||||
}
|
||||
@ -1610,7 +1625,7 @@ gtk_list_item_manager_model_sections_changed_cb (GListModel *model,
|
||||
gtk_list_item_change_clear_header (&change, &header->widget);
|
||||
gtk_list_tile_set_type (header, GTK_LIST_TILE_UNMATCHED_HEADER);
|
||||
|
||||
n_items -= MIN (n_items, position - offset);
|
||||
n_items += offset;
|
||||
while (n_items > 0)
|
||||
{
|
||||
switch (tile->type)
|
||||
|
@ -433,7 +433,7 @@ test_exhaustive (void)
|
||||
gboolean add = FALSE, remove = FALSE;
|
||||
guint position, n_items;
|
||||
|
||||
switch (g_test_rand_int_range (0, 6))
|
||||
switch (g_test_rand_int_range (0, 7))
|
||||
{
|
||||
case 0:
|
||||
if (g_test_verbose ())
|
||||
@ -483,6 +483,34 @@ test_exhaustive (void)
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
{
|
||||
n_items = g_list_model_get_n_items (G_LIST_MODEL (store));
|
||||
if (n_items > 0)
|
||||
{
|
||||
guint j = g_test_rand_int_range (0, n_items);
|
||||
GListModel *source = g_list_model_get_item (G_LIST_MODEL (store), j);
|
||||
guint source_size = g_list_model_get_n_items (G_LIST_MODEL (source));
|
||||
GStrvBuilder *builder = g_strv_builder_new ();
|
||||
guint inclusion_size = g_test_rand_int_range (1, 11);
|
||||
char **inclusion;
|
||||
|
||||
for (j = 0; j < inclusion_size; j++)
|
||||
g_strv_builder_add (builder, g_test_rand_bit () ? "A" : "B");
|
||||
inclusion = g_strv_builder_end (builder);
|
||||
g_strv_builder_unref (builder);
|
||||
|
||||
j = g_test_rand_int_range (0, source_size + 1);
|
||||
gtk_string_list_splice (GTK_STRING_LIST (source), j, 0, (const char * const *) inclusion);
|
||||
g_strfreev (inclusion);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_test_message ("Adding %u items at position %u of a section which had %u items",
|
||||
inclusion_size, j, source_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user