Make g_emblemed_icon_add_emblem() keep the list sorted

Fixes bug #628317.
This commit is contained in:
Christian Persch 2010-08-30 16:12:42 +02:00
parent 7a6f8bd3c3
commit 9493925854

View File

@ -159,6 +159,21 @@ g_emblemed_icon_get_emblems (GEmblemedIcon *emblemed)
return emblemed->emblems;
}
static gint
g_emblem_comp (GEmblem *a,
GEmblem *b)
{
guint hash_a = g_icon_hash (G_ICON (a));
guint hash_b = g_icon_hash (G_ICON (b));
if(hash_a < hash_b)
return -1;
if(hash_a == hash_b)
return 0;
return 1;
}
/**
* g_emblemed_icon_add_emblem:
@ -177,7 +192,8 @@ g_emblemed_icon_add_emblem (GEmblemedIcon *emblemed,
g_return_if_fail (G_IS_EMBLEM (emblem));
g_object_ref (emblem);
emblemed->emblems = g_list_append (emblemed->emblems, emblem);
emblemed->emblems = g_list_insert_sorted (emblemed->emblems, emblem,
(GCompareFunc) g_emblem_comp);
}
static guint
@ -193,22 +209,6 @@ g_emblemed_icon_hash (GIcon *icon)
return hash;
}
static gint
g_emblem_comp (GEmblem *a,
GEmblem *b)
{
guint hash_a = g_icon_hash (G_ICON (a));
guint hash_b = g_icon_hash (G_ICON (b));
if(hash_a < hash_b)
return -1;
if(hash_a == hash_b)
return 0;
return 1;
}
static gboolean
g_emblemed_icon_equal (GIcon *icon1,
GIcon *icon2)
@ -223,9 +223,6 @@ g_emblemed_icon_equal (GIcon *icon1,
list1 = emblemed1->emblems;
list2 = emblemed2->emblems;
list1 = g_list_sort (list1, (GCompareFunc) g_emblem_comp);
list2 = g_list_sort (list2, (GCompareFunc) g_emblem_comp);
while (list1 && list2)
{
if (!g_icon_equal (G_ICON (list1->data), G_ICON (list2->data)))