From 83df73bacd2cd3abd177e6a8ac1b76b072255025 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 7 Jul 2009 12:52:45 +0800 Subject: [PATCH] Fix bug in value labels dialog box --- src/ui/gui/helper.c | 4 ++-- src/ui/gui/helper.h | 6 +++--- src/ui/gui/missing-val-dialog.h | 2 +- src/ui/gui/psppire-var-sheet.c | 5 +++-- src/ui/gui/val-labs-dialog.c | 10 +++++----- src/ui/gui/val-labs-dialog.h | 6 +++--- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 31633de9..b4b3872d 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -49,11 +49,11 @@ /* Formats a value according to FORMAT The returned string must be freed when no longer required */ gchar * -value_to_text (union value v, const struct dictionary *dict, struct fmt_spec format) +value_to_text (union value v, PsppireDict *dict, struct fmt_spec format) { gchar *s = 0; - s = data_out (&v, dict_get_encoding (dict), &format); + s = data_out (&v, dict_get_encoding (dict->dict), &format); g_strchug (s); return s; diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h index 0cd1f555..6706df20 100644 --- a/src/ui/gui/helper.h +++ b/src/ui/gui/helper.h @@ -25,16 +25,16 @@ #include - +#include "psppire-dict.h" void paste_syntax_in_new_window (const gchar *syntax); struct fmt_spec; -struct dictionary; + /* Formats a value according to FORMAT The returned string must be freed when no longer required */ -gchar * value_to_text (union value v, const struct dictionary *dict, struct fmt_spec format); +gchar * value_to_text (union value v, PsppireDict *dict, struct fmt_spec format); gboolean text_to_value (const gchar *text, union value *v, diff --git a/src/ui/gui/missing-val-dialog.h b/src/ui/gui/missing-val-dialog.h index bbf36f26..82acf975 100644 --- a/src/ui/gui/missing-val-dialog.h +++ b/src/ui/gui/missing-val-dialog.h @@ -33,7 +33,7 @@ struct missing_val_dialog struct variable *pv; /* The dictionary to which that value belongs */ - const struct dictionary *dict; + PsppireDict *dict; /* local copy */ struct missing_values mvl; diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index c0d0059b..dfd62bb6 100644 --- a/src/ui/gui/psppire-var-sheet.c +++ b/src/ui/gui/psppire-var-sheet.c @@ -384,7 +384,7 @@ var_sheet_change_active_cell (PsppireVarSheet *vs, vs->missing_val_dialog->pv = psppire_var_store_get_var (var_store, row); - vs->missing_val_dialog->dict = var_store->dict->dict; + vs->missing_val_dialog->dict = var_store->dict; g_signal_connect_swapped (customEntry, "clicked", @@ -481,7 +481,8 @@ psppire_var_sheet_realize (GtkWidget *w) GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (vs)); vs->val_labs_dialog = val_labs_dialog_create (GTK_WINDOW (toplevel), - PSPPIRE_SHEET (vs)); + PSPPIRE_VAR_STORE (psppire_sheet_get_model (PSPPIRE_SHEET (vs)))); + vs->missing_val_dialog = missing_val_dialog_create (GTK_WINDOW (toplevel)); vs->var_type_dialog = var_type_dialog_create (GTK_WINDOW (toplevel)); diff --git a/src/ui/gui/val-labs-dialog.c b/src/ui/gui/val-labs-dialog.c index 04f9534d..92a7fe8e 100644 --- a/src/ui/gui/val-labs-dialog.c +++ b/src/ui/gui/val-labs-dialog.c @@ -34,7 +34,7 @@ struct val_labs_dialog { GtkWidget *window; - PsppireSheet *vs; + PsppireVarStore *var_store; /* The variable to be updated */ struct variable *pv; @@ -345,7 +345,7 @@ on_select_row (GtkTreeView *treeview, gpointer data) gchar *text; get_selected_tuple (dialog, &value, &label); - text = value_to_text (value, NULL, *var_get_write_format (dialog->pv)); + text = value_to_text (value, dialog->var_store->dict, *var_get_write_format (dialog->pv)); g_signal_handler_block (GTK_ENTRY (dialog->value_entry), dialog->value_handler_id); @@ -374,7 +374,7 @@ on_select_row (GtkTreeView *treeview, gpointer data) /* Create a new dialog box (there should normally be only one)*/ struct val_labs_dialog * -val_labs_dialog_create (GtkWindow *toplevel, PsppireSheet *sheet) +val_labs_dialog_create (GtkWindow *toplevel, PsppireVarStore *var_store) { GtkTreeViewColumn *column; @@ -384,10 +384,10 @@ val_labs_dialog_create (GtkWindow *toplevel, PsppireSheet *sheet) struct val_labs_dialog *dialog = g_malloc (sizeof (*dialog)); + dialog->var_store = var_store; dialog->window = get_widget_assert (xml,"val_labs_dialog"); dialog->value_entry = get_widget_assert (xml,"value_entry"); dialog->label_entry = get_widget_assert (xml,"label_entry"); - dialog->vs = sheet; gtk_window_set_transient_for (GTK_WINDOW (dialog->window), toplevel); @@ -497,7 +497,7 @@ repopulate_dialog (struct val_labs_dialog *dialog) const struct val_lab *vl = labels[i]; gchar *const vstr = - value_to_text (vl->value, NULL, + value_to_text (vl->value, dialog->var_store->dict, *var_get_write_format (dialog->pv)); gchar *const text = g_strdup_printf ("%s = \"%s\"", diff --git a/src/ui/gui/val-labs-dialog.h b/src/ui/gui/val-labs-dialog.h index 3a09f1ca..745e0a0a 100644 --- a/src/ui/gui/val-labs-dialog.h +++ b/src/ui/gui/val-labs-dialog.h @@ -24,13 +24,13 @@ #include #include -#include - +//#include +#include "psppire-var-store.h" struct val_labs; -struct val_labs_dialog * val_labs_dialog_create (GtkWindow *, PsppireSheet *); +struct val_labs_dialog * val_labs_dialog_create (GtkWindow *, PsppireVarStore *); void val_labs_dialog_show (struct val_labs_dialog *); -- 2.30.2