From 80da4cc56954f97ed026888c96f041f42c7ec7db Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Mon, 28 Sep 2009 17:10:41 +0200 Subject: [PATCH] [AdgModel] Added "clear" signal Implemented base signal to clear any eventual model cache retained by the subject instance. It works in a similar way of the "invalidate" signal in AdgEntity. --- adg/adg-model.c | 37 +++++++++++++++++++++++++++++++++++-- adg/adg-model.h | 2 ++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/adg/adg-model.c b/adg/adg-model.c index d05a28a7..e191d309 100644 --- a/adg/adg-model.c +++ b/adg/adg-model.c @@ -56,6 +56,7 @@ enum { enum { ADD_DEPENDENCY, REMOVE_DEPENDENCY, + CLEAR, CHANGED, LAST_SIGNAL }; @@ -96,6 +97,7 @@ adg_model_class_init(AdgModelClass *klass) klass->get_dependencies = get_dependencies; klass->add_dependency = add_dependency; klass->remove_dependency = remove_dependency; + klass->clear = NULL; klass->changed = changed; param = g_param_spec_object("dependency", @@ -137,11 +139,24 @@ adg_model_class_init(AdgModelClass *klass) G_TYPE_NONE, 1, ADG_TYPE_ENTITY); /** + * AdgModel::clear: + * @model: an #AdgModel + * + * Removes any cached information from @model. + **/ + signals[CLEAR] = g_signal_new("clear", ADG_TYPE_MODEL, + G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET(AdgModelClass, clear), + NULL, NULL, + adg_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /** * AdgModel::changed: * @model: an #AdgModel * - * Notificates that the model has changed. By default, the model - * cache is invalidated. + * Notificates that the model has changed. By default, all the + * dependent entities are invalidated. **/ signals[CHANGED] = g_signal_new("changed", ADG_TYPE_MODEL, G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE, @@ -295,6 +310,24 @@ adg_model_foreach_dependency(AdgModel *model, GCallback callback, } /** + * adg_model_clear: + * @model: an #AdgModel + * + * + * This function is only useful in entity implementations. + * + * + * Emits the #AdgModel::clear signal on @model. + **/ +void +adg_model_clear(AdgModel *model) +{ + g_return_if_fail(ADG_IS_MODEL(model)); + + g_signal_emit(model, signals[CLEAR], 0); +} + +/** * adg_model_changed: * @model: an #AdgModel * diff --git a/adg/adg-model.h b/adg/adg-model.h index 55f8defd..3a276c97 100644 --- a/adg/adg-model.h +++ b/adg/adg-model.h @@ -51,6 +51,7 @@ struct _AdgModelClass { AdgEntity *entity); void (*remove_dependency) (AdgModel *model, AdgEntity *entity); + void (*clear) (AdgModel *model); void (*changed) (AdgModel *model); }; @@ -66,6 +67,7 @@ void adg_model_foreach_dependency (AdgModel *model, GCallback callback, gpointer user_data); +void adg_model_clear (AdgModel *model); void adg_model_changed (AdgModel *model); G_END_DECLS -- 2.11.4.GIT