Commit bed3c858 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added new function gimp_list_sort().

2003-03-27  Sven Neumann  <sven@gimp.org>

	* app/core/gimplist.[ch]: added new function gimp_list_sort().

	* app/text/gimpfontlist.c (gimp_font_list_restore): sort the list
	after all fonts have been added instead of keeping the list in
	order while inserting
parent ad6a8983
2003-03-27 Sven Neumann <sven@gimp.org>
* app/core/gimplist.[ch]: added new function gimp_list_sort().
* app/text/gimpfontlist.c (gimp_font_list_restore): sort the list
after all fonts have been added instead of keeping the list in
order while inserting
2003-03-27 Michael Natterer <mitch@gimp.org>
Someone produces icons faster than I can commit...
......@@ -305,3 +305,20 @@ gimp_list_reverse (GimpList *list)
gimp_container_thaw (GIMP_CONTAINER (list));
}
}
void
gimp_list_sort (GimpList *list,
GCompareFunc compare_func)
{
g_return_if_fail (GIMP_IS_LIST (list));
g_return_if_fail (compare_func != NULL);
if (GIMP_CONTAINER (list)->num_children > 1)
{
gimp_container_freeze (GIMP_CONTAINER (list));
list->list = g_list_sort (list->list, compare_func);
gimp_container_thaw (GIMP_CONTAINER (list));
}
}
......@@ -54,6 +54,8 @@ GType gimp_list_get_type (void) G_GNUC_CONST;
GimpContainer * gimp_list_new (GType children_type,
GimpContainerPolicy policy);
void gimp_list_reverse (GimpList *list);
void gimp_list_sort (GimpList *list,
GCompareFunc compare_func);
#endif /* __GIMP_LIST_H__ */
......@@ -38,8 +38,6 @@
static void gimp_font_list_class_init (GimpFontListClass *klass);
static void gimp_font_list_init (GimpFontList *list);
static void gimp_font_list_add (GimpContainer *container,
GimpObject *object);
static gint gimp_font_list_font_compare_func (gconstpointer first,
gconstpointer second);
......@@ -78,13 +76,7 @@ gimp_font_list_get_type (void)
static void
gimp_font_list_class_init (GimpFontListClass *klass)
{
GimpContainerClass *container_class;
container_class = GIMP_CONTAINER_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
container_class->add = gimp_font_list_add;
}
static void
......@@ -92,18 +84,6 @@ gimp_font_list_init (GimpFontList *list)
{
}
static void
gimp_font_list_add (GimpContainer *container,
GimpObject *object)
{
GimpList *list;
list = GIMP_LIST (container);
list->list = g_list_insert_sorted (list->list, object,
gimp_font_list_font_compare_func);
}
GimpContainer *
gimp_font_list_new (gdouble xresolution,
gdouble yresolution)
......@@ -142,6 +122,8 @@ gimp_font_list_restore (GimpFontList *list)
g_return_if_fail (GIMP_IS_FONT_LIST (list));
gimp_container_freeze (GIMP_CONTAINER (list));
pango_context = g_object_get_data (G_OBJECT (list), "pango-context");
pango_context_list_families (pango_context, &families, &n_families);
......@@ -172,6 +154,10 @@ gimp_font_list_restore (GimpFontList *list)
}
g_free (families);
gimp_list_sort (GIMP_LIST (list), gimp_font_list_font_compare_func);
gimp_container_thaw (GIMP_CONTAINER (list));
}
static gint
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment