diff options
Diffstat (limited to 'liblogdiag')
-rw-r--r-- | liblogdiag/ld-category.c | 32 | ||||
-rw-r--r-- | liblogdiag/ld-category.h | 7 | ||||
-rw-r--r-- | liblogdiag/ld-library.c | 10 |
3 files changed, 45 insertions, 4 deletions
diff --git a/liblogdiag/ld-category.c b/liblogdiag/ld-category.c index e7b212d..6a4cf8c 100644 --- a/liblogdiag/ld-category.c +++ b/liblogdiag/ld-category.c @@ -85,6 +85,26 @@ ld_category_class_init (LdCategoryClass *klass) "", G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_HUMAN_NAME, pspec); +/** + * LdCategory::symbols-changed: + * + * The list of symbols has changed. + */ + klass->symbols_changed_signal = g_signal_new + ("symbols-changed", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + +/** + * LdCategory::children-changed: + * + * The list of subcategory children has changed. + */ + klass->children_changed_signal = g_signal_new + ("children-changed", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_type_class_add_private (klass, sizeof (LdCategoryPrivate)); } @@ -285,6 +305,9 @@ ld_category_insert_symbol (LdCategory *self, LdSymbol *symbol, gint pos) self->priv->symbols = g_slist_insert (self->priv->symbols, symbol, pos); g_object_ref (symbol); + + g_signal_emit (self, + LD_CATEGORY_GET_CLASS (self)->symbols_changed_signal, 0); return TRUE; } @@ -307,6 +330,9 @@ ld_category_remove_symbol (LdCategory *self, LdSymbol *symbol) { self->priv->symbols = g_slist_delete_link (self->priv->symbols, link); g_object_unref (symbol); + + g_signal_emit (self, + LD_CATEGORY_GET_CLASS (self)->symbols_changed_signal, 0); } } @@ -379,6 +405,9 @@ ld_category_add_child (LdCategory *self, LdCategory *category) self->priv->subcategories = g_slist_insert_before (self->priv->subcategories, iter, category); g_object_ref (category); + + g_signal_emit (self, + LD_CATEGORY_GET_CLASS (self)->children_changed_signal, 0); return TRUE; } @@ -404,6 +433,9 @@ ld_category_remove_child (LdCategory *self, LdCategory *category) self->priv->subcategories = g_slist_delete_link (self->priv->subcategories, link); g_object_unref (category); + + g_signal_emit (self, + LD_CATEGORY_GET_CLASS (self)->children_changed_signal, 0); } } diff --git a/liblogdiag/ld-category.h b/liblogdiag/ld-category.h index 5bbb00f..6b77596 100644 --- a/liblogdiag/ld-category.h +++ b/liblogdiag/ld-category.h @@ -41,14 +41,13 @@ struct _LdCategory LdCategoryPrivate *priv; }; -/* TODO: If required sometime, categories (and maybe symbols) should implement - * a "changed" signal. This can be somewhat tricky. The library might be - * a good candidate for what they call a proxy. See GtkUIManager. - */ struct _LdCategoryClass { /*< private >*/ GObjectClass parent_class; + + guint symbols_changed_signal; + guint children_changed_signal; }; diff --git a/liblogdiag/ld-library.c b/liblogdiag/ld-library.c index 2b4c704..75e377c 100644 --- a/liblogdiag/ld-library.c +++ b/liblogdiag/ld-library.c @@ -328,6 +328,16 @@ ld_library_load (LdLibrary *self, const gchar *directory) data.changed = FALSE; foreach_dir (directory, load_category_cb, &data, NULL); + /* XXX: It might also make sense to just forward the "children-changed" + * signal of the root category but we'd have to block it here anyway, + * so that we don't unnecessarily fire events for every single change. + * + * The user code isn't supposed to make changes to / and it's its own + * problem if it keeps reloading something a hundred times in a row. + * + * That said, it'd be possible to add change grouping methods to + * LdCategory and so delay the signal emission until an `unblock'. + */ if (data.changed) g_signal_emit (self, LD_LIBRARY_GET_CLASS (self)->changed_signal, 0); |