projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gui: Fix temporary filtering by a variable's value.
[pspp]
/
src
/
ui
/
gui
/
missing-val-dialog.c
diff --git
a/src/ui/gui/missing-val-dialog.c
b/src/ui/gui/missing-val-dialog.c
index 3a350735b99f17bf207bc0b5c7221f107a1c57af..7e04b8548e02fb6cd02602645e2b8fbd99287b59 100644
(file)
--- a/
src/ui/gui/missing-val-dialog.c
+++ b/
src/ui/gui/missing-val-dialog.c
@@
-1,5
+1,5
@@
/* PSPPIRE - a graphical user interface for PSPP.
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2005, 2006 Free Software Foundation
+ Copyright (C) 2005, 2006
, 2009
Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-24,6
+24,7
@@
#include "helper.h"
#include "helper.h"
+#include <data/format.h>
#include "missing-val-dialog.h"
#include <data/missing-values.h>
#include <data/variable.h>
#include "missing-val-dialog.h"
#include <data/missing-values.h>
#include <data/variable.h>
@@
-31,7
+32,6
@@
#include <gtk/gtk.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
#include <string.h>
#include <string.h>
@@
-80,8
+80,6
@@
missing_val_dialog_accept (GtkWidget *w, gpointer data)
{
struct missing_val_dialog *dialog = data;
{
struct missing_val_dialog *dialog = data;
- const struct fmt_spec *write_spec = var_get_write_format (dialog->pv);
-
if ( gtk_toggle_button_get_active (dialog->button_discrete))
{
gint nvals = 0;
if ( gtk_toggle_button_get_active (dialog->button_discrete))
{
gint nvals = 0;
@@
-100,7
+98,7
@@
missing_val_dialog_accept (GtkWidget *w, gpointer data)
continue;
}
continue;
}
- if ( text_to_value (text,
&v, *write_spec
))
+ if ( text_to_value (text,
dialog->dict, dialog->pv, &v
))
{
nvals++;
mv_add_value (&dialog->mvl, &v);
{
nvals++;
mv_add_value (&dialog->mvl, &v);
@@
-108,6
+106,7
@@
missing_val_dialog_accept (GtkWidget *w, gpointer data)
else
badvals++;
g_free (text);
else
badvals++;
g_free (text);
+ value_destroy (&v, var_get_width (dialog->pv));
}
if ( nvals == 0 || badvals > 0 )
{
}
if ( nvals == 0 || badvals > 0 )
{
@@
-126,14
+125,16
@@
missing_val_dialog_accept (GtkWidget *w, gpointer data)
const gchar *low_text = gtk_entry_get_text (GTK_ENTRY (dialog->low));
const gchar *high_text = gtk_entry_get_text (GTK_ENTRY (dialog->high));
const gchar *low_text = gtk_entry_get_text (GTK_ENTRY (dialog->low));
const gchar *high_text = gtk_entry_get_text (GTK_ENTRY (dialog->high));
- if ( text_to_value (low_text,
&low_val, *write_spec
)
+ if ( text_to_value (low_text,
dialog->dict, dialog->pv, &low_val
)
&&
&&
- text_to_value (high_text,
&high_val, *write_spec)
)
+ text_to_value (high_text,
dialog->dict, dialog->pv, &high_val)
)
{
if ( low_val.f > high_val.f )
{
err_dialog (_("Incorrect range specification"),
GTK_WINDOW (dialog->window));
{
if ( low_val.f > high_val.f )
{
err_dialog (_("Incorrect range specification"),
GTK_WINDOW (dialog->window));
+ value_destroy (&low_val, var_get_width (dialog->pv));
+ value_destroy (&high_val, var_get_width (dialog->pv));
return ;
}
}
return ;
}
}
@@
-141,6
+142,8
@@
missing_val_dialog_accept (GtkWidget *w, gpointer data)
{
err_dialog (_("Incorrect range specification"),
GTK_WINDOW (dialog->window));
{
err_dialog (_("Incorrect range specification"),
GTK_WINDOW (dialog->window));
+ value_destroy (&low_val, var_get_width (dialog->pv));
+ value_destroy (&high_val, var_get_width (dialog->pv));
return;
}
return;
}
@@
-148,20
+151,27
@@
missing_val_dialog_accept (GtkWidget *w, gpointer data)
g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->discrete)));
mv_clear (&dialog->mvl);
g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->discrete)));
mv_clear (&dialog->mvl);
- mv_add_num_range (&dialog->mvl, low_val.f, high_val.f);
+ mv_add_range (&dialog->mvl, low_val.f, high_val.f);
+
+ value_destroy (&low_val, var_get_width (dialog->pv));
+ value_destroy (&high_val, var_get_width (dialog->pv));
if ( discrete_text && strlen (g_strstrip (discrete_text)) > 0 )
{
union value discrete_val;
if ( discrete_text && strlen (g_strstrip (discrete_text)) > 0 )
{
union value discrete_val;
- if ( !text_to_value (discrete_text, &discrete_val,
- *write_spec))
+ if ( !text_to_value (discrete_text,
+ dialog->dict,
+ dialog->pv,
+ &discrete_val))
{
err_dialog (_("Incorrect value for variable type"),
GTK_WINDOW (dialog->window) );
g_free (discrete_text);
{
err_dialog (_("Incorrect value for variable type"),
GTK_WINDOW (dialog->window) );
g_free (discrete_text);
+ value_destroy (&discrete_val, var_get_width (dialog->pv));
return;
}
mv_add_value (&dialog->mvl, &discrete_val);
return;
}
mv_add_value (&dialog->mvl, &discrete_val);
+ value_destroy (&discrete_val, var_get_width (dialog->pv));
}
g_free (discrete_text);
}
}
g_free (discrete_text);
}
@@
-218,20
+228,18
@@
on_delete (GtkWidget *w, GdkEvent *e, gpointer data)
}
}
-/* Creates the dialog structure
from the xml
*/
+/* Creates the dialog structure */
struct missing_val_dialog *
struct missing_val_dialog *
-missing_val_dialog_create (G
ladeXML *xm
l)
+missing_val_dialog_create (G
tkWindow *topleve
l)
{
{
-
struct missing_val_dialog *dialog = g_malloc (sizeof (*dialog)
);
+
GtkBuilder *xml = builder_new ("var-sheet-dialogs.ui"
);
-
connect_help (xml
);
+
struct missing_val_dialog *dialog = g_malloc (sizeof (*dialog)
);
dialog->window = get_widget_assert (xml, "missing_values_dialog");
gtk_window_set_transient_for
dialog->window = get_widget_assert (xml, "missing_values_dialog");
gtk_window_set_transient_for
- (GTK_WINDOW (dialog->window),
- GTK_WINDOW (get_widget_assert (xml, "data_editor")));
-
+ (GTK_WINDOW (dialog->window), toplevel);
g_signal_connect_swapped (get_widget_assert (xml, "missing_val_cancel"),
"clicked", G_CALLBACK (gtk_widget_hide), dialog->window);
g_signal_connect_swapped (get_widget_assert (xml, "missing_val_cancel"),
"clicked", G_CALLBACK (gtk_widget_hide), dialog->window);
@@
-239,7
+247,7
@@
missing_val_dialog_create (GladeXML *xml)
g_signal_connect (get_widget_assert (xml, "missing_val_ok"),
"clicked", G_CALLBACK (missing_val_dialog_accept), dialog);
g_signal_connect (get_widget_assert (xml, "missing_val_ok"),
"clicked", G_CALLBACK (missing_val_dialog_accept), dialog);
- g_signal_connect (
GTK_OBJECT (dialog->window)
, "delete-event",
+ g_signal_connect (
dialog->window
, "delete-event",
G_CALLBACK (on_delete), dialog);
dialog->mv[0] = get_widget_assert (xml, "mv0");
G_CALLBACK (on_delete), dialog);
dialog->mv[0] = get_widget_assert (xml, "mv0");
@@
-261,12
+269,14
@@
missing_val_dialog_create (GladeXML *xml)
GTK_TOGGLE_BUTTON (get_widget_assert (xml, "range_missing"));
GTK_TOGGLE_BUTTON (get_widget_assert (xml, "range_missing"));
- g_signal_connect (
G_OBJECT (dialog->button_discrete)
, "toggled",
+ g_signal_connect (
dialog->button_discrete
, "toggled",
G_CALLBACK (discrete), dialog);
G_CALLBACK (discrete), dialog);
- g_signal_connect (
G_OBJECT (dialog->button_range)
, "toggled",
+ g_signal_connect (
dialog->button_range
, "toggled",
G_CALLBACK (range), dialog);
G_CALLBACK (range), dialog);
+ g_object_unref (xml);
+
return dialog;
}
return dialog;
}
@@
-307,10
+317,11
@@
missing_val_dialog_show (struct missing_val_dialog *dialog)
union value low, high;
gchar *low_text;
gchar *high_text;
union value low, high;
gchar *low_text;
gchar *high_text;
- mv_peek_range (&dialog->mvl, &low.f, &high.f);
+ mv_get_range (&dialog->mvl, &low.f, &high.f);
+
- low_text = value_to_text (low, *write_spec);
- high_text = value_to_text (high, *write_spec);
+ low_text = value_to_text (low,
dialog->dict,
*write_spec);
+ high_text = value_to_text (high,
dialog->dict,
*write_spec);
gtk_entry_set_text (GTK_ENTRY (dialog->low), low_text);
gtk_entry_set_text (GTK_ENTRY (dialog->high), high_text);
gtk_entry_set_text (GTK_ENTRY (dialog->low), low_text);
gtk_entry_set_text (GTK_ENTRY (dialog->high), high_text);
@@
-320,9
+331,7
@@
missing_val_dialog_show (struct missing_val_dialog *dialog)
if ( mv_has_value (&dialog->mvl))
{
gchar *text;
if ( mv_has_value (&dialog->mvl))
{
gchar *text;
- union value value;
- mv_peek_value (&dialog->mvl, &value, 0);
- text = value_to_text (value, *write_spec);
+ text = value_to_text (*mv_get_value (&dialog->mvl, 0), dialog->dict, *write_spec);
gtk_entry_set_text (GTK_ENTRY (dialog->discrete), text);
g_free (text);
}
gtk_entry_set_text (GTK_ENTRY (dialog->discrete), text);
g_free (text);
}
@@
-342,10
+351,9
@@
missing_val_dialog_show (struct missing_val_dialog *dialog)
if ( i < n)
{
gchar *text ;
if ( i < n)
{
gchar *text ;
- union value value;
- mv_peek_value (&dialog->mvl, &value, i);
-
text = value_to_text (value,
*write_spec);
+ text = value_to_text (*mv_get_value (&dialog->mvl, i), dialog->dict,
+
*write_spec);
gtk_entry_set_text (GTK_ENTRY (dialog->mv[i]), text);
g_free (text);
}
gtk_entry_set_text (GTK_ENTRY (dialog->mv[i]), text);
g_free (text);
}