X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fdialog-common.c;h=c6832df4d05d4b783200f6a5e33bdd33fae463f2;hb=1effaa062b65095fbaa5c83c691deb741a79f8ee;hp=723a65e4a3bf5751b0923961db90bdf36000e989;hpb=48913a68e4a84276ae421aeb108a3782c95946f8;p=pspp-builds.git diff --git a/src/ui/gui/dialog-common.c b/src/ui/gui/dialog-common.c index 723a65e4..c6832df4 100644 --- a/src/ui/gui/dialog-common.c +++ b/src/ui/gui/dialog-common.c @@ -236,3 +236,59 @@ homogeneous_types (GtkWidget *source, GtkWidget *dest) return retval; } + + +/* Returns true iff the variable selected by SOURCE is numeric */ +gboolean +numeric_only (GtkWidget *source, GtkWidget *dest) +{ + gboolean ok; + GtkTreeIter iter; + gboolean retval = TRUE; + + GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (source)); + + PsppireDict *dict; + GtkTreeSelection *selection; + GList *list, *l; + + while (GTK_IS_TREE_MODEL_FILTER (model)) + { + model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model)); + } + + dict = PSPPIRE_DICT (model); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (source)); + + list = gtk_tree_selection_get_selected_rows (selection, &model); + + /* Iterate through the selection of the source treeview */ + for (l = list; l ; l = l->next) + { + GtkTreePath *path = l->data; + GtkTreePath *fpath; + gint *idx; + + const struct variable *v; + + fpath = gtk_tree_model_filter_convert_path_to_child_path + (GTK_TREE_MODEL_FILTER (model), path); + + idx = gtk_tree_path_get_indices (fpath); + + v = psppire_dict_get_variable (dict, idx[0]); + + if ( var_is_alpha (v)) + { + retval = FALSE; + break; + } + } + + g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); + g_list_free (list); + + return retval; +} +