From 20e4e92e290b33bf7ce168feaf1fc946424e4736 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 19 Apr 2017 12:06:39 +0200 Subject: [PATCH] Enable changing of missing values from the variable sheet --- src/ui/gui/psppire-data-editor.c | 33 +++++++++++++++++++++++++++++++- src/ui/gui/psppire-data-editor.h | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 1d804ef05b..c480fd223b 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -128,6 +128,29 @@ var_sheet_data_to_string (GtkTreeModel *m, gint col, gint row, const GValue *in) return jmd_sheet_default_forward_conversion (m, col, row, in); } +static void +set_missing_values (GtkCellRenderer *renderer, + GtkCellEditable *editable, + gchar *path, + gpointer user_data) +{ + PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (user_data); + gint row = -1, col = -1; + jmd_sheet_get_active_cell (JMD_SHEET (de->var_sheet), &col, &row); + + struct variable *var = + psppire_dict_get_variable (PSPPIRE_DICT (de->dict), row); + + struct missing_values mv; + if (GTK_RESPONSE_OK == psppire_missing_val_dialog_run (NULL, + var, &mv)) + { + var_set_missing_values (var, &mv); + } + + mv_destroy (&mv); +} + static void set_value_labels (GtkCellRenderer *renderer, GtkCellEditable *editable, @@ -136,7 +159,7 @@ set_value_labels (GtkCellRenderer *renderer, { PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (user_data); gint row = -1, col = -1; - sscanf (path, "r%dc%d", &row, &col); + jmd_sheet_get_active_cell (JMD_SHEET (de->var_sheet), &col, &row); struct variable *var = psppire_dict_get_variable (PSPPIRE_DICT (de->dict), row); @@ -181,6 +204,9 @@ select_renderer_func (gint col, gint row, GType type, PsppireDataEditor *de) case DICT_TVM_COL_VALUE_LABELS: return de->value_label_renderer; + case DICT_TVM_COL_MISSING_VALUES: + return de->missing_values_renderer; + case DICT_TVM_COL_ALIGNMENT: return alignment_renderer; @@ -1078,6 +1104,11 @@ psppire_data_editor_init (PsppireDataEditor *de) g_signal_connect (de->value_label_renderer, "editing-started", G_CALLBACK (set_value_labels), de); + + de->missing_values_renderer = gtk_cell_renderer_text_new (); + g_signal_connect (de->missing_values_renderer, + "editing-started", G_CALLBACK (set_missing_values), + de); } GtkWidget* diff --git a/src/ui/gui/psppire-data-editor.h b/src/ui/gui/psppire-data-editor.h index e2db89f51a..dfea654085 100644 --- a/src/ui/gui/psppire-data-editor.h +++ b/src/ui/gui/psppire-data-editor.h @@ -84,6 +84,7 @@ struct _PsppireDataEditor gboolean split; /* True if the sheets are in split view. */ GtkCellRenderer *value_label_renderer; + GtkCellRenderer *missing_values_renderer; }; struct _PsppireDataEditorClass -- 2.30.2