aboutsummaryrefslogtreecommitdiff
path: root/liblogdiag
diff options
context:
space:
mode:
Diffstat (limited to 'liblogdiag')
-rw-r--r--liblogdiag/ld-library-pane.c2
-rw-r--r--liblogdiag/ld-library.c4
-rw-r--r--liblogdiag/ld-symbol-category.c40
-rw-r--r--liblogdiag/ld-symbol-category.h8
4 files changed, 32 insertions, 22 deletions
diff --git a/liblogdiag/ld-library-pane.c b/liblogdiag/ld-library-pane.c
index 57f01c0..5fe85c1 100644
--- a/liblogdiag/ld-library-pane.c
+++ b/liblogdiag/ld-library-pane.c
@@ -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);
}
diff --git a/liblogdiag/ld-library.c b/liblogdiag/ld-library.c
index f68a55e..31f3855 100644
--- a/liblogdiag/ld-library.c
+++ b/liblogdiag/ld-library.c
@@ -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);
diff --git a/liblogdiag/ld-symbol-category.c b/liblogdiag/ld-symbol-category.c
index 0e2a220..f5f5b75 100644
--- a/liblogdiag/ld-symbol-category.c
+++ b/liblogdiag/ld-symbol-category.c
@@ -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;
diff --git a/liblogdiag/ld-symbol-category.h b/liblogdiag/ld-symbol-category.h
index 2102db0..1ac7f59 100644
--- a/liblogdiag/ld-symbol-category.h
+++ b/liblogdiag/ld-symbol-category.h
@@ -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