From: John Darrington Date: Sat, 22 Jun 2013 06:14:12 +0000 (+0200) Subject: Added the WHAT and OLDVAR parameters to the var_changed dictionary callback X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9daf6d834acd26a9f3e47906773ea57777bf5399;p=pspp Added the WHAT and OLDVAR parameters to the var_changed dictionary callback Propagate the newly implemented WHAT and OLDVAR parameters in the PsppireDict class. --- diff --git a/src/data/dictionary.c b/src/data/dictionary.c index c8f9da5ef4..ff0587553f 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -547,6 +547,7 @@ static void reindex_var (struct dictionary *d, struct vardict_info *vardict) { struct variable *var = vardict->var; + struct variable *old = var_clone (var); var_set_vardict (var, vardict); hmap_insert_fast (&d->name_map, &vardict->name_node, @@ -554,7 +555,8 @@ reindex_var (struct dictionary *d, struct vardict_info *vardict) if ( d->changed ) d->changed (d, d->changed_data); if ( d->callbacks && d->callbacks->var_changed ) - d->callbacks->var_changed (d, var_get_dict_index (var), d->cb_data); + d->callbacks->var_changed (d, var_get_dict_index (var), VAR_TRAIT_POSITION, old, d->cb_data); + var_destroy (old); } /* Sets the case_index in V's vardict to CASE_INDEX. */ @@ -757,6 +759,7 @@ void dict_rename_var (struct dictionary *d, struct variable *v, const char *new_name) { + struct variable *old = var_clone (v); assert (!utf8_strcasecmp (var_get_name (v), new_name) || dict_lookup_var (d, new_name) == NULL); @@ -769,7 +772,9 @@ dict_rename_var (struct dictionary *d, struct variable *v, if ( d->changed ) d->changed (d, d->changed_data); if ( d->callbacks && d->callbacks->var_changed ) - d->callbacks->var_changed (d, var_get_dict_index (v), d->cb_data); + d->callbacks->var_changed (d, var_get_dict_index (v), VAR_TRAIT_NAME, old, d->cb_data); + + var_destroy (old); } /* Renames COUNT variables specified in VARS to the names given @@ -1596,7 +1601,7 @@ dict_has_attributes (const struct dictionary *d) prior to the change. OLDVAR is destroyed by this function. */ void -dict_var_changed (const struct variable *v, unsigned int what UNUSED, struct variable *oldvar) +dict_var_changed (const struct variable *v, unsigned int what, struct variable *oldvar) { if ( var_has_vardict (v)) { @@ -1608,7 +1613,7 @@ dict_var_changed (const struct variable *v, unsigned int what UNUSED, struct var if (d->changed ) d->changed (d, d->changed_data); if ( d->callbacks && d->callbacks->var_changed ) - d->callbacks->var_changed (d, var_get_dict_index (v), d->cb_data); + d->callbacks->var_changed (d, var_get_dict_index (v), what, oldvar, d->cb_data); } var_destroy (oldvar); } diff --git a/src/data/dictionary.h b/src/data/dictionary.h index c725d5a5a6..fdc28611f6 100644 --- a/src/data/dictionary.h +++ b/src/data/dictionary.h @@ -181,7 +181,7 @@ struct dict_callbacks void (*var_added) (struct dictionary *, int, void *); void (*var_deleted) (struct dictionary *, const struct variable *, int dict_index, int case_index, void *); - void (*var_changed) (struct dictionary *, int, void *); + void (*var_changed) (struct dictionary *, int, unsigned int, const struct variable *, void *); void (*var_resized) (struct dictionary *, int, int, void *); void (*weight_changed) (struct dictionary *, int, void *); void (*filter_changed) (struct dictionary *, int, void *); diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index e6291b69c4..97115b0474 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -256,7 +256,7 @@ delcb (struct dictionary *d, const struct variable *var, } static void -mutcb (struct dictionary *d, int idx, void *pd) +mutcb (struct dictionary *d, int idx, unsigned int what, const struct variable *oldvar, void *pd) { g_signal_emit (pd, signals [VARIABLE_CHANGED], 0, idx); }