Renaming, order categories by name.
So at least in English the order will make some sense. And it shall stay consistent.
This commit is contained in:
parent
0e952b084c
commit
6a633c8321
@ -199,7 +199,7 @@ reload_library (LdLibraryPane *self)
|
||||
{
|
||||
GSList *categories;
|
||||
|
||||
categories = (GSList *) ld_symbol_category_get_subcategories
|
||||
categories = (GSList *) ld_symbol_category_get_children
|
||||
(ld_library_get_root (self->priv->library));
|
||||
g_slist_foreach (categories, load_category_cb, self);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ load_category_cb (const gchar *base, const gchar *path, gpointer userdata)
|
||||
cat = load_category (data->self, path, base);
|
||||
if (cat)
|
||||
{
|
||||
ld_symbol_category_insert_subcategory (data->cat, cat, -1);
|
||||
ld_symbol_category_add_child (data->cat, cat);
|
||||
g_object_unref (cat);
|
||||
}
|
||||
}
|
||||
@ -368,7 +368,7 @@ ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
|
||||
{
|
||||
gboolean found = FALSE;
|
||||
|
||||
list = ld_symbol_category_get_subcategories (cat);
|
||||
list = ld_symbol_category_get_children (cat);
|
||||
for (list_el = list; list_el; list_el = g_slist_next (list_el))
|
||||
{
|
||||
cat = LD_SYMBOL_CATEGORY (list_el->data);
|
||||
|
@ -329,60 +329,70 @@ static void
|
||||
on_category_notify_name (LdSymbolCategory *category,
|
||||
GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
/* XXX: We could disown the category if a name collision has occured. */
|
||||
LdSymbolCategory *self;
|
||||
|
||||
self = (LdSymbolCategory *) user_data;
|
||||
g_warning ("name of a library subcategory has changed");
|
||||
|
||||
/* The easy way of handling it. */
|
||||
g_object_ref (category);
|
||||
ld_symbol_category_remove_child (self, category);
|
||||
ld_symbol_category_add_child (self, category);
|
||||
g_object_unref (category);
|
||||
}
|
||||
|
||||
/**
|
||||
* ld_symbol_category_insert_subcategory:
|
||||
* ld_symbol_category_add_child:
|
||||
* @self: an #LdSymbolCategory object.
|
||||
* @category: the category to be inserted.
|
||||
* @pos: the position at which the category will be inserted.
|
||||
* Negative values will append to the end of list.
|
||||
*
|
||||
* Insert a subcategory into the category.
|
||||
*
|
||||
* Return value: %TRUE if successful (no name collisions).
|
||||
*/
|
||||
gboolean
|
||||
ld_symbol_category_insert_subcategory (LdSymbolCategory *self,
|
||||
LdSymbolCategory *category, gint pos)
|
||||
ld_symbol_category_add_child (LdSymbolCategory *self,
|
||||
LdSymbolCategory *category)
|
||||
{
|
||||
const gchar *name;
|
||||
const GSList *iter;
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), FALSE);
|
||||
g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (category), FALSE);
|
||||
|
||||
/* Check for name collisions. */
|
||||
name = ld_symbol_category_get_name (category);
|
||||
for (iter = self->priv->subcategories; iter; iter = iter->next)
|
||||
{
|
||||
if (!strcmp (name, ld_symbol_category_get_name (iter->data)))
|
||||
gint comp;
|
||||
|
||||
comp = g_utf8_collate (name, ld_symbol_category_get_name (iter->data));
|
||||
if (!comp)
|
||||
{
|
||||
g_warning ("attempted to insert multiple `%s' subcategories into"
|
||||
" category `%s'", name, ld_symbol_category_get_name (self));
|
||||
return FALSE;
|
||||
}
|
||||
if (comp < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
g_signal_connect (category, "notify::name",
|
||||
G_CALLBACK (on_category_notify_name), self);
|
||||
self->priv->subcategories
|
||||
= g_slist_insert (self->priv->subcategories, category, pos);
|
||||
self->priv->subcategories = g_slist_insert_before
|
||||
(self->priv->subcategories, iter, category);
|
||||
g_object_ref (category);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ld_symbol_category_remove_subcategory:
|
||||
* ld_symbol_category_remove_child:
|
||||
* @self: an #LdSymbolCategory object.
|
||||
* @category: the category to be removed.
|
||||
*
|
||||
* Removes a subcategory from the category.
|
||||
*/
|
||||
void
|
||||
ld_symbol_category_remove_subcategory (LdSymbolCategory *self,
|
||||
ld_symbol_category_remove_child (LdSymbolCategory *self,
|
||||
LdSymbolCategory *category)
|
||||
{
|
||||
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
|
||||
@ -399,14 +409,14 @@ ld_symbol_category_remove_subcategory (LdSymbolCategory *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* ld_symbol_category_get_subcategories:
|
||||
* ld_symbol_category_get_children:
|
||||
* @self: an #LdSymbolCategory object.
|
||||
*
|
||||
* Return value: (element-type LdSymbolCategory *):
|
||||
* a list of subcategories. Do not modify.
|
||||
*/
|
||||
const GSList *
|
||||
ld_symbol_category_get_subcategories (LdSymbolCategory *self)
|
||||
ld_symbol_category_get_children (LdSymbolCategory *self)
|
||||
{
|
||||
g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
|
||||
return self->priv->subcategories;
|
||||
|
@ -69,11 +69,11 @@ void ld_symbol_category_remove_symbol (LdSymbolCategory *self,
|
||||
LdSymbol *symbol);
|
||||
const GSList *ld_symbol_category_get_symbols (LdSymbolCategory *self);
|
||||
|
||||
gboolean ld_symbol_category_insert_subcategory (LdSymbolCategory *self,
|
||||
LdSymbolCategory *category, gint pos);
|
||||
void ld_symbol_category_remove_subcategory (LdSymbolCategory *self,
|
||||
gboolean ld_symbol_category_add_child (LdSymbolCategory *self,
|
||||
LdSymbolCategory *category);
|
||||
const GSList *ld_symbol_category_get_subcategories (LdSymbolCategory *self);
|
||||
void ld_symbol_category_remove_child (LdSymbolCategory *self,
|
||||
LdSymbolCategory *category);
|
||||
const GSList *ld_symbol_category_get_children (LdSymbolCategory *self);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user