From: John Darrington Date: Sun, 13 Dec 2009 14:50:09 +0000 (+0100) Subject: New function psppire_var_view_contains_var X-Git-Tag: sid-i386-build122~9 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4e361fed54bb9a1cb3259722038976dadd938f6;p=pspp-builds.git New function psppire_var_view_contains_var Added a function to test whether a variable is currently contained within a PsppireVarView widget. --- diff --git a/src/ui/gui/psppire-var-view.c b/src/ui/gui/psppire-var-view.c index 97a5aec1..2a9ebf2e 100644 --- a/src/ui/gui/psppire-var-view.c +++ b/src/ui/gui/psppire-var-view.c @@ -201,7 +201,6 @@ psppire_var_view_class_init (PsppireVarViewClass *class) g_object_class_install_property (object_class, PROP_N_COLS, n_cols_spec); - } @@ -292,4 +291,26 @@ psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string) return n_vars; } +/* Returns TRUE iff VV contains the item V. + V must be an initialised value containing a + PSPPIRE_VAR_PTR_TYPE. +*/ +gboolean +psppire_var_view_contains_var (PsppireVarView *vv, const GValue *v) +{ + gboolean ok; + GtkTreeIter iter; + g_return_val_if_fail (G_VALUE_HOLDS (v, PSPPIRE_VAR_PTR_TYPE), FALSE); + + for (ok = psppire_var_view_get_iter_first (vv, &iter); + ok; + ok = psppire_var_view_get_iter_next (vv, &iter)) + { + const struct variable *var = psppire_var_view_get_variable (vv, 0, &iter); + if (var == g_value_get_boxed (v)) + return TRUE; + } + + return FALSE; +} diff --git a/src/ui/gui/psppire-var-view.h b/src/ui/gui/psppire-var-view.h index f2696072..3509a46b 100644 --- a/src/ui/gui/psppire-var-view.h +++ b/src/ui/gui/psppire-var-view.h @@ -58,9 +58,14 @@ struct _PsppireVarViewClass GType psppire_var_view_get_type (void); +gboolean psppire_var_view_contains_var (PsppireVarView *vv, const GValue *v); + gint psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string); + gboolean psppire_var_view_get_iter_first (PsppireVarView *vv, GtkTreeIter *iter); + gboolean psppire_var_view_get_iter_next (PsppireVarView *vv, GtkTreeIter *iter); + const struct variable * psppire_var_view_get_variable (PsppireVarView *vv, gint column, GtkTreeIter *iter);