- SET and SHOW no longer have ENDCMD, NULLINE, PROMPT, CPROMPT, and
DPROMPT subcommands. The defaults are now fixed values.
+ - SHOW now has a JOURNAL subcommand, to show the location of the
+ journal file.
+
- VALUE LABELS can now assign value labels to long string
variables.
AC_C_BIGENDIAN
-AC_CHECK_FUNCS([__setfpucw fork execl execlp isinf isnan finite getpid feholdexcept fpsetmask popen round])
+AC_CHECK_FUNCS([__setfpucw fork execl isinf isnan finite getpid feholdexcept fpsetmask popen round])
AC_PROG_LN_S
Use @samp{-} as @var{output-file} to write output to standard output.
-If no @option{-o} option is used, then @pspp{} writes output to standard
-output in plain text format.
+If no @option{-o} option is used, then @pspp{} writes text and CSV
+output to standard output and other kinds of output to whose name is
+based on the format, e.g.@: @file{pspp.pdf} for PDF output.
@item @option{-O @var{option}=@var{value}}
Sets an option for the output file configured by a preceding
r->leading_zeros = strspn (r->string, "0.");
r->leading_nines = strspn (r->string, "9.");
r->integer_digits = strchr (r->string, '.') - r->string;
+ assert (r->integer_digits < 64);
assert (r->integer_digits >= 0);
r->negative = number < 0;
}
enum fh_mode mode; /* File mode. */
size_t record_width; /* Length of fixed-format records. */
size_t tab_width; /* Tab width, 0=do not expand tabs. */
- char *encoding; /* Charset for contents. */
+ const char *encoding; /* Charset for contents. */
};
void fh_init (void);
if (lex_match (lexer, T_LPAREN))
{
- if (!parse_format_specifier (lexer, &input)
- || !fmt_check_input (&input)
- || !lex_force_match (lexer, T_RPAREN))
+ char type[FMT_TYPE_LEN_MAX + 1];
+
+ if (!parse_abstract_format_specifier (lexer, type, &input.w,
+ &input.d))
+ return NULL;
+ if (!fmt_from_name (type, &input.type))
+ {
+ msg (SE, _("Unknown format type `%s'."), type);
+ return NULL;
+ }
+
+ /* If no width was included, use the minimum width for the type.
+ This isn't quite right, because DATETIME by itself seems to become
+ DATETIME20 (see bug #30690), whereas this will become
+ DATETIME17. The correct behavior is not documented. */
+ if (input.w == 0)
+ {
+ input.w = fmt_min_input_width (input.type);
+ input.d = 0;
+ }
+
+ if (!fmt_check_input (&input) || !lex_force_match (lexer, T_RPAREN))
return NULL;
/* As a special case, N format is treated as F format
/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
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
/* Quoted field. */
int quote = ss_get_byte (&p);
if (!ss_get_until (&p, quote, field))
- msg (SW, _("Quoted string extends beyond end of line."));
+ msg (DW, _("Quoted string extends beyond end of line."));
if (parser->quote_escape && ss_first (p) == quote)
{
ds_assign_substring (tmp, *field);
struct substring ss;
ds_put_byte (tmp, quote);
if (!ss_get_until (&p, quote, &ss))
- msg (SW, _("Quoted string extends beyond end of line."));
+ msg (DW, _("Quoted string extends beyond end of line."));
ds_put_substring (tmp, ss);
}
*field = ds_ss (tmp);
/* Skip trailing soft separator and a single hard separator
if present. */
- ss_ltrim (&p, parser->soft_seps);
- if (!ss_is_empty (p)
- && ss_find_byte (parser->hard_seps, ss_first (p)) != SIZE_MAX)
- ss_advance (&p, 1);
+ if (!ss_is_empty (p))
+ {
+ size_t n_seps = ss_ltrim (&p, parser->soft_seps);
+ if (!ss_is_empty (p)
+ && ss_find_byte (parser->hard_seps, ss_first (p)) != SIZE_MAX)
+ {
+ ss_advance (&p, 1);
+ n_seps++;
+ }
+ if (!n_seps)
+ msg (DW, _("Missing delimiter following quoted string."));
+ }
}
else
{
if (dfm_eof (reader))
{
- msg (SW, _("Partial case of %d of %d records discarded."),
+ msg (DW, _("Partial case of %d of %d records discarded."),
row - 1, parser->records_per_case);
return false;
}
if (dfm_eof (reader))
{
if (f > parser->fields)
- msg (SW, _("Partial case discarded. The first variable "
+ msg (DW, _("Partial case discarded. The first variable "
"missing was %s."), f->name);
ds_destroy (&tmp);
return false;
if (!cut_field (parser, reader, &first_column, &last_column, &tmp, &s))
{
if (f < end - 1 && settings_get_undefined ())
- msg (SW, _("Missing value(s) for all variables from %s onward. "
+ msg (DW, _("Missing value(s) for all variables from %s onward. "
"These will be filled with the system-missing value "
"or blanks, as appropriate."),
f->name);
s = dfm_get_record (reader);
ss_ltrim (&s, parser->soft_seps);
if (!ss_is_empty (s))
- msg (SW, _("Record ends in data not part of any field."));
+ msg (DW, _("Record ends in data not part of any field."));
exit:
dfm_forward_record (reader);
emit_END_CASE (ds, inp);
saw_END_CASE = true;
}
- else if (cmd_result_is_failure (result) && result != CMD_FAILURE)
+ else if (cmd_result_is_failure (result)
+ && result != CMD_FAILURE
+ && lex_get_error_mode (lexer) != LEX_ERROR_INTERACTIVE)
{
if (result == CMD_EOF)
msg (SE, _("Unexpected end-of-file within INPUT PROGRAM."));
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2010, 2011, 2012 Free Software Foundation, Inc.
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
return false;
}
+ if (format->w == 0 && !strchr (lex_tokcstr (lexer), '0'))
+ {
+ msg (SE, _("Format specifier `%s' lacks required width."),
+ lex_tokcstr (lexer));
+ return false;
+ }
+
lex_get (lexer);
return true;
}
format_cell_entry (struct tab_table *table, int c, int r, double value,
char suffix, bool mark_missing, const struct dictionary *dict)
{
- const struct fmt_spec f = {FMT_F, 10, 1};
union value v;
char suffixes[3];
int suffix_len;
char *s;
v.f = value;
- s = data_out (&v, dict_get_encoding (dict), &f);
+ s = data_out (&v, dict_get_encoding (dict), settings_get_format ());
suffix_len = 0;
if (suffix != 0)
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-2000, 2009-2012 Free Software Foundation, Inc.
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
#include "data/casegrouper.h"
#include "data/casereader.h"
+#include "data/casewriter.h"
#include "data/dataset.h"
#include "data/dictionary.h"
#include "data/transformations.h"
size_t var_cnt; /* Number of variables. */
enum dsc_missing_type missing_type; /* Treatment of missing values. */
enum mv_class exclude; /* Classes of missing values to exclude. */
+ struct casereader *z_reader; /* Reader for count, mean, stddev. */
+ casenumber count; /* Number left in this SPLIT FILE group.*/
+ bool ok;
};
/* Statistics. Used as bit indexes, so must be 32 or fewer. */
unsigned long show_stats; /* Statistics to display. */
unsigned long calc_stats; /* Statistics to calculate. */
enum moment max_moment; /* Highest moment needed for stats. */
+
+ /* Z scores. */
+ struct casewriter *z_writer; /* Mean and stddev per SPLIT FILE group. */
};
/* Parsing. */
dsc->sort_by_stat = DSC_NONE;
dsc->sort_ascending = 1;
dsc->show_stats = dsc->calc_stats = DEFAULT_STATS;
+ dsc->z_writer = NULL;
/* Parse DESCRIPTIVES. */
while (lex_token (lexer) != T_ENDCMD)
/* Construct z-score varnames, show translation table. */
if (z_cnt || save_z_scores)
{
+ struct caseproto *proto;
+
if (save_z_scores)
{
int gen_cnt = 0;
}
}
}
+
+ proto = caseproto_create ();
+ for (i = 0; i < 1 + 2 * z_cnt; i++)
+ proto = caseproto_add_width (proto, 0);
+ dsc->z_writer = autopaging_writer_create (proto);
+ caseproto_unref (proto);
+
dump_z_table (dsc);
}
free (dsc_var->z_name);
moments_destroy (dsc_var->moments);
}
+ casewriter_destroy (dsc->z_writer);
free (dsc->vars);
free (dsc);
}
const struct variable **vars;
int all_sysmis = 0;
+ if (t->count <= 0)
+ {
+ struct ccase *z_case;
+
+ z_case = casereader_read (t->z_reader);
+ if (z_case)
+ {
+ size_t z_idx = 0;
+
+ t->count = case_num_idx (z_case, z_idx++);
+ for (z = t->z_scores; z < t->z_scores + t->z_score_cnt; z++)
+ {
+ z->mean = case_num_idx (z_case, z_idx++);
+ z->std_dev = case_num_idx (z_case, z_idx++);
+ }
+ case_unref (z_case);
+ }
+ else
+ {
+ if (t->ok)
+ {
+ msg (SE, _("Internal error processing Z scores"));
+ t->ok = false;
+ }
+ for (z = t->z_scores; z < t->z_scores + t->z_score_cnt; z++)
+ z->mean = z->std_dev = SYSMIS;
+ }
+ }
+ t->count--;
+
if (t->missing_type == DSC_LISTWISE)
{
assert(t->vars);
descriptives_trns_free (void *trns_)
{
struct dsc_trns *t = trns_;
+ bool ok = t->ok && !casereader_error (t->z_reader);
free (t->z_scores);
+ casereader_destroy (t->z_reader);
assert((t->missing_type != DSC_LISTWISE) ^ (t->vars != NULL));
free (t->vars);
- return true;
+ return ok;
}
/* Sets up a transformation to calculate Z scores. */
t->var_cnt = 0;
t->vars = NULL;
}
+ t->z_reader = casewriter_make_reader (dsc->z_writer);
+ t->count = 0;
+ t->ok = true;
+ dsc->z_writer = NULL;
for (cnt = i = 0; i < dsc->var_cnt; i++)
{
z = &t->z_scores[cnt++];
z->src_var = dv->v;
z->z_var = dst_var;
- z->mean = dv->stats[DSC_MEAN];
- z->std_dev = dv->stats[DSC_STDDEV];
}
}
struct dataset *ds)
{
struct casereader *pass1, *pass2;
+ casenumber count;
struct ccase *c;
+ size_t z_idx;
size_t i;
c = casereader_peek (group, 0);
dsc->valid = 0.;
/* First pass to handle most of the work. */
+ count = 0;
for (; (c = casereader_read (pass1)) != NULL; case_unref (c))
{
double weight = dict_get_case_weight (dataset_dict (ds), c, NULL);
if (x > dv->max)
dv->max = x;
}
+
+ count++;
}
if (!casereader_destroy (pass1))
{
}
/* Calculate results. */
+ if (dsc->z_writer)
+ {
+ c = case_create (casewriter_get_proto (dsc->z_writer));
+ z_idx = 0;
+ case_data_rw_idx (c, z_idx++)->f = count;
+ }
+ else
+ c = NULL;
+
for (i = 0; i < dsc->var_cnt; i++)
{
struct dsc_var *dv = &dsc->vars[i];
dv->stats[DSC_MAX] = dv->max == -DBL_MAX ? SYSMIS : dv->max;
if (dsc->calc_stats & (1ul << DSC_SUM))
dv->stats[DSC_SUM] = W * dv->stats[DSC_MEAN];
+
+ if (dv->z_name)
+ {
+ case_data_rw_idx (c, z_idx++)->f = dv->stats[DSC_MEAN];
+ case_data_rw_idx (c, z_idx++)->f = dv->stats[DSC_STDDEV];
+ }
}
+ if (c != NULL)
+ casewriter_write (dsc->z_writer, c);
+
/* Output results. */
display (dsc);
}
{
if (lex_match (lexer, T_LPAREN))
{
- lex_force_num (lexer);
+ if (! lex_force_num (lexer))
+ return 2;
btp->category1 = lex_number (lexer);
lex_get (lexer);
if ( lex_match (lexer, T_COMMA))
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
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
return xstrdup (fmt_to_string (settings_get_format (), str));
}
+static char *
+show_journal (const struct dataset *ds UNUSED)
+{
+ return (journal_is_enabled ()
+ ? xasprintf ("\"%s\"", journal_get_file_name ())
+ : xstrdup ("disabled"));
+}
+
static char *
show_length (const struct dataset *ds UNUSED)
{
{"ENVIRONMENT", show_system},
{"ERRORS", show_errors},
{"FORMAT", show_format},
+ {"JOURNAL", show_journal},
{"LENGTH", show_length},
{"LOCALE", show_locale},
{"MESSAGES", show_messages},
#else
#define expensive_assert(EXPR) ((void) 0)
#endif
+
+
+#define testing_assert(EXPR) do {if (settings_get_testing_mode ()) assert (EXPR); } while (0);
#include <gsl/gsl_histogram.h>
#include <math.h>
+#include "data/settings.h"
#include "libpspp/message.h"
#include "libpspp/assertion.h"
#include "libpspp/cast.h"
ADJ_MIN and ADJ_MAX are locations of the adjusted values of MIN and MAX (the range will
always be equal or slightly larger).
Returns the number of bins.
+
+ The "testing_assert" expressions in this function should be algebraically correct.
+ However, due to floating point rounding they could fail, especially when small numbers
+ are involved. In normal use, therefore, testing_assert does nothing.
*/
static int
adjust_bin_ranges (double bin_width, double min, double max, double *adj_min, double *adj_max)
double lower_slack = get_slack (min, half_bin_width, &lower_limit);
double upper_slack = -get_slack (max, half_bin_width, &upper_limit);
- assert (max > min);
+ testing_assert (max > min);
/* If min is negative, then lower_slack may be less than zero.
In this case, the lower bound must be extended in the negative direction
lower_limit--;
lower_slack += half_bin_width;
}
- assert (lower_limit * half_bin_width <= min);
+ testing_assert (lower_limit * half_bin_width <= min);
/* However, the upper bound must be extended regardless, because histogram bins
span the range [lower, upper). In other words, the upper bound must be
*/
upper_limit++;;
upper_slack += half_bin_width;
- assert (upper_limit * half_bin_width > max);
+ testing_assert (upper_limit * half_bin_width > max);
/* The range must be an EVEN number of half bin_widths */
if ( (upper_limit - lower_limit) % 2)
if (upper_slack > lower_slack)
{
- assert (upper_slack > half_bin_width);
+ testing_assert (upper_slack > half_bin_width);
/* Adjust the range to the left */
lower_limit --;
}
else
{
- assert (lower_slack >= half_bin_width);
+ testing_assert (lower_slack >= half_bin_width);
/* Adjust the range to the right */
lower_limit ++;
*adj_min = lower_limit * half_bin_width;
*adj_max = upper_limit * half_bin_width;
- assert (*adj_max > max);
- assert (*adj_min <= min);
+ testing_assert (*adj_max > max);
+ testing_assert (*adj_min <= min);
return (upper_limit - lower_limit) / 2.0;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
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
}
const struct output_driver_factory txt_driver_factory =
- { "txt", ascii_create };
+ { "txt", "-", ascii_create };
const struct output_driver_factory list_driver_factory =
- { "list", ascii_create };
+ { "list", "-", ascii_create };
static const struct output_driver_class ascii_driver_class =
{
xr_draw_cell (xr, &cell, bb, bb);
}
\f
-struct output_driver_factory pdf_driver_factory = { "pdf", xr_pdf_create };
-struct output_driver_factory ps_driver_factory = { "ps", xr_ps_create };
-struct output_driver_factory svg_driver_factory = { "svg", xr_svg_create };
+struct output_driver_factory pdf_driver_factory =
+ { "pdf", "pspp.pdf", xr_pdf_create };
+struct output_driver_factory ps_driver_factory =
+ { "ps", "pspp.ps", xr_ps_create };
+struct output_driver_factory svg_driver_factory =
+ { "svg", "pspp.svg", xr_svg_create };
static const struct output_driver_class cairo_driver_class =
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010, 2012 Free Software Foundation, Inc.
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
}
}
-struct output_driver_factory csv_driver_factory = { "csv", csv_create };
+struct output_driver_factory csv_driver_factory = { "csv", "-", csv_create };
static const struct output_driver_class csv_driver_class =
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2012 Free Software Foundation, Inc.
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
/* The file extension, without the leading dot, e.g. "pdf". */
const char *extension;
+ /* The default file name, including extension.
+
+ If this is "-", that implies that by default output will be directed to
+ stdout. */
+ const char *default_file_name;
+
/* Creates a new output driver of this class. NAME and TYPE should be
passed directly to output_driver_init. Returns the new output driver if
successful, otherwise a null pointer.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
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
char *file_name;
char *format;
+ format = string_map_find_and_delete (options, "format");
file_name = string_map_find_and_delete (options, "output-file");
- if (file_name == NULL)
- file_name = xstrdup ("-");
- format = string_map_find_and_delete (options, "format");
if (format == NULL)
{
- const char *extension = strrchr (file_name, '.');
- format = xstrdup (extension != NULL ? extension + 1 : "");
+ if (file_name != NULL)
+ {
+ const char *extension = strrchr (file_name, '.');
+ format = xstrdup (extension != NULL ? extension + 1 : "");
+ }
+ else
+ format = xstrdup ("txt");
}
+ f = find_factory (format);
+
+ if (file_name == NULL)
+ file_name = xstrdup (f->default_file_name);
/* XXX should use parse_enum(). */
device_string = string_map_find_and_delete (options, "device");
device_type = default_device_type (file_name);
}
- f = find_factory (format);
driver = f->create (file_name, device_type, options);
if (driver != NULL)
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
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
fputs ("</TABLE>\n\n", html->file);
}
-struct output_driver_factory html_driver_factory = { "html", html_create };
+struct output_driver_factory html_driver_factory =
+ { "html", "pspp.html", html_create };
static const struct output_driver_class html_driver_class =
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010, 2012 Free Software Foundation, Inc.
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
{
if (j->file == NULL)
{
- j->file = fopen (journal_file_name, "a");
+ j->file = fopen (journal_get_file_name (), "a");
if (j->file == NULL)
{
error (0, errno, _("error opening output file `%s'"),
- journal_file_name);
+ journal_get_file_name ());
output_driver_destroy (&j->driver);
return;
}
{
if (journal == NULL)
{
- /* If no journal file name is configured, use the default. */
- if (journal_file_name == NULL)
- {
- const char *output_path = default_output_path ();
- journal_file_name = xasprintf ("%s%s", output_path, "pspp.jnl");
- }
-
/* Create journal driver. */
journal = xzalloc (sizeof *journal);
output_driver_init (&journal->driver, &journal_class, "journal",
output_driver_destroy (&journal->driver);
}
+/* Returns true if journaling is enabled, false otherwise. */
+bool
+journal_is_enabled (void)
+{
+ return journal != NULL;
+}
+
/* Sets the name of the journal file to FILE_NAME. */
void
journal_set_file_name (const char *file_name)
free (journal_file_name);
journal_file_name = xstrdup (file_name);
}
+
+/* Returns the name of the journal file. The caller must not modify or free
+ the returned string. */
+const char *
+journal_get_file_name (void)
+{
+ if (journal_file_name == NULL)
+ {
+ const char *output_path = default_output_path ();
+ journal_file_name = xasprintf ("%s%s", output_path, "pspp.jnl");
+ }
+ return journal_file_name;
+}
/* PSPP - a program for statistical analysis.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2012 Free Software Foundation, Inc.
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
void journal_enable (void);
void journal_disable (void);
+bool journal_is_enabled (void);
void journal_set_file_name (const char *);
+const char *journal_get_file_name (void);
#endif /* output/journal.h */
#include "output/measure.h"
+#include <gl/c-strtod.h>
#include <ctype.h>
#include <errno.h>
#if HAVE_LC_PAPER
char *tail;
/* Number. */
- raw = strtod (dimen, &tail);
+ raw = c_strtod (dimen, &tail);
if (raw < 0.0)
goto syntax_error;
char *tail;
/* Width. */
- raw_h = strtod (size, &tail);
+ raw_h = c_strtod (size, &tail);
if (raw_h <= 0.0)
return false;
tail += strspn (tail, CC_SPACES "x,");
/* Length. */
- raw_v = strtod (tail, &tail);
+ raw_v = c_strtod (tail, &tail);
if (raw_v <= 0.0)
return false;
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
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
}
}
-struct output_driver_factory odt_driver_factory = { "odt", odt_create };
+struct output_driver_factory odt_driver_factory =
+ { "odt", "pspp.odf", odt_create };
static const struct output_driver_class odt_driver_class =
{
noinst_LTLIBRARIES += src/ui/libuicommon.la
src_ui_libuicommon_la_SOURCES = \
- src/ui/debugger.c src/ui/debugger.h \
src/ui/source-init-opts.c src/ui/source-init-opts.h \
src/ui/syntax-gen.c src/ui/syntax-gen.h
+++ /dev/null
-/* PSPP - a program for statistical analysis.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
- 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
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "debugger.h"
-
-#if HAVE_FORK && HAVE_EXECLP
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-
-/* Fork, start gdb and connect to the parent process.
- If that happens successfully, then this function does not return,
- but exits with EXIT_FAILURE. Otherwise it returns.
- */
-void
-connect_debugger (void)
-{
- char pidstr[20];
- pid_t pid;
-
- snprintf (pidstr, 20, "%d", getpid ());
- pid = fork ();
- if ( pid == -1 )
- {
- perror ("Cannot fork");
- return ;
- }
- if ( pid == 0 )
- {
- /* child */
- execlp ("gdb", "gdb", "-p", pidstr, NULL);
- perror ("Cannot exec debugger");
- exit (EXIT_FAILURE);
- }
- else
- {
- int status;
- wait (&status);
- if ( EXIT_SUCCESS != WEXITSTATUS (status) )
- return ;
- }
-
- exit (EXIT_FAILURE);
-}
-
-#else /* !(HAVE_FORK && HAVE_EXECLP) */
-/* Don't know how to connect to gdb.
- Just return.
- */
-void
-connect_debugger (void)
-{
-}
-#endif /* !(HAVE_FORK && HAVE_EXECLP) */
+++ /dev/null
-/* PSPP - a program for statistical analysis.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
- 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
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef DEBUGGER_H
-#define DEBUGGER_H
-
-
-/* Fork, start gdb and connect to the parent process.
- Exit with EXIT_FAILURE.
- */
-void connect_debugger (void) ;
-
-#endif
static char * generate_syntax (const struct aggregate *rd);
-/* Makes widget W's sensitivity follow the active state of TOGGLE */
-static void
-sensitive_if_active (GtkToggleButton *toggle, GtkWidget *w)
-{
- gboolean active = gtk_toggle_button_get_active (toggle);
-
- gtk_widget_set_sensitive (w, active);
-}
-
static void update_arguments (struct aggregate *agg);
dialog_state_valid, &fd);
g_signal_connect (fd.filename_radiobutton, "toggled",
- G_CALLBACK (sensitive_if_active), fd.filename_box );
+ G_CALLBACK (set_sensitivity_from_toggle), fd.filename_box );
g_signal_connect_swapped (fd.filename_button, "clicked",
G_CALLBACK (choose_filename), &fd);
src/ui/gui/autorecode-dialog.h \
src/ui/gui/aggregate-dialog.c \
src/ui/gui/aggregate-dialog.h \
- src/ui/gui/binomial-dialog.c \
- src/ui/gui/binomial-dialog.h \
src/ui/gui/builder-wrapper.c \
src/ui/gui/builder-wrapper.h \
src/ui/gui/checkbox-treeview.c \
src/ui/gui/chi-square-dialog.h \
src/ui/gui/count-dialog.c \
src/ui/gui/count-dialog.h \
- src/ui/gui/crosstabs-dialog.c \
- src/ui/gui/crosstabs-dialog.h \
src/ui/gui/dialog-common.c \
src/ui/gui/dialog-common.h \
src/ui/gui/dict-display.h \
src/ui/gui/executor.h \
src/ui/gui/find-dialog.c \
src/ui/gui/find-dialog.h \
- src/ui/gui/frequencies-dialog.c \
- src/ui/gui/frequencies-dialog.h \
src/ui/gui/goto-case-dialog.c \
src/ui/gui/goto-case-dialog.h \
src/ui/gui/helper.c \
src/ui/gui/psppire-dialog.h \
src/ui/gui/psppire-dialog-action.c \
src/ui/gui/psppire-dialog-action.h \
+ src/ui/gui/psppire-dialog-action-binomial.c \
+ src/ui/gui/psppire-dialog-action-binomial.h \
src/ui/gui/psppire-dialog-action-correlation.c \
src/ui/gui/psppire-dialog-action-correlation.h \
+ src/ui/gui/psppire-dialog-action-crosstabs.c \
+ src/ui/gui/psppire-dialog-action-crosstabs.h \
src/ui/gui/psppire-dialog-action-descriptives.c \
src/ui/gui/psppire-dialog-action-descriptives.h \
src/ui/gui/psppire-dialog-action-examine.c \
src/ui/gui/psppire-dialog-action-examine.h \
src/ui/gui/psppire-dialog-action-factor.c \
src/ui/gui/psppire-dialog-action-factor.h \
+ src/ui/gui/psppire-dialog-action-frequencies.c \
+ src/ui/gui/psppire-dialog-action-frequencies.h \
src/ui/gui/psppire-dialog-action-indep-samps.c \
src/ui/gui/psppire-dialog-action-indep-samps.h \
src/ui/gui/psppire-dialog-action-kmeans.c \
+++ /dev/null
-/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2010, 2011, 2012 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
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "binomial-dialog.h"
-
-#include "psppire-dialog.h"
-#include "psppire-var-view.h"
-#include "psppire-acr.h"
-#include "dialog-common.h"
-
-#include "builder-wrapper.h"
-#include "executor.h"
-#include "helper.h"
-
-#include <gtk/gtk.h>
-
-struct binomial_dialog
-{
- PsppireDict *dict;
- GtkWidget *var_view;
-
- GtkWidget *button1;
-
- GtkWidget *prop_entry;
-
- GtkWidget *cutpoint_button;
- GtkWidget *cutpoint_entry;
-};
-
-static void
-set_sensitivity (GtkToggleButton *button, GtkWidget *w)
-{
- gboolean state = gtk_toggle_button_get_active (button);
- gtk_widget_set_sensitive (w, state);
-}
-
-
-static gboolean
-get_proportion (const struct binomial_dialog *bin_d, double *prop)
-{
- const gchar *text = gtk_entry_get_text (GTK_ENTRY (bin_d->prop_entry));
- gchar *endptr = NULL;
- *prop = g_strtod (text, &endptr);
-
- if (endptr == text)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-dialog_state_valid (gpointer data)
-{
- double prop;
- struct binomial_dialog *bin_d = data;
-
- GtkTreeModel *vars =
- gtk_tree_view_get_model (GTK_TREE_VIEW (bin_d->var_view));
-
- GtkTreeIter notused;
-
- if ( !gtk_tree_model_get_iter_first (vars, ¬used) )
- return FALSE;
-
- if ( ! get_proportion (bin_d, &prop))
- return FALSE;
-
- if (prop < 0 || prop > 1.0)
- return FALSE;
-
- return TRUE;
-}
-
-
-static void
-refresh (struct binomial_dialog *bin_d)
-{
- GtkTreeModel *liststore =
- gtk_tree_view_get_model (GTK_TREE_VIEW (bin_d->var_view));
-
- gtk_list_store_clear (GTK_LIST_STORE (liststore));
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bin_d->button1), TRUE);
-
- gtk_entry_set_text (GTK_ENTRY (bin_d->prop_entry), "0.5");
-
- gtk_entry_set_text (GTK_ENTRY (bin_d->cutpoint_entry), "");
-}
-
-
-
-static char *
-generate_syntax (const struct binomial_dialog *scd)
-{
- gchar *text;
- double prop;
- GString *string;
-
- string = g_string_new ("NPAR TEST\n\t/BINOMIAL");
-
- if ( get_proportion (scd, &prop))
- g_string_append_printf (string, "(%g)", prop);
-
- g_string_append (string, " =");
-
- psppire_var_view_append_names (PSPPIRE_VAR_VIEW (scd->var_view), 0, string);
-
- if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->cutpoint_button)))
- {
- const gchar *cutpoint = gtk_entry_get_text (GTK_ENTRY (scd->cutpoint_entry));
- g_string_append_printf (string, "(%s)", cutpoint);
- }
-
- g_string_append (string, ".\n");
-
- text = string->str;
-
- g_string_free (string, FALSE);
-
- return text;
-}
-
-
-
-/* Pops up the Chi-Square dialog box */
-void
-binomial_dialog (PsppireDataWindow *dw)
-{
- gint response;
-
- struct binomial_dialog bin_d;
-
- GtkBuilder *xml = builder_new ("binomial.ui");
-
- GtkWidget *dialog = get_widget_assert (xml, "binomial-dialog");
-
-
-
- GtkWidget *dict_view = get_widget_assert (xml, "dict-view");
-
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (dw));
-
- bin_d.var_view = get_widget_assert (xml, "variables-treeview");
- bin_d.button1 = get_widget_assert (xml, "radiobutton3");
- bin_d.prop_entry = get_widget_assert (xml, "proportion-entry");
-
- bin_d.cutpoint_entry = get_widget_assert (xml, "cutpoint-entry");
- bin_d.cutpoint_button = get_widget_assert (xml, "radiobutton4");
-
- g_object_get (dw->data_editor, "dictionary", &bin_d.dict, NULL);
- g_object_set (dict_view,
- "model", bin_d.dict,
- "predicate", var_is_numeric,
- NULL);
-
- g_signal_connect (bin_d.cutpoint_button, "toggled", G_CALLBACK (set_sensitivity),
- bin_d.cutpoint_entry);
-
- g_signal_connect_swapped (dialog, "refresh", G_CALLBACK (refresh), &bin_d);
-
- psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
- dialog_state_valid, &bin_d);
-
- response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
-
-
- switch (response)
- {
- case GTK_RESPONSE_OK:
- g_free (execute_syntax_string (dw, generate_syntax (&bin_d)));
- break;
- case PSPPIRE_RESPONSE_PASTE:
- g_free (paste_syntax_to_window (generate_syntax (&bin_d)));
- break;
- default:
- break;
- }
-
- g_object_unref (xml);
-}
+++ /dev/null
-/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2010 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
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef __BINOMIAL_DIALOG_H
-#define __BINOMIAL_DIALOG_H
-
-#include "psppire-data-window.h"
-
-void binomial_dialog (PsppireDataWindow * data);
-
-#endif
GtkListStore *expected_list;
};
-static void
-set_sensitivity (GtkToggleButton *button, GtkWidget *w)
-{
- gboolean state = gtk_toggle_button_get_active (button);
- gtk_widget_set_sensitive (w, state);
-}
-
-
static gboolean
dialog_state_valid (gpointer data)
{
NULL);
- g_signal_connect (csd.range_button, "toggled", G_CALLBACK (set_sensitivity),
+ g_signal_connect (csd.range_button, "toggled", G_CALLBACK (set_sensitivity_from_toggle),
range_table);
- g_signal_connect (csd.values_button, "toggled", G_CALLBACK (set_sensitivity),
+ g_signal_connect (csd.values_button, "toggled", G_CALLBACK (set_sensitivity_from_toggle),
values_acr);
- g_signal_connect (csd.values_button, "toggled", G_CALLBACK (set_sensitivity),
+ g_signal_connect (csd.values_button, "toggled", G_CALLBACK (set_sensitivity_from_toggle),
expected_value_entry);
+++ /dev/null
-/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2010, 2011, 2012 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
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "checkbox-treeview.h"
-#include "crosstabs-dialog.h"
-#include "psppire-var-view.h"
-
-#include <gtk/gtk.h>
-#include <stdlib.h>
-
-#include <ui/gui/psppire-data-window.h>
-#include <ui/gui/dialog-common.h>
-#include <ui/gui/dict-display.h>
-#include "executor.h"
-#include <ui/gui/psppire-dialog.h>
-#include <ui/gui/builder-wrapper.h>
-#include "helper.h"
-
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-#define N_(msgid) msgid
-
-
-#define CROSSTABS_STATS \
- CS (CHISQ, N_("Chisq")) \
- CS (PHI, N_("Phi")) \
- CS (CC, N_("CC")) \
- CS (LAMBDA, N_("Lambda")) \
- CS (UC, N_("UC")) \
- CS (BTAU, N_("BTau")) \
- CS (CTAU, N_("CTau")) \
- CS (RISK, N_("Risk")) \
- CS (GAMMA, N_("Gamma")) \
- CS (D, N_("D")) \
- CS (KAPPA, N_("Kappa")) \
- CS (ETA, N_("Eta")) \
- CS (CORR, N_("Corr")) \
- CS (STATS_NONE, N_("None"))
-
-#define CROSSTABS_CELLS \
- CS (COUNT, N_("Count")) \
- CS (ROW, N_("Row")) \
- CS (COLUMN, N_("Column")) \
- CS (TOTAL, N_("Total")) \
- CS (EXPECTED, N_("Expected")) \
- CS (RESIDUAL, N_("Residual")) \
- CS (SRESIDUAL, N_("Std. Residual")) \
- CS (ASRESIDUAL, N_("Adjusted Std. Residual")) \
- CS (CELLS_NONE, N_("None"))
-
-enum
- {
-#define CS(NAME, LABEL) CS_##NAME,
- CROSSTABS_STATS
-#undef CS
- N_CROSSTABS_STATS
- };
-
-enum
- {
-#define CS(NAME, LABEL) CS_##NAME,
- CROSSTABS_CELLS
-#undef CS
- N_CROSSTABS_CELLS
- };
-
-enum
- {
-#define CS(NAME, LABEL) B_CS_##NAME = 1u << CS_##NAME,
- CROSSTABS_STATS
- CROSSTABS_CELLS
-#undef CS
- B_CS_STATS_ALL = (1u << N_CROSSTABS_STATS) - 1,
- B_CS_CELLS_ALL = (1u << N_CROSSTABS_CELLS) - 1,
- B_CS_STATS_DEFAULT = B_CS_CHISQ,
- B_CS_CELL_DEFAULT = B_CS_COUNT | B_CS_ROW | B_CS_COLUMN | B_CS_TOTAL,
- B_CS_NONE
- };
-
-static const struct checkbox_entry_item stats[] =
- {
-#define CS(NAME, LABEL) {#NAME, LABEL},
- CROSSTABS_STATS \
- CS(NONE, N_("None"))
-#undef CS
- };
-
-static const struct checkbox_entry_item cells[] =
- {
-#define CS(NAME, LABEL) {#NAME, LABEL},
- CROSSTABS_CELLS \
- CS(NONE, N_("None"))
-#undef CS
- };
-
-struct format_options
-{
- gboolean avalue;
- gboolean pivot;
- gboolean table;
-};
-
-struct crosstabs_dialog
-{
- GtkTreeView *row_vars;
- GtkTreeView *col_vars;
- PsppireDict *dict;
-
- GtkToggleButton *table_button;
- GtkToggleButton *pivot_button;
-
- GtkWidget *format_dialog;
- GtkWidget *cell_dialog;
- GtkWidget *stat_dialog;
-
- GtkToggleButton *avalue;
- GtkTreeModel *stat;
- GtkTreeModel *cell;
-
- GtkWidget *stat_view;
- GtkWidget *cell_view;
- struct format_options current_opts;
-};
-
-static void
-refresh (PsppireDialog *dialog, struct crosstabs_dialog *cd)
-{
- GtkTreeModel *liststore = gtk_tree_view_get_model (cd->row_vars);
- gtk_list_store_clear (GTK_LIST_STORE (liststore));
-
- liststore = gtk_tree_view_get_model (cd->col_vars);
- gtk_list_store_clear (GTK_LIST_STORE (liststore));
-}
-static void
-on_format_clicked (struct crosstabs_dialog *cd)
-{
- int ret;
-
- if (cd->current_opts.avalue)
- {
- gtk_toggle_button_set_active (cd->avalue, TRUE);
- }
- if (cd->current_opts.table)
- {
- gtk_toggle_button_set_active (cd->table_button, TRUE);
- }
- if (cd->current_opts.pivot)
- {
- gtk_toggle_button_set_active (cd->pivot_button, TRUE);
- }
-
- ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->format_dialog));
-
- if ( ret == PSPPIRE_RESPONSE_CONTINUE )
- {
- cd->current_opts.avalue = (gtk_toggle_button_get_active (cd->avalue) == TRUE )
- ? TRUE : FALSE;
- cd->current_opts.table = (gtk_toggle_button_get_active (cd->table_button) == TRUE)
- ? TRUE : FALSE;
- cd->current_opts.pivot = (gtk_toggle_button_get_active (cd->pivot_button) == TRUE)
- ? TRUE : FALSE;
- }
-}
-
-static void
-on_statistics_clicked (struct crosstabs_dialog *cd)
-{
- GtkListStore *liststore;
- int ret;
-
- liststore = clone_list_store (GTK_LIST_STORE (cd->stat));
-
- ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->stat_dialog));
-
- if ( ret == PSPPIRE_RESPONSE_CONTINUE )
- {
- g_object_unref (liststore);
- }
- else
- {
- g_object_unref (cd->stat);
- gtk_tree_view_set_model (GTK_TREE_VIEW (cd->stat_view) , GTK_TREE_MODEL (liststore));
- cd->stat = GTK_TREE_MODEL (liststore);
- }
-}
-static void
-on_cell_clicked (struct crosstabs_dialog *cd)
-{
- GtkListStore *liststore;
- int ret;
-
- liststore = clone_list_store (GTK_LIST_STORE (cd->cell));
-
- ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->cell_dialog));
-
- if ( ret == PSPPIRE_RESPONSE_CONTINUE )
- {
- g_object_unref (liststore);
- }
- else
- {
- g_object_unref (cd->cell);
- gtk_tree_view_set_model (GTK_TREE_VIEW (cd->cell_view) , GTK_TREE_MODEL (liststore));
- cd->cell = GTK_TREE_MODEL (liststore);
- }
-}
-
-static char *
-generate_syntax (const struct crosstabs_dialog *cd)
-{
- gint i;
- int n;
- guint selected;
- GtkTreeIter iter;
- gboolean ok;
-
- gchar *text;
- GString *string = g_string_new ("CROSSTABS");
-
- g_string_append (string, "\n\t/TABLES=");
- psppire_var_view_append_names (PSPPIRE_VAR_VIEW (cd->row_vars), 0, string);
- g_string_append (string, "\tBY\t");
- psppire_var_view_append_names (PSPPIRE_VAR_VIEW (cd->col_vars), 0, string);
-
- g_string_append (string, "\n\t/FORMAT=");
-
- if (cd->current_opts.avalue)
- {
- g_string_append (string, "AVALUE");
- }
- else
- {
- g_string_append (string, "DVALUE");
- }
- g_string_append (string, " ");
- if (cd->current_opts.table)
- g_string_append (string, "TABLES");
- else
- g_string_append (string, "NOTABLES");
- g_string_append (string, " ");
-
- if (cd->current_opts.pivot)
- g_string_append (string, "PIVOT");
- else
- g_string_append (string, "NOPIVOT");
-
- selected = 0;
- for (i = 0, ok = gtk_tree_model_get_iter_first (cd->stat, &iter); ok;
- i++, ok = gtk_tree_model_iter_next (cd->stat, &iter))
- {
- gboolean toggled;
- gtk_tree_model_get (cd->stat, &iter,
- CHECKBOX_COLUMN_SELECTED, &toggled, -1);
- if (toggled)
- selected |= 1u << i;
- else
- selected &= ~(1u << i);
- }
-
- if (!(selected & (1u << CS_STATS_NONE)))
- {
- if (selected)
- {
- g_string_append (string, "\n\t/STATISTICS=");
- n = 0;
- for (i = 0; i < N_CROSSTABS_STATS; i++)
- if (selected & (1u << i))
- {
- if (n++)
- g_string_append (string, " ");
- g_string_append (string, stats[i].name);
- }
- }
- }
-
- selected = 0;
- for (i = 0, ok = gtk_tree_model_get_iter_first (cd->cell, &iter); ok;
- i++, ok = gtk_tree_model_iter_next (cd->cell, &iter))
- {
- gboolean toggled;
- gtk_tree_model_get (cd->cell, &iter,
- CHECKBOX_COLUMN_SELECTED, &toggled, -1);
- if (toggled)
- selected |= 1u << i;
- else
- selected &= ~(1u << i);
- }
-
- g_string_append (string, "\n\t/CELLS=");
- if (selected & (1u << CS_CELLS_NONE))
- g_string_append (string, "NONE");
- else
- {
- n = 0;
- for (i = 0; i < N_CROSSTABS_CELLS; i++)
- if (selected & (1u << i))
- {
- if (n++)
- g_string_append (string, " ");
- g_string_append (string, cells[i].name);
- }
- }
-
- g_string_append (string, ".\n");
-
- text = string->str;
-
- g_string_free (string, FALSE);
-
- return text;
-}
-
-/* Dialog is valid iff at least one row and one column variable has
- been selected. */
-static gboolean
-dialog_state_valid (gpointer data)
-{
- struct crosstabs_dialog *cd = data;
-
- GtkTreeModel *row_vars = gtk_tree_view_get_model (cd->row_vars);
- GtkTreeModel *col_vars = gtk_tree_view_get_model (cd->col_vars);
-
- GtkTreeIter notused;
-
- return (gtk_tree_model_get_iter_first (row_vars, ¬used)
- && gtk_tree_model_get_iter_first (col_vars, ¬used));
-}
-
-/* Pops up the Crosstabs dialog box */
-void
-crosstabs_dialog (PsppireDataWindow *de)
-{
- gint response;
- struct crosstabs_dialog cd;
-
- GtkBuilder *xml = builder_new ("crosstabs.ui");
- PsppireDict *dict = NULL;
-
-
- GtkWidget *dialog = get_widget_assert (xml, "crosstabs-dialog");
- GtkWidget *source = get_widget_assert (xml, "dict-treeview");
- GtkWidget *dest_rows = get_widget_assert (xml, "rows");
- GtkWidget *dest_cols = get_widget_assert (xml, "cols");
- GtkWidget *format_button = get_widget_assert (xml, "format-button");
- GtkWidget *stat_button = get_widget_assert (xml, "stats-button");
- GtkWidget *cell_button = get_widget_assert (xml, "cell-button");
-
-
- cd.stat_view = get_widget_assert (xml, "stats-view");
- cd.cell_view = get_widget_assert (xml, "cell-view");
-
- put_checkbox_items_in_treeview (GTK_TREE_VIEW(cd.stat_view),
- B_CS_STATS_DEFAULT,
- N_CROSSTABS_STATS,
- stats
- );
- put_checkbox_items_in_treeview (GTK_TREE_VIEW(cd.cell_view),
- B_CS_CELL_DEFAULT,
- N_CROSSTABS_CELLS,
- cells
- );
-
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
-
- g_object_get (de->data_editor, "dictionary", &dict, NULL);
- g_object_set (source, "model", dict, NULL);
-
- cd.row_vars = GTK_TREE_VIEW (dest_rows);
- cd.col_vars = GTK_TREE_VIEW (dest_cols);
- g_object_get (de->data_editor, "dictionary", &cd.dict, NULL);
- cd.format_dialog = get_widget_assert (xml, "format-dialog");
- cd.table_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "print-tables"));
- cd.pivot_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "pivot"));
- cd.stat_dialog = get_widget_assert (xml, "stat-dialog");
- cd.cell_dialog = get_widget_assert (xml, "cell-dialog");
-
- cd.stat = gtk_tree_view_get_model (GTK_TREE_VIEW (cd.stat_view));
- cd.cell = gtk_tree_view_get_model (GTK_TREE_VIEW (cd.cell_view));
- cd.avalue = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "ascending"));
- cd.current_opts.avalue = TRUE;
- cd.current_opts.table = TRUE;
- cd.current_opts.pivot = TRUE;
-
- gtk_window_set_transient_for (GTK_WINDOW (cd.format_dialog), GTK_WINDOW (de));
- gtk_window_set_transient_for (GTK_WINDOW (cd.cell_dialog), GTK_WINDOW (de));
- gtk_window_set_transient_for (GTK_WINDOW (cd.stat_dialog), GTK_WINDOW (de));
-
- g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &cd);
-
- psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
- dialog_state_valid, &cd);
-
- g_signal_connect_swapped (format_button, "clicked",
- G_CALLBACK (on_format_clicked), &cd);
- g_signal_connect_swapped (stat_button, "clicked",
- G_CALLBACK (on_statistics_clicked), &cd);
- g_signal_connect_swapped (cell_button, "clicked",
- G_CALLBACK (on_cell_clicked), &cd);
-
- response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
-
-
- switch (response)
- {
- case GTK_RESPONSE_OK:
- g_free (execute_syntax_string (de, generate_syntax (&cd)));
- break;
- case PSPPIRE_RESPONSE_PASTE:
- g_free (paste_syntax_to_window (generate_syntax (&cd)));
- break;
- default:
- break;
- }
-
- g_object_unref (xml);
-}
+++ /dev/null
-/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2010 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
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef __CROSSTABS_DIALOG_H
-#define __CROSSTABS_DIALOG_H
-
-#include "psppire-data-window.h"
-
-void crosstabs_dialog (PsppireDataWindow * data);
-
-#endif
</object>
</child>
<child>
- <object class="GtkAction" id="analyze_frequencies">
- <property name="name">analyze_frequencies</property>
+ <object class="PsppireDialogActionFrequencies" id="frequencies">
+ <property name="manager">uimanager1</property>
+ <property name="name">frequencies</property>
<property name="label" translatable="yes">_Frequencies...</property>
</object>
</child>
</object>
</child>
<child>
- <object class="GtkAction" id="crosstabs">
+ <object class="PsppireDialogActionCrosstabs" id="crosstabs">
<property name="name">crosstabs</property>
+ <property name="manager">uimanager1</property>
<property name="label" translatable="yes">_Crosstabs...</property>
</object>
</child>
</object>
</child>
<child>
- <object class="GtkAction" id="binomial">
+ <object class="PsppireDialogActionBinomial" id="binomial">
<property name="name">binomial</property>
+ <property name="manager">uimanager1</property>
<property name="label" translatable="yes">_Binomial...</property>
</object>
</child>
</menu>
<menu action="analyze">
<menu action="descriptive-statistics">
- <menuitem action="analyze_frequencies"/>
+ <menuitem action="frequencies"/>
<menuitem action="analyze_descriptives"/>
<menuitem action="explore"/>
<menuitem action="crosstabs"/>
return retval;
}
+/*
+ A pair of functions intended to be used as callbacks for the "toggled" signal
+ of a GtkToggleButton widget. They make the sensitivity of W follow the status
+ of the togglebutton.
+*/
+void
+set_sensitivity_from_toggle (GtkToggleButton *togglebutton, GtkWidget *w)
+{
+ gboolean active = gtk_toggle_button_get_active (togglebutton);
+
+ gtk_widget_set_sensitive (w, active);
+ if (active)
+ gtk_widget_grab_focus (w);
+}
+
+/* */
+void
+set_sensitivity_from_toggle_invert (GtkToggleButton *togglebutton,
+ GtkWidget *w)
+{
+ gboolean active = gtk_toggle_button_get_active (togglebutton);
+
+ gtk_widget_set_sensitive (w, !active);
+}
+
+
+
*/
gboolean numeric_only (GtkWidget *source, GtkWidget *dest);
+/*
+ A pair of functions intended to be used as callbacks for the "toggled" signal
+ of a GtkToggleButton widget. They make the sensitivity of W follow the status
+ of the togglebutton.
+*/
+void set_sensitivity_from_toggle (GtkToggleButton *togglebutton, GtkWidget *w);
+void set_sensitivity_from_toggle_invert (GtkToggleButton *togglebutton, GtkWidget *w);
+
#endif
+++ /dev/null
-/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007, 2010, 2011, 2012 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
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "checkbox-treeview.h"
-#include "frequencies-dialog.h"
-#include "psppire-var-view.h"
-
-#include <gtk/gtk.h>
-#include <stdlib.h>
-
-#include <ui/gui/psppire-data-window.h>
-#include <ui/gui/dialog-common.h>
-#include <ui/gui/dict-display.h>
-#include <ui/gui/builder-wrapper.h>
-#include <ui/gui/psppire-dialog.h>
-#include "executor.h"
-#include "helper.h"
-
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-#define N_(msgid) msgid
-
-
-#define FREQUENCY_STATS \
- FS (MEAN, N_("Mean")) \
- FS (STDDEV, N_("Standard deviation")) \
- FS (MINIMUM, N_("Minimum")) \
- FS (MAXIMUM, N_("Maximum")) \
- FS (SEMEAN, N_("Standard error of the mean")) \
- FS (VARIANCE, N_("Variance")) \
- FS (SKEWNESS, N_("Skewness")) \
- FS (SESKEW, N_("Standard error of the skewness")) \
- FS (RANGE, N_("Range")) \
- FS (MODE, N_("Mode")) \
- FS (KURTOSIS, N_("Kurtosis")) \
- FS (SEKURT, N_("Standard error of the kurtosis")) \
- FS (MEDIAN, N_("Median")) \
- FS (SUM, N_("Sum"))
-
-enum
- {
-#define FS(NAME, LABEL) FS_##NAME,
- FREQUENCY_STATS
-#undef FS
- N_FREQUENCY_STATS
- };
-
-enum
- {
-#define FS(NAME, LABEL) B_FS_##NAME = 1u << FS_##NAME,
- FREQUENCY_STATS
-#undef FS
- B_FS_ALL = (1u << N_FREQUENCY_STATS) - 1,
- B_FS_DEFAULT = B_FS_MEAN | B_FS_STDDEV | B_FS_MINIMUM | B_FS_MAXIMUM
- };
-
-
-static const struct checkbox_entry_item stats[] =
- {
-#define FS(NAME, LABEL) {#NAME, LABEL},
- FREQUENCY_STATS
-#undef FS
- };
-
-
-
-enum frq_order
- {
- FRQ_AVALUE,
- FRQ_DVALUE,
- FRQ_ACOUNT,
- FRQ_DCOUNT
- };
-
-enum frq_table
- {
- FRQ_TABLE,
- FRQ_NOTABLE,
- FRQ_LIMIT
- };
-
-struct tables_options
-{
- enum frq_order order;
- enum frq_table table;
- int limit;
-};
-
-enum frq_scale
- {
- FRQ_FREQ,
- FRQ_PERCENT
- };
-
-struct charts_options
- {
- bool use_min;
- double min;
- bool use_max;
- double max;
- bool draw_hist;
- bool draw_normal;
- enum frq_scale scale;
- bool draw_pie;
- bool pie_include_missing;
- };
-
-struct frequencies_dialog
-{
- /* Main dialog. */
- GtkTreeView *stat_vars;
- PsppireDict *dict;
-
- GtkWidget *tables_button;
- GtkWidget *charts_button;
-
- GtkToggleButton *include_missing;
-
- GtkTreeModel *stats;
-
- /* Frequency Tables dialog. */
- GtkWidget *tables_dialog;
- struct tables_options tables_opts;
-
- GtkToggleButton *always;
- GtkToggleButton *never;
- GtkToggleButton *limit;
- GtkSpinButton *limit_spinbutton;
-
- GtkToggleButton *avalue;
- GtkToggleButton *dvalue;
- GtkToggleButton *afreq;
- GtkToggleButton *dfreq;
-
- /* Charts dialog. */
- GtkWidget *charts_dialog;
- struct charts_options charts_opts;
-
- GtkToggleButton *freqs;
- GtkToggleButton *percents;
-
- GtkToggleButton *min;
- GtkSpinButton *min_spin;
- GtkToggleButton *max;
- GtkSpinButton *max_spin;
-
- GtkToggleButton *hist;
- GtkToggleButton *normal;
-
- GtkToggleButton *pie;
- GtkToggleButton *pie_include_missing;
-};
-
-static void
-refresh (PsppireDialog *dialog, struct frequencies_dialog *fd)
-{
- GtkTreeIter iter;
- size_t i;
- bool ok;
-
- GtkTreeModel *liststore = gtk_tree_view_get_model (fd->stat_vars);
- gtk_list_store_clear (GTK_LIST_STORE (liststore));
-
- for (i = 0, ok = gtk_tree_model_get_iter_first (fd->stats, &iter); ok;
- i++, ok = gtk_tree_model_iter_next (fd->stats, &iter))
- gtk_list_store_set (GTK_LIST_STORE (fd->stats), &iter,
- CHECKBOX_COLUMN_SELECTED,
- (B_FS_DEFAULT & (1u << i)) ? true : false, -1);
-}
-
-static char *
-generate_syntax (const struct frequencies_dialog *fd)
-{
- GtkTreeIter iter;
- gboolean ok;
- gint i;
- guint selected = 0;
-
- gchar *text;
- GString *string = g_string_new ("FREQUENCIES");
-
- g_string_append (string, "\n\t/VARIABLES=");
- psppire_var_view_append_names (PSPPIRE_VAR_VIEW (fd->stat_vars), 0, string);
-
- g_string_append (string, "\n\t/FORMAT=");
-
- switch (fd->tables_opts.order)
- {
- case FRQ_AVALUE:
- g_string_append (string, "AVALUE");
- break;
- case FRQ_DVALUE:
- g_string_append (string, "DVALUE");
- break;
- case FRQ_ACOUNT:
- g_string_append (string, "AFREQ");
- break;
- case FRQ_DCOUNT:
- g_string_append (string, "DFREQ");
- break;
- default:
- g_assert_not_reached();
- }
-
- g_string_append (string, " ");
-
- switch (fd->tables_opts.table)
- {
- case FRQ_TABLE:
- g_string_append (string, "TABLE");
- break;
- case FRQ_NOTABLE:
- g_string_append (string, "NOTABLE");
- break;
- case FRQ_LIMIT:
- g_string_append_printf (string, "LIMIT (%d)", fd->tables_opts.limit);
- break;
- }
-
-
- for (i = 0, ok = gtk_tree_model_get_iter_first (fd->stats, &iter); ok;
- i++, ok = gtk_tree_model_iter_next (fd->stats, &iter))
- {
- gboolean toggled;
- gtk_tree_model_get (fd->stats, &iter,
- CHECKBOX_COLUMN_SELECTED, &toggled, -1);
- if (toggled)
- selected |= 1u << i;
- }
-
- if (selected != B_FS_DEFAULT)
- {
- g_string_append (string, "\n\t/STATISTICS=");
- if (selected == B_FS_ALL)
- g_string_append (string, "ALL");
- else if (selected == 0)
- g_string_append (string, "NONE");
- else
- {
- int n = 0;
- if ((selected & B_FS_DEFAULT) == B_FS_DEFAULT)
- {
- g_string_append (string, "DEFAULT");
- selected &= ~B_FS_DEFAULT;
- n++;
- }
- for (i = 0; i < N_FREQUENCY_STATS; i++)
- if (selected & (1u << i))
- {
- if (n++)
- g_string_append (string, " ");
- g_string_append (string, stats[i].name);
- }
- }
- }
-
- if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->include_missing)))
- g_string_append (string, "\n\t/MISSING=INCLUDE");
-
- if (fd->charts_opts.draw_hist)
- {
- g_string_append (string, "\n\t/HISTOGRAM=");
- g_string_append (string,
- fd->charts_opts.draw_normal ? "NORMAL" : "NONORMAL");
-
- if (fd->charts_opts.scale == FRQ_PERCENT)
- g_string_append (string, " PERCENT");
-
- if (fd->charts_opts.use_min)
- g_string_append_printf (string, " MIN(%.15g)", fd->charts_opts.min);
- if (fd->charts_opts.use_max)
- g_string_append_printf (string, " MAX(%.15g)", fd->charts_opts.max);
- }
-
- if (fd->charts_opts.draw_pie)
- {
- g_string_append (string, "\n\t/PIECHART=");
-
- if (fd->charts_opts.pie_include_missing)
- g_string_append (string, " MISSING");
-
- if (fd->charts_opts.use_min)
- g_string_append_printf (string, " MIN(%.15g)", fd->charts_opts.min);
- if (fd->charts_opts.use_max)
- g_string_append_printf (string, " MAX(%.15g)", fd->charts_opts.max);
- }
-
- g_string_append (string, ".\n");
-
- text = string->str;
-
- g_string_free (string, FALSE);
-
- return text;
-}
-
-/* Dialog is valid iff at least one variable has been selected */
-static gboolean
-dialog_state_valid (gpointer data)
-{
- struct frequencies_dialog *fd = data;
-
- GtkTreeModel *vars = gtk_tree_view_get_model (fd->stat_vars);
-
- GtkTreeIter notused;
-
- return gtk_tree_model_get_iter_first (vars, ¬used);
-}
-
-
-static void
-on_tables_clicked (struct frequencies_dialog *fd)
-{
- int ret;
-
- switch (fd->tables_opts.order)
- {
- case FRQ_AVALUE:
- gtk_toggle_button_set_active (fd->avalue, TRUE);
- break;
- case FRQ_DVALUE:
- gtk_toggle_button_set_active (fd->dvalue, TRUE);
- break;
- case FRQ_ACOUNT:
- gtk_toggle_button_set_active (fd->afreq, TRUE);
- break;
- case FRQ_DCOUNT:
- gtk_toggle_button_set_active (fd->dfreq, TRUE);
- break;
- };
-
- switch (fd->tables_opts.table)
- {
- case FRQ_TABLE:
- gtk_toggle_button_set_active (fd->always, TRUE);
- break;
- case FRQ_NOTABLE:
- gtk_toggle_button_set_active (fd->never, TRUE);
- break;
- case FRQ_LIMIT:
- gtk_toggle_button_set_active (fd->limit, TRUE);
- break;
- }
- gtk_spin_button_set_value (fd->limit_spinbutton,
- fd->tables_opts.limit);
- g_signal_emit_by_name (fd->limit, "toggled");
-
- ret = psppire_dialog_run (PSPPIRE_DIALOG (fd->tables_dialog));
-
- if ( ret == PSPPIRE_RESPONSE_CONTINUE )
- {
- if (gtk_toggle_button_get_active (fd->avalue))
- fd->tables_opts.order = FRQ_AVALUE;
- else if (gtk_toggle_button_get_active (fd->dvalue))
- fd->tables_opts.order = FRQ_DVALUE;
- else if (gtk_toggle_button_get_active (fd->afreq))
- fd->tables_opts.order = FRQ_ACOUNT;
- else if (gtk_toggle_button_get_active (fd->dfreq))
- fd->tables_opts.order = FRQ_DCOUNT;
-
- if (gtk_toggle_button_get_active (fd->always))
- fd->tables_opts.table = FRQ_TABLE;
- else if (gtk_toggle_button_get_active (fd->never))
- fd->tables_opts.table = FRQ_NOTABLE;
- else
- fd->tables_opts.table = FRQ_LIMIT;
-
- fd->tables_opts.limit = gtk_spin_button_get_value (fd->limit_spinbutton);
- }
-}
-
-static void
-on_charts_clicked (struct frequencies_dialog *fd)
-{
- int ret;
-
- gtk_toggle_button_set_active (fd->min, fd->charts_opts.use_min);
- gtk_spin_button_set_value (fd->min_spin, fd->charts_opts.min);
- g_signal_emit_by_name (fd->min, "toggled");
-
- gtk_toggle_button_set_active (fd->max, fd->charts_opts.use_max);
- gtk_spin_button_set_value (fd->max_spin, fd->charts_opts.max);
- g_signal_emit_by_name (fd->max, "toggled");
-
- gtk_toggle_button_set_active (fd->hist, fd->charts_opts.draw_hist);
- gtk_toggle_button_set_active (fd->normal, fd->charts_opts.draw_normal);
- g_signal_emit_by_name (fd->hist, "toggled");
-
- switch (fd->charts_opts.scale)
- {
- case FRQ_FREQ:
- gtk_toggle_button_set_active (fd->freqs, TRUE);
- break;
- case FRQ_DVALUE:
- gtk_toggle_button_set_active (fd->percents, TRUE);
- break;
- };
-
-
- gtk_toggle_button_set_active (fd->pie, fd->charts_opts.draw_pie);
- gtk_toggle_button_set_active (fd->pie_include_missing,
- fd->charts_opts.pie_include_missing);
- g_signal_emit_by_name (fd->pie, "toggled");
-
- ret = psppire_dialog_run (PSPPIRE_DIALOG (fd->charts_dialog));
-
- if ( ret == PSPPIRE_RESPONSE_CONTINUE )
- {
- fd->charts_opts.use_min = gtk_toggle_button_get_active (fd->min);
- fd->charts_opts.min = gtk_spin_button_get_value (fd->min_spin);
-
- fd->charts_opts.use_max = gtk_toggle_button_get_active (fd->max);
- fd->charts_opts.max = gtk_spin_button_get_value (fd->max_spin);
-
- fd->charts_opts.draw_hist = gtk_toggle_button_get_active (fd->hist);
- fd->charts_opts.draw_normal = gtk_toggle_button_get_active (fd->normal);
- if (gtk_toggle_button_get_active (fd->freqs))
- fd->charts_opts.scale = FRQ_FREQ;
- else if (gtk_toggle_button_get_active (fd->percents))
- fd->charts_opts.scale = FRQ_PERCENT;
-
- fd->charts_opts.draw_pie = gtk_toggle_button_get_active (fd->pie);
- fd->charts_opts.pie_include_missing
- = gtk_toggle_button_get_active (fd->pie_include_missing);
- }
-}
-
-
-/* Makes widget W's sensitivity follow the active state of TOGGLE */
-static void
-sensitive_if_active (GtkToggleButton *toggle, GtkWidget *w)
-{
- gboolean active = gtk_toggle_button_get_active (toggle);
-
- gtk_widget_set_sensitive (w, active);
-}
-
-/* Pops up the Frequencies dialog box */
-void
-frequencies_dialog (PsppireDataWindow *de)
-{
- gint response;
-
- struct frequencies_dialog fd;
-
- GtkBuilder *xml = builder_new ("frequencies.ui");
-
- GtkWidget *dialog = get_widget_assert (xml, "frequencies-dialog");
- GtkWidget *source = get_widget_assert (xml, "dict-treeview");
- GtkWidget *dest = get_widget_assert (xml, "var-treeview");
- GtkWidget *tables_button = get_widget_assert (xml, "tables-button");
- GtkWidget *charts_button = get_widget_assert (xml, "charts-button");
- GtkWidget *stats_treeview = get_widget_assert (xml, "stats-treeview");
-
- put_checkbox_items_in_treeview (GTK_TREE_VIEW(stats_treeview),
- B_FS_DEFAULT,
- N_FREQUENCY_STATS,
- stats
- );
-
-
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
-
- g_object_get (de->data_editor, "dictionary", &fd.dict, NULL);
- g_object_set (source, "model", fd.dict, NULL);
-
- fd.stat_vars = GTK_TREE_VIEW (dest);
- fd.tables_button = get_widget_assert (xml, "tables-button");
- fd.charts_button = get_widget_assert (xml, "charts-button");
-
- fd.include_missing = GTK_TOGGLE_BUTTON (
- get_widget_assert (xml, "include_missing"));
-
- fd.stats = gtk_tree_view_get_model (GTK_TREE_VIEW (stats_treeview));
-
- /* Frequency Tables dialog. */
- fd.tables_dialog = get_widget_assert (xml, "tables-dialog");
- fd.tables_opts.order = FRQ_AVALUE;
- fd.tables_opts.table = FRQ_TABLE;
- fd.tables_opts.limit = 50;
-
- fd.always = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "always"));
- fd.never = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "never"));
- fd.limit = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "limit"));
- fd.limit_spinbutton =
- GTK_SPIN_BUTTON (get_widget_assert (xml, "limit-spin"));
- g_signal_connect (fd.limit, "toggled",
- G_CALLBACK (sensitive_if_active), fd.limit_spinbutton);
-
- fd.avalue = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "avalue"));
- fd.dvalue = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "dvalue"));
- fd.afreq = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "afreq"));
- fd.dfreq = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "dfreq"));
-
- gtk_window_set_transient_for (GTK_WINDOW (fd.tables_dialog),
- GTK_WINDOW (de));
-
- /* Charts dialog. */
- fd.charts_dialog = get_widget_assert (xml, "charts-dialog");
- fd.charts_opts.use_min = false;
- fd.charts_opts.min = 0;
- fd.charts_opts.use_max = false;
- fd.charts_opts.max = 100;
- fd.charts_opts.draw_hist = false;
- fd.charts_opts.draw_normal = false;
- fd.charts_opts.scale = FRQ_FREQ;
- fd.charts_opts.draw_pie = false;
- fd.charts_opts.pie_include_missing = false;
-
- fd.freqs = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "freqs"));
- fd.percents = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "percents"));
-
- fd.min = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "min"));
- fd.min_spin = GTK_SPIN_BUTTON (get_widget_assert (xml, "min-spin"));
- g_signal_connect (fd.min, "toggled",
- G_CALLBACK (sensitive_if_active), fd.min_spin);
- fd.max = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "max"));
- fd.max_spin = GTK_SPIN_BUTTON (get_widget_assert (xml, "max-spin"));
- g_signal_connect (fd.max, "toggled",
- G_CALLBACK (sensitive_if_active), fd.max_spin);
-
- fd.hist = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "hist"));
- fd.normal = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "normal"));
- g_signal_connect (fd.hist, "toggled",
- G_CALLBACK (sensitive_if_active), fd.normal);
-
- fd.pie = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "pie"));
- fd.pie_include_missing = GTK_TOGGLE_BUTTON (
- get_widget_assert (xml, "pie-include-missing"));
- g_signal_connect (fd.pie, "toggled",
- G_CALLBACK (sensitive_if_active), fd.pie_include_missing);
-
- gtk_window_set_transient_for (GTK_WINDOW (fd.charts_dialog),
- GTK_WINDOW (de));
-
- /* Main dialog. */
- g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &fd);
-
- psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
- dialog_state_valid, &fd);
-
- g_signal_connect_swapped (tables_button, "clicked",
- G_CALLBACK (on_tables_clicked), &fd);
- g_signal_connect_swapped (charts_button, "clicked",
- G_CALLBACK (on_charts_clicked), &fd);
-
- response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
-
-
- switch (response)
- {
- case GTK_RESPONSE_OK:
- g_free (execute_syntax_string (de, generate_syntax (&fd)));
- break;
- case PSPPIRE_RESPONSE_PASTE:
- g_free (paste_syntax_to_window (generate_syntax (&fd)));
- break;
- default:
- break;
- }
-
- g_object_unref (xml);
-}
+++ /dev/null
-/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007, 2010 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
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef __FREQUENCIES_DIALOG_H
-#define __FREQUENCIES_DIALOG_H
-
-#include "psppire-data-window.h"
-
-void frequencies_dialog (PsppireDataWindow * data);
-
-#endif
#include "libpspp/str.h"
#include "ui/gui/aggregate-dialog.h"
#include "ui/gui/autorecode-dialog.h"
-#include "ui/gui/binomial-dialog.h"
#include "ui/gui/builder-wrapper.h"
#include "ui/gui/chi-square-dialog.h"
#include "ui/gui/comments-dialog.h"
#include "ui/gui/compute-dialog.h"
#include "ui/gui/count-dialog.h"
-#include "ui/gui/crosstabs-dialog.h"
#include "ui/gui/entry-dialog.h"
#include "ui/gui/executor.h"
-#include "ui/gui/frequencies-dialog.h"
#include "ui/gui/help-menu.h"
#include "ui/gui/helper.h"
#include "ui/gui/helper.h"
GCallback handler)
{
GtkAction *action = get_action_assert (dw->builder, action_name);
-
+
g_signal_connect_swapped (action, "activate", handler, dw);
return action;
}
+/* Only a data file with at least one variable can be saved. */
+static void
+enable_save (PsppireDataWindow *dw)
+{
+ gboolean enable = psppire_dict_get_var_cnt (dw->dict) > 0;
+
+ gtk_action_set_sensitive (get_action_assert (dw->builder, "file_save"),
+ enable);
+ gtk_action_set_sensitive (get_action_assert (dw->builder, "file_save_as"),
+ enable);
+}
+
/* Initializes as much of a PsppireDataWindow as we can and must before the
dataset has been set.
G_CALLBACK (on_split_change),
de);
+ g_signal_connect_swapped (de->dict, "backend-changed",
+ G_CALLBACK (enable_save), de);
+ g_signal_connect_swapped (de->dict, "variable-inserted",
+ G_CALLBACK (enable_save), de);
+ g_signal_connect_swapped (de->dict, "variable-deleted",
+ G_CALLBACK (enable_save), de);
+ enable_save (de);
connect_action (de, "file_new_data", G_CALLBACK (create_data_window));
connect_action (de, "transform_count", G_CALLBACK (count_dialog));
connect_action (de, "transform_recode-same", G_CALLBACK (recode_same_dialog));
connect_action (de, "transform_recode-different", G_CALLBACK (recode_different_dialog));
- connect_action (de, "analyze_frequencies", G_CALLBACK (frequencies_dialog));
- connect_action (de, "crosstabs", G_CALLBACK (crosstabs_dialog));
connect_action (de, "univariate", G_CALLBACK (univariate_dialog));
connect_action (de, "chi-square", G_CALLBACK (chisquare_dialog));
- connect_action (de, "binomial", G_CALLBACK (binomial_dialog));
connect_action (de, "runs", G_CALLBACK (runs_dialog));
connect_action (de, "ks-one-sample", G_CALLBACK (ks_one_sample_dialog));
connect_action (de, "k-related-samples", G_CALLBACK (k_related_dialog));
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+
+#include "psppire-dialog-action-binomial.h"
+#include "psppire-value-entry.h"
+
+#include "dialog-common.h"
+#include "helper.h"
+#include <ui/syntax-gen.h>
+#include "psppire-var-view.h"
+
+#include "psppire-dialog.h"
+#include "builder-wrapper.h"
+#include "checkbox-treeview.h"
+#include "psppire-dict.h"
+#include "libpspp/str.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+
+static void
+psppire_dialog_action_binomial_class_init (PsppireDialogActionBinomialClass *class);
+
+G_DEFINE_TYPE (PsppireDialogActionBinomial, psppire_dialog_action_binomial, PSPPIRE_TYPE_DIALOG_ACTION);
+
+
+static gboolean
+get_proportion (PsppireDialogActionBinomial *act, double *prop)
+{
+ const gchar *text = gtk_entry_get_text (GTK_ENTRY (act->prop_entry));
+ gchar *endptr = NULL;
+ *prop = g_strtod (text, &endptr);
+
+ if (endptr == text)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+dialog_state_valid (gpointer data)
+{
+ PsppireDialogActionBinomial *act = PSPPIRE_DIALOG_ACTION_BINOMIAL (data);
+ double prop;
+
+ GtkTreeModel *vars =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (act->var_view));
+
+ GtkTreeIter notused;
+
+ if ( !gtk_tree_model_get_iter_first (vars, ¬used) )
+ return FALSE;
+
+ if ( ! get_proportion (act, &prop))
+ return FALSE;
+
+ if (prop < 0 || prop > 1.0)
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+refresh (PsppireDialogAction *da)
+{
+ PsppireDialogActionBinomial *act = PSPPIRE_DIALOG_ACTION_BINOMIAL (da);
+ GtkTreeModel *liststore =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (act->var_view));
+
+ gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (act->button1), TRUE);
+
+ gtk_entry_set_text (GTK_ENTRY (act->prop_entry), "0.5");
+
+ gtk_entry_set_text (GTK_ENTRY (act->cutpoint_entry), "");
+}
+
+
+static void
+psppire_dialog_action_binomial_activate (GtkAction *a)
+{
+ PsppireDialogActionBinomial *act = PSPPIRE_DIALOG_ACTION_BINOMIAL (a);
+ PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
+
+ GtkBuilder *xml = builder_new ("binomial.ui");
+
+ pda->dialog = get_widget_assert (xml, "binomial-dialog");
+ pda->source = get_widget_assert (xml, "dict-view");
+
+ act->var_view = get_widget_assert (xml, "variables-treeview");
+ act->button1 = get_widget_assert (xml, "radiobutton3");
+ act->prop_entry = get_widget_assert (xml, "proportion-entry");
+
+ act->cutpoint_entry = get_widget_assert (xml, "cutpoint-entry");
+ act->cutpoint_button = get_widget_assert (xml, "radiobutton4");
+
+ g_object_unref (xml);
+
+
+ g_signal_connect (act->cutpoint_button, "toggled", G_CALLBACK (set_sensitivity_from_toggle),
+ act->cutpoint_entry);
+
+ psppire_dialog_action_set_refresh (pda, refresh);
+
+ psppire_dialog_action_set_valid_predicate (pda,
+ dialog_state_valid);
+
+ if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_binomial_parent_class)->activate)
+ PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_binomial_parent_class)->activate (pda);
+}
+
+
+
+static char *
+generate_syntax (PsppireDialogAction *a)
+{
+ PsppireDialogActionBinomial *scd = PSPPIRE_DIALOG_ACTION_BINOMIAL (a);
+ gchar *text = NULL;
+
+ double prop;
+ GString *string = g_string_new ("NPAR TEST\n\t/BINOMIAL");
+
+ if ( get_proportion (scd, &prop))
+ g_string_append_printf (string, "(%g)", prop);
+
+ g_string_append (string, " =");
+
+ psppire_var_view_append_names (PSPPIRE_VAR_VIEW (scd->var_view), 0, string);
+
+ if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->cutpoint_button)))
+ {
+ const gchar *cutpoint = gtk_entry_get_text (GTK_ENTRY (scd->cutpoint_entry));
+ g_string_append_printf (string, "(%s)", cutpoint);
+ }
+
+ g_string_append (string, ".\n");
+
+ text = string->str;
+
+ g_string_free (string, FALSE);
+
+ return text;
+}
+
+static void
+psppire_dialog_action_binomial_class_init (PsppireDialogActionBinomialClass *class)
+{
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+ action_class->activate = psppire_dialog_action_binomial_activate;
+
+ PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
+}
+
+
+static void
+psppire_dialog_action_binomial_init (PsppireDialogActionBinomial *act)
+{
+}
+
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-dialog-action.h"
+
+#ifndef __PSPPIRE_DIALOG_ACTION_BINOMIAL_H__
+#define __PSPPIRE_DIALOG_ACTION_BINOMIAL_H__
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL (psppire_dialog_action_binomial_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION_BINOMIAL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, PsppireDialogActionBinomial))
+
+#define PSPPIRE_DIALOG_ACTION_BINOMIAL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, \
+ PsppireDialogActionBinomialClass))
+
+
+#define PSPPIRE_IS_DIALOG_ACTION_BINOMIAL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL))
+
+#define PSPPIRE_IS_DIALOG_ACTION_BINOMIAL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL))
+
+
+#define PSPPIRE_DIALOG_ACTION_BINOMIAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, \
+ PsppireDialogActionBinomialClass))
+
+typedef struct _PsppireDialogActionBinomial PsppireDialogActionBinomial;
+typedef struct _PsppireDialogActionBinomialClass PsppireDialogActionBinomialClass;
+
+
+struct _PsppireDialogActionBinomial
+{
+ PsppireDialogAction parent;
+
+ /*< private >*/
+ gboolean dispose_has_run ;
+
+
+ GtkWidget *var_view;
+ GtkWidget *button1;
+ GtkWidget *prop_entry;
+
+ GtkWidget *cutpoint_entry;
+ GtkWidget *cutpoint_button;
+};
+
+
+struct _PsppireDialogActionBinomialClass
+{
+ PsppireDialogActionClass parent_class;
+};
+
+
+GType psppire_dialog_action_binomial_get_type (void) ;
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_BINOMIAL_H__ */
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+
+#include "psppire-dialog-action-crosstabs.h"
+#include "psppire-value-entry.h"
+
+#include "dialog-common.h"
+#include "helper.h"
+#include <ui/syntax-gen.h>
+#include "psppire-var-view.h"
+
+#include "psppire-dialog.h"
+#include "builder-wrapper.h"
+#include "checkbox-treeview.h"
+#include "psppire-dict.h"
+#include "libpspp/str.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+
+static void
+psppire_dialog_action_crosstabs_class_init (PsppireDialogActionCrosstabsClass *class);
+
+G_DEFINE_TYPE (PsppireDialogActionCrosstabs, psppire_dialog_action_crosstabs, PSPPIRE_TYPE_DIALOG_ACTION);
+
+static gboolean
+dialog_state_valid (gpointer data)
+{
+ PsppireDialogActionCrosstabs *cd = PSPPIRE_DIALOG_ACTION_CROSSTABS (data);
+
+ GtkTreeModel *row_vars = gtk_tree_view_get_model (GTK_TREE_VIEW (cd->dest_rows));
+ GtkTreeModel *col_vars = gtk_tree_view_get_model (GTK_TREE_VIEW (cd->dest_cols));
+
+ GtkTreeIter notused;
+
+ return (gtk_tree_model_get_iter_first (row_vars, ¬used)
+ && gtk_tree_model_get_iter_first (col_vars, ¬used));
+}
+
+static void
+refresh (PsppireDialogAction *rd_)
+{
+ PsppireDialogActionCrosstabs *cd = PSPPIRE_DIALOG_ACTION_CROSSTABS (rd_);
+
+ GtkTreeModel *liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (cd->dest_rows));
+ gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+ liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (cd->dest_cols));
+ gtk_list_store_clear (GTK_LIST_STORE (liststore));
+}
+
+#define CROSSTABS_STATS \
+ CS (CHISQ, N_("Chisq")) \
+ CS (PHI, N_("Phi")) \
+ CS (CC, N_("CC")) \
+ CS (LAMBDA, N_("Lambda")) \
+ CS (UC, N_("UC")) \
+ CS (BTAU, N_("BTau")) \
+ CS (CTAU, N_("CTau")) \
+ CS (RISK, N_("Risk")) \
+ CS (GAMMA, N_("Gamma")) \
+ CS (D, N_("D")) \
+ CS (KAPPA, N_("Kappa")) \
+ CS (ETA, N_("Eta")) \
+ CS (CORR, N_("Corr")) \
+ CS (STATS_NONE, N_("None"))
+
+
+#define CROSSTABS_CELLS \
+ CS (COUNT, N_("Count")) \
+ CS (ROW, N_("Row")) \
+ CS (COLUMN, N_("Column")) \
+ CS (TOTAL, N_("Total")) \
+ CS (EXPECTED, N_("Expected")) \
+ CS (RESIDUAL, N_("Residual")) \
+ CS (SRESIDUAL, N_("Std. Residual")) \
+ CS (ASRESIDUAL, N_("Adjusted Std. Residual")) \
+ CS (CELLS_NONE, N_("None"))
+
+enum
+ {
+#define CS(NAME, LABEL) CS_##NAME,
+ CROSSTABS_STATS
+#undef CS
+ N_CROSSTABS_STATS
+ };
+
+enum
+ {
+#define CS(NAME, LABEL) CS_##NAME,
+ CROSSTABS_CELLS
+#undef CS
+ N_CROSSTABS_CELLS
+ };
+
+enum
+ {
+#define CS(NAME, LABEL) B_CS_##NAME = 1u << CS_##NAME,
+ CROSSTABS_STATS
+ CROSSTABS_CELLS
+#undef CS
+ B_CS_STATS_ALL = (1u << N_CROSSTABS_STATS) - 1,
+ B_CS_CELLS_ALL = (1u << N_CROSSTABS_CELLS) - 1,
+ B_CS_STATS_DEFAULT = B_CS_CHISQ,
+ B_CS_CELL_DEFAULT = B_CS_COUNT | B_CS_ROW | B_CS_COLUMN | B_CS_TOTAL,
+ B_CS_NONE
+ };
+
+static const struct checkbox_entry_item stats[] =
+ {
+#define CS(NAME, LABEL) {#NAME, LABEL},
+ CROSSTABS_STATS \
+ CS(NONE, N_("None"))
+#undef CS
+ };
+
+static const struct checkbox_entry_item cells[] =
+ {
+#define CS(NAME, LABEL) {#NAME, LABEL},
+ CROSSTABS_CELLS \
+ CS(NONE, N_("None"))
+#undef CS
+ };
+
+static void
+on_format_clicked (PsppireDialogActionCrosstabs *cd)
+{
+ int ret;
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->avalue_button), cd->format_options_avalue);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->table_button), cd->format_options_table);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->pivot_button), cd->format_options_pivot);
+
+ ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->format_dialog));
+
+ if ( ret == PSPPIRE_RESPONSE_CONTINUE )
+ {
+ cd->format_options_avalue =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->avalue_button));
+
+ cd->format_options_table =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->table_button));
+
+ cd->format_options_pivot =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->pivot_button));
+ }
+}
+
+static void
+on_cell_clicked (PsppireDialogActionCrosstabs *cd)
+{
+ GtkListStore *liststore = clone_list_store (GTK_LIST_STORE (cd->cell));
+
+ gint ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->cell_dialog));
+
+ if ( ret == PSPPIRE_RESPONSE_CONTINUE )
+ {
+ g_object_unref (liststore);
+ }
+ else
+ {
+ gtk_tree_view_set_model (GTK_TREE_VIEW (cd->cell_view) , GTK_TREE_MODEL (liststore));
+ cd->cell = GTK_TREE_MODEL (liststore);
+ }
+}
+
+
+static void
+on_statistics_clicked (PsppireDialogActionCrosstabs *cd)
+{
+ GtkListStore *liststore = clone_list_store (GTK_LIST_STORE (cd->stat));
+
+ gint ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->stat_dialog));
+
+ if ( ret == PSPPIRE_RESPONSE_CONTINUE )
+ {
+ g_object_unref (liststore);
+ }
+ else
+ {
+ gtk_tree_view_set_model (GTK_TREE_VIEW (cd->stat_view) , GTK_TREE_MODEL (liststore));
+ cd->stat = GTK_TREE_MODEL (liststore);
+ }
+}
+
+
+static void
+psppire_dialog_action_crosstabs_activate (GtkAction *a)
+{
+ PsppireDialogActionCrosstabs *act = PSPPIRE_DIALOG_ACTION_CROSSTABS (a);
+ PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
+
+ GtkBuilder *xml = builder_new ("crosstabs.ui");
+
+ pda->dialog = get_widget_assert (xml, "crosstabs-dialog");
+ pda->source = get_widget_assert (xml, "dict-treeview");
+
+ act->dest_rows = get_widget_assert (xml, "rows");
+ act->dest_cols = get_widget_assert (xml, "cols");
+ act->format_button = get_widget_assert (xml, "format-button");
+ act->stat_button = get_widget_assert (xml, "stats-button");
+ act->cell_button = get_widget_assert (xml, "cell-button");
+ act->stat_view = get_widget_assert (xml, "stats-view");
+ act->cell_view = get_widget_assert (xml, "cell-view");
+ act->cell_dialog = get_widget_assert (xml, "cell-dialog");
+ act->stat_dialog = get_widget_assert (xml, "stat-dialog");
+ act->format_dialog = get_widget_assert (xml, "format-dialog");
+
+ act->avalue_button = get_widget_assert (xml, "ascending");
+ act->table_button = get_widget_assert (xml, "print-tables");
+ act->pivot_button = get_widget_assert (xml, "pivot");
+
+
+ g_object_unref (xml);
+
+ act->format_options_avalue = TRUE;
+ act->format_options_table = TRUE;
+ act->format_options_pivot = TRUE;
+
+ put_checkbox_items_in_treeview (GTK_TREE_VIEW (act->cell_view),
+ B_CS_CELL_DEFAULT,
+ N_CROSSTABS_CELLS,
+ cells
+ );
+
+ act->cell = gtk_tree_view_get_model (GTK_TREE_VIEW (act->cell_view));
+
+ put_checkbox_items_in_treeview (GTK_TREE_VIEW (act->stat_view),
+ B_CS_STATS_DEFAULT,
+ N_CROSSTABS_STATS,
+ stats
+ );
+
+ act->stat = gtk_tree_view_get_model (GTK_TREE_VIEW (act->stat_view));
+
+ psppire_dialog_action_set_refresh (pda, refresh);
+
+ psppire_dialog_action_set_valid_predicate (pda,
+ dialog_state_valid);
+
+ g_signal_connect_swapped (act->cell_button, "clicked",
+ G_CALLBACK (on_cell_clicked), act);
+
+ g_signal_connect_swapped (act->stat_button, "clicked",
+ G_CALLBACK (on_statistics_clicked), act);
+
+ g_signal_connect_swapped (act->format_button, "clicked",
+ G_CALLBACK (on_format_clicked), act);
+
+
+ if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_crosstabs_parent_class)->activate)
+ PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_crosstabs_parent_class)->activate (pda);
+}
+
+
+
+static char *
+generate_syntax (PsppireDialogAction *a)
+{
+ PsppireDialogActionCrosstabs *cd = PSPPIRE_DIALOG_ACTION_CROSSTABS (a);
+ gchar *text = NULL;
+ int i, n;
+ guint selected;
+ GString *string = g_string_new ("CROSSTABS ");
+ gboolean ok;
+ GtkTreeIter iter;
+
+ g_string_append (string, "\n\t/TABLES=");
+ psppire_var_view_append_names (PSPPIRE_VAR_VIEW (cd->dest_rows), 0, string);
+ g_string_append (string, "\tBY\t");
+ psppire_var_view_append_names (PSPPIRE_VAR_VIEW (cd->dest_cols), 0, string);
+
+
+ g_string_append (string, "\n\t/FORMAT=");
+
+ if (cd->format_options_avalue)
+ g_string_append (string, "AVALUE");
+ else
+ g_string_append (string, "DVALUE");
+ g_string_append (string, " ");
+
+ if (cd->format_options_table)
+ g_string_append (string, "TABLES");
+ else
+ g_string_append (string, "NOTABLES");
+ g_string_append (string, " ");
+
+ if (cd->format_options_pivot)
+ g_string_append (string, "PIVOT");
+ else
+ g_string_append (string, "NOPIVOT");
+
+
+ selected = 0;
+ for (i = 0, ok = gtk_tree_model_get_iter_first (cd->stat, &iter); ok;
+ i++, ok = gtk_tree_model_iter_next (cd->stat, &iter))
+ {
+ gboolean toggled;
+ gtk_tree_model_get (cd->stat, &iter,
+ CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+ if (toggled)
+ selected |= 1u << i;
+ else
+ selected &= ~(1u << i);
+ }
+
+ if (!(selected & (1u << CS_STATS_NONE)))
+ {
+ if (selected)
+ {
+ g_string_append (string, "\n\t/STATISTICS=");
+ n = 0;
+ for (i = 0; i < N_CROSSTABS_STATS; i++)
+ if (selected & (1u << i))
+ {
+ if (n++)
+ g_string_append (string, " ");
+ g_string_append (string, stats[i].name);
+ }
+ }
+ }
+
+ selected = 0;
+ for (i = 0, ok = gtk_tree_model_get_iter_first (cd->cell, &iter); ok;
+ i++, ok = gtk_tree_model_iter_next (cd->cell, &iter))
+ {
+ gboolean toggled;
+ gtk_tree_model_get (cd->cell, &iter,
+ CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+ if (toggled)
+ selected |= 1u << i;
+ else
+ selected &= ~(1u << i);
+ }
+
+
+
+ g_string_append (string, "\n\t/CELLS=");
+ if (selected & (1u << CS_CELLS_NONE))
+ g_string_append (string, "NONE");
+ else
+ {
+ n = 0;
+ for (i = 0; i < N_CROSSTABS_CELLS; i++)
+ if (selected & (1u << i))
+ {
+ if (n++)
+ g_string_append (string, " ");
+ g_string_append (string, cells[i].name);
+ }
+ }
+
+ g_string_append (string, ".\n");
+
+ text = string->str;
+
+ g_string_free (string, FALSE);
+
+ return text;
+}
+
+static void
+psppire_dialog_action_crosstabs_class_init (PsppireDialogActionCrosstabsClass *class)
+{
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+ action_class->activate = psppire_dialog_action_crosstabs_activate;
+
+ PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
+}
+
+
+static void
+psppire_dialog_action_crosstabs_init (PsppireDialogActionCrosstabs *act)
+{
+}
+
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-dialog-action.h"
+
+#ifndef __PSPPIRE_DIALOG_ACTION_CROSSTABS_H__
+#define __PSPPIRE_DIALOG_ACTION_CROSSTABS_H__
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS (psppire_dialog_action_crosstabs_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION_CROSSTABS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, PsppireDialogActionCrosstabs))
+
+#define PSPPIRE_DIALOG_ACTION_CROSSTABS_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, \
+ PsppireDialogActionCrosstabsClass))
+
+
+#define PSPPIRE_IS_DIALOG_ACTION_CROSSTABS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS))
+
+#define PSPPIRE_IS_DIALOG_ACTION_CROSSTABS_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS))
+
+
+#define PSPPIRE_DIALOG_ACTION_CROSSTABS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, \
+ PsppireDialogActionCrosstabsClass))
+
+typedef struct _PsppireDialogActionCrosstabs PsppireDialogActionCrosstabs;
+typedef struct _PsppireDialogActionCrosstabsClass PsppireDialogActionCrosstabsClass;
+
+
+struct _PsppireDialogActionCrosstabs
+{
+ PsppireDialogAction parent;
+
+ /*< private >*/
+ gboolean dispose_has_run ;
+
+ GtkWidget *col_vars;
+ GtkWidget *row_vars;
+
+ GtkWidget *dest_rows;
+ GtkWidget *dest_cols ;
+ GtkWidget *format_button ;
+ GtkWidget *stat_button ;
+ GtkWidget *cell_button ;
+
+ GtkWidget *stat_view ;
+
+ GtkWidget *cell_view ;
+ GtkTreeModel *cell ;
+ GtkWidget *cell_dialog ;
+ GtkTreeModel *stat;
+ GtkWidget *stat_dialog ;
+
+ gboolean format_options_avalue;
+ gboolean format_options_pivot;
+ gboolean format_options_table;
+
+ GtkWidget *table_button;
+ GtkWidget *pivot_button;
+
+ GtkWidget *format_dialog;
+ GtkWidget *avalue_button;
+};
+
+
+struct _PsppireDialogActionCrosstabsClass
+{
+ PsppireDialogActionClass parent_class;
+};
+
+
+GType psppire_dialog_action_crosstabs_get_type (void) ;
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_CROSSTABS_H__ */
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+Copyright (C) 2012 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+
+#include "psppire-dialog-action-frequencies.h"
+#include "psppire-value-entry.h"
+
+#include "dialog-common.h"
+#include "helper.h"
+#include <ui/syntax-gen.h>
+#include "psppire-var-view.h"
+
+#include "psppire-dialog.h"
+#include "builder-wrapper.h"
+#include "checkbox-treeview.h"
+#include "psppire-dict.h"
+#include "libpspp/str.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+
+#define FREQUENCY_STATS \
+ FS (MEAN, N_("Mean")) \
+ FS (STDDEV, N_("Standard deviation")) \
+ FS (MINIMUM, N_("Minimum")) \
+ FS (MAXIMUM, N_("Maximum")) \
+ FS (SEMEAN, N_("Standard error of the mean")) \
+ FS (VARIANCE, N_("Variance")) \
+ FS (SKEWNESS, N_("Skewness")) \
+ FS (SESKEW, N_("Standard error of the skewness")) \
+ FS (RANGE, N_("Range")) \
+ FS (MODE, N_("Mode")) \
+ FS (KURTOSIS, N_("Kurtosis")) \
+ FS (SEKURT, N_("Standard error of the kurtosis")) \
+ FS (MEDIAN, N_("Median")) \
+ FS (SUM, N_("Sum"))
+
+
+
+enum
+{
+#define FS(NAME, LABEL) FS_##NAME,
+ FREQUENCY_STATS
+#undef FS
+ N_FREQUENCY_STATS
+};
+
+enum
+{
+#define FS(NAME, LABEL) B_FS_##NAME = 1u << FS_##NAME,
+ FREQUENCY_STATS
+#undef FS
+ B_FS_ALL = (1u << N_FREQUENCY_STATS) - 1,
+ B_FS_DEFAULT = B_FS_MEAN | B_FS_STDDEV | B_FS_MINIMUM | B_FS_MAXIMUM
+};
+
+
+static const struct checkbox_entry_item stats[] = {
+#define FS(NAME, LABEL) {#NAME, LABEL},
+ FREQUENCY_STATS
+#undef FS
+};
+
+
+static void
+on_tables_clicked (PsppireDialogActionFrequencies * fd)
+{
+ int ret;
+
+ switch (fd->tables_opts_order)
+ {
+ case FRQ_AVALUE:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->avalue), TRUE);
+ break;
+ case FRQ_DVALUE:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->dvalue), TRUE);
+ break;
+ case FRQ_ACOUNT:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->afreq), TRUE);
+ break;
+ case FRQ_DCOUNT:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->dfreq), TRUE);
+ break;
+ };
+
+ switch (fd->tables_opts_table)
+ {
+ case FRQ_TABLE:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->always), TRUE);
+ break;
+ case FRQ_NOTABLE:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->never), TRUE);
+ break;
+ case FRQ_LIMIT:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->limit), TRUE);
+ break;
+ }
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (fd->limit_spinbutton),
+ fd->tables_opts_limit);
+
+ g_signal_emit_by_name (fd->limit, "toggled");
+
+ ret = psppire_dialog_run (PSPPIRE_DIALOG (fd->tables_dialog));
+
+ if (ret == PSPPIRE_RESPONSE_CONTINUE)
+ {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->avalue)))
+ fd->tables_opts_order = FRQ_AVALUE;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->dvalue)))
+ fd->tables_opts_order = FRQ_DVALUE;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->afreq)))
+ fd->tables_opts_order = FRQ_ACOUNT;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->dfreq)))
+ fd->tables_opts_order = FRQ_DCOUNT;
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->always)))
+ fd->tables_opts_table = FRQ_TABLE;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->never)))
+ fd->tables_opts_table = FRQ_NOTABLE;
+ else
+ fd->tables_opts_table = FRQ_LIMIT;
+
+
+ fd->tables_opts_limit =
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (fd->limit_spinbutton));
+ }
+}
+
+
+static void
+on_charts_clicked (PsppireDialogActionFrequencies *fd)
+{
+ int ret;
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->min), fd->charts_opts_use_min);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (fd->min_spin), fd->charts_opts_min);
+ g_signal_emit_by_name (fd->min, "toggled");
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->max), fd->charts_opts_use_max);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (fd->max_spin), fd->charts_opts_max);
+ g_signal_emit_by_name (fd->max, "toggled");
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->hist), fd->charts_opts_draw_hist);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->normal), fd->charts_opts_draw_normal);
+ g_signal_emit_by_name (fd->hist, "toggled");
+
+ switch (fd->charts_opts_scale)
+ {
+ case FRQ_FREQ:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->freqs), TRUE);
+ break;
+ case FRQ_DVALUE:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->percents), TRUE);
+ break;
+ };
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->pie), fd->charts_opts_draw_pie);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->pie_include_missing),
+ fd->charts_opts_pie_include_missing);
+
+ g_signal_emit_by_name (fd->pie, "toggled");
+
+ ret = psppire_dialog_run (PSPPIRE_DIALOG (fd->charts_dialog));
+
+ if ( ret == PSPPIRE_RESPONSE_CONTINUE )
+ {
+ fd->charts_opts_use_min = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->min));
+ fd->charts_opts_min = gtk_spin_button_get_value (GTK_SPIN_BUTTON (fd->min_spin));
+
+ fd->charts_opts_use_max = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->max));
+ fd->charts_opts_max = gtk_spin_button_get_value (GTK_SPIN_BUTTON (fd->max_spin));
+
+ fd->charts_opts_draw_hist = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->hist));
+ fd->charts_opts_draw_normal = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->normal));
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->freqs)))
+ fd->charts_opts_scale = FRQ_FREQ;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->percents)))
+ fd->charts_opts_scale = FRQ_PERCENT;
+
+ fd->charts_opts_draw_pie = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie));
+ fd->charts_opts_pie_include_missing
+ = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie_include_missing));
+ }
+}
+
+
+static void
+psppire_dialog_action_frequencies_class_init
+(PsppireDialogActionFrequenciesClass * class);
+
+G_DEFINE_TYPE (PsppireDialogActionFrequencies,
+ psppire_dialog_action_frequencies, PSPPIRE_TYPE_DIALOG_ACTION);
+
+static gboolean
+dialog_state_valid (gpointer data)
+{
+ PsppireDialogActionFrequencies *fd =
+ PSPPIRE_DIALOG_ACTION_FREQUENCIES (data);
+
+ GtkTreeModel *vars =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (fd->stat_vars));
+
+ GtkTreeIter notused;
+
+ return gtk_tree_model_get_iter_first (vars, ¬used);
+}
+
+static void
+refresh (PsppireDialogAction * fdx)
+{
+ PsppireDialogActionFrequencies *fd =
+ PSPPIRE_DIALOG_ACTION_FREQUENCIES (fdx);
+
+ GtkTreeIter iter;
+ size_t i;
+ bool ok;
+
+ GtkTreeModel *liststore =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (fd->stat_vars));
+ gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+ for (i = 0, ok = gtk_tree_model_get_iter_first (fd->stats, &iter); ok;
+ i++, ok = gtk_tree_model_iter_next (fd->stats, &iter))
+ gtk_list_store_set (GTK_LIST_STORE (fd->stats), &iter,
+ CHECKBOX_COLUMN_SELECTED,
+ (B_FS_DEFAULT & (1u << i)) ? true : false, -1);
+}
+
+
+
+static void
+psppire_dialog_action_frequencies_activate (GtkAction * a)
+{
+ PsppireDialogActionFrequencies *act = PSPPIRE_DIALOG_ACTION_FREQUENCIES (a);
+ PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
+
+ GtkBuilder *xml = builder_new ("frequencies.ui");
+
+ GtkWidget *stats_treeview = get_widget_assert (xml, "stats-treeview");
+ GtkWidget *tables_button = get_widget_assert (xml, "tables-button");
+ GtkWidget *charts_button = get_widget_assert (xml, "charts-button");
+
+ pda->dialog = get_widget_assert (xml, "frequencies-dialog");
+ pda->source = get_widget_assert (xml, "dict-treeview");
+
+ act->stat_vars = get_widget_assert (xml, "var-treeview");
+
+ put_checkbox_items_in_treeview (GTK_TREE_VIEW (stats_treeview),
+ B_FS_DEFAULT, N_FREQUENCY_STATS, stats);
+
+ act->stats = gtk_tree_view_get_model (GTK_TREE_VIEW (stats_treeview));
+
+ act->include_missing = get_widget_assert (xml, "include_missing");
+
+
+ act->tables_dialog = get_widget_assert (xml, "tables-dialog");
+ act->charts_dialog = get_widget_assert (xml, "charts-dialog");
+ act->always = get_widget_assert (xml, "always");
+ act->never = get_widget_assert (xml, "never");
+ act->limit = get_widget_assert (xml, "limit");
+ act->limit_spinbutton = get_widget_assert (xml, "limit-spin");
+
+ g_signal_connect (act->limit, "toggled",
+ G_CALLBACK (set_sensitivity_from_toggle),
+ act->limit_spinbutton);
+
+ act->avalue = get_widget_assert (xml, "avalue");
+ act->dvalue = get_widget_assert (xml, "dvalue");
+ act->afreq = get_widget_assert (xml, "afreq");
+ act->dfreq = get_widget_assert (xml, "dfreq");
+
+ act->charts_opts_use_min = false;
+ act->charts_opts_min = 0;
+ act->charts_opts_use_max = false;
+ act->charts_opts_max = 100;
+ act->charts_opts_draw_hist = false;
+ act->charts_opts_draw_normal = false;
+ act->charts_opts_scale = FRQ_FREQ;
+ act->charts_opts_draw_pie = false;
+ act->charts_opts_pie_include_missing = false;
+
+ act->freqs = get_widget_assert (xml, "freqs");
+ act->percents = get_widget_assert (xml, "percents");
+
+ act->min = get_widget_assert (xml, "min");
+ act->min_spin = get_widget_assert (xml, "min-spin");
+ g_signal_connect (act->min, "toggled",
+ G_CALLBACK (set_sensitivity_from_toggle), act->min_spin);
+ act->max = get_widget_assert (xml, "max");
+ act->max_spin = get_widget_assert (xml, "max-spin");
+ g_signal_connect (act->max, "toggled",
+ G_CALLBACK (set_sensitivity_from_toggle), act->max_spin);
+
+ act->hist = get_widget_assert (xml, "hist");
+ act->normal = get_widget_assert (xml, "normal");
+ g_signal_connect (act->hist, "toggled",
+ G_CALLBACK (set_sensitivity_from_toggle), act->normal);
+
+ act->pie = (get_widget_assert (xml, "pie"));
+ act->pie_include_missing = get_widget_assert (xml, "pie-include-missing");
+
+
+ g_object_unref (xml);
+
+
+ act->tables_opts_order = FRQ_AVALUE;
+ act->tables_opts_table = FRQ_TABLE;
+ act->tables_opts_limit = 50;
+
+ g_signal_connect_swapped (tables_button, "clicked",
+ G_CALLBACK (on_tables_clicked), act);
+
+ g_signal_connect_swapped (charts_button, "clicked",
+ G_CALLBACK (on_charts_clicked), act);
+
+ psppire_dialog_action_set_refresh (pda, refresh);
+
+ psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
+
+ if (PSPPIRE_DIALOG_ACTION_CLASS
+ (psppire_dialog_action_frequencies_parent_class)->activate)
+ PSPPIRE_DIALOG_ACTION_CLASS
+ (psppire_dialog_action_frequencies_parent_class)->activate (pda);
+}
+
+static char *
+generate_syntax (PsppireDialogAction * a)
+{
+ PsppireDialogActionFrequencies *fd = PSPPIRE_DIALOG_ACTION_FREQUENCIES (a);
+ gchar *text = NULL;
+ gint i;
+ gboolean ok;
+ GtkTreeIter iter;
+ guint selected = 0;
+
+ GString *string = g_string_new ("FREQUENCIES");
+
+ g_string_append (string, "\n\t/VARIABLES=");
+ psppire_var_view_append_names (PSPPIRE_VAR_VIEW (fd->stat_vars), 0, string);
+
+ g_string_append (string, "\n\t/FORMAT=");
+
+ switch (fd->tables_opts_order)
+ {
+ case FRQ_AVALUE:
+ g_string_append (string, "AVALUE");
+ break;
+ case FRQ_DVALUE:
+ g_string_append (string, "DVALUE");
+ break;
+ case FRQ_ACOUNT:
+ g_string_append (string, "AFREQ");
+ break;
+ case FRQ_DCOUNT:
+ g_string_append (string, "DFREQ");
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ g_string_append (string, " ");
+
+ switch (fd->tables_opts_table)
+ {
+ case FRQ_TABLE:
+ g_string_append (string, "TABLE");
+ break;
+ case FRQ_NOTABLE:
+ g_string_append (string, "NOTABLE");
+ break;
+ case FRQ_LIMIT:
+ g_string_append_printf (string, "LIMIT (%d)", fd->tables_opts_limit);
+ break;
+ }
+
+
+ for (i = 0, ok = gtk_tree_model_get_iter_first (fd->stats, &iter); ok;
+ i++, ok = gtk_tree_model_iter_next (fd->stats, &iter))
+ {
+ gboolean toggled;
+ gtk_tree_model_get (fd->stats, &iter,
+ CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+ if (toggled)
+ selected |= 1u << i;
+ }
+
+ if (selected != B_FS_DEFAULT)
+ {
+ g_string_append (string, "\n\t/STATISTICS=");
+ if (selected == B_FS_ALL)
+ g_string_append (string, "ALL");
+ else if (selected == 0)
+ g_string_append (string, "NONE");
+ else
+ {
+ int n = 0;
+ if ((selected & B_FS_DEFAULT) == B_FS_DEFAULT)
+ {
+ g_string_append (string, "DEFAULT");
+ selected &= ~B_FS_DEFAULT;
+ n++;
+ }
+ for (i = 0; i < N_FREQUENCY_STATS; i++)
+ if (selected & (1u << i))
+ {
+ if (n++)
+ g_string_append (string, " ");
+ g_string_append (string, stats[i].name);
+ }
+ }
+ }
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->include_missing)))
+ g_string_append (string, "\n\t/MISSING=INCLUDE");
+
+
+ if (fd->charts_opts_draw_hist)
+ {
+ g_string_append (string, "\n\t/HISTOGRAM=");
+ g_string_append (string,
+ fd->charts_opts_draw_normal ? "NORMAL" : "NONORMAL");
+
+ if (fd->charts_opts_scale == FRQ_PERCENT)
+ g_string_append (string, " PERCENT");
+
+ if (fd->charts_opts_use_min)
+ g_string_append_printf (string, " MIN(%.15g)", fd->charts_opts_min);
+ if (fd->charts_opts_use_max)
+ g_string_append_printf (string, " MAX(%.15g)", fd->charts_opts_max);
+ }
+
+ if (fd->charts_opts_draw_pie)
+ {
+ g_string_append (string, "\n\t/PIECHART=");
+
+ if (fd->charts_opts_pie_include_missing)
+ g_string_append (string, " MISSING");
+
+ if (fd->charts_opts_use_min)
+ g_string_append_printf (string, " MIN(%.15g)", fd->charts_opts_min);
+ if (fd->charts_opts_use_max)
+ g_string_append_printf (string, " MAX(%.15g)", fd->charts_opts_max);
+ }
+
+ g_string_append (string, ".\n");
+
+ text = string->str;
+
+ g_string_free (string, FALSE);
+
+ return text;
+}
+
+static void
+psppire_dialog_action_frequencies_class_init (PsppireDialogActionFrequenciesClass *class)
+{
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+ action_class->activate = psppire_dialog_action_frequencies_activate;
+
+ PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
+}
+
+
+static void
+psppire_dialog_action_frequencies_init (PsppireDialogActionFrequencies * act)
+{
+}
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-dialog-action.h"
+
+#ifndef __PSPPIRE_DIALOG_ACTION_FREQUENCIES_H__
+#define __PSPPIRE_DIALOG_ACTION_FREQUENCIES_H__
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES (psppire_dialog_action_frequencies_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION_FREQUENCIES(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \
+ PsppireDialogActionFrequencies))
+
+#define PSPPIRE_DIALOG_ACTION_FREQUENCIES_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \
+ PsppireDialogActionFrequenciesClass))
+
+
+#define PSPPIRE_IS_DIALOG_ACTION_FREQUENCIES(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES))
+
+#define PSPPIRE_IS_DIALOG_ACTION_FREQUENCIES_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES))
+
+
+#define PSPPIRE_DIALOG_ACTION_FREQUENCIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \
+ PsppireDialogActionFrequenciesClass))
+
+typedef struct _PsppireDialogActionFrequencies PsppireDialogActionFrequencies;
+typedef struct _PsppireDialogActionFrequenciesClass PsppireDialogActionFrequenciesClass;
+
+
+enum frq_scale
+ {
+ FRQ_FREQ,
+ FRQ_PERCENT
+ };
+
+enum frq_order
+ {
+ FRQ_AVALUE,
+ FRQ_DVALUE,
+ FRQ_ACOUNT,
+ FRQ_DCOUNT
+ };
+
+enum frq_table
+ {
+ FRQ_TABLE,
+ FRQ_NOTABLE,
+ FRQ_LIMIT
+ };
+
+
+struct _PsppireDialogActionFrequencies
+{
+ PsppireDialogAction parent;
+
+ /*< private >*/
+ gboolean dispose_has_run ;
+
+ GtkWidget *stat_vars;
+ GtkTreeModel *stats;
+
+ GtkWidget *include_missing;
+
+ enum frq_order tables_opts_order;
+ enum frq_table tables_opts_table;
+ gint tables_opts_limit;
+
+ GtkWidget * always;
+ GtkWidget * never;
+ GtkWidget * limit;
+ GtkWidget * limit_spinbutton;
+
+ GtkWidget * avalue;
+ GtkWidget * dvalue;
+ GtkWidget * afreq;
+ GtkWidget * dfreq;
+
+ GtkWidget *tables_dialog;
+
+ /* Charts dialog */
+
+ GtkWidget *min;
+ GtkWidget *min_spin;
+ GtkWidget *max;
+ GtkWidget *max_spin;
+
+ GtkWidget *hist;
+ GtkWidget *normal;
+
+ gboolean charts_opts_use_min;
+ gdouble charts_opts_min;
+
+ gboolean charts_opts_use_max;
+ gdouble charts_opts_max;
+
+ gboolean charts_opts_draw_hist;
+ gboolean charts_opts_draw_normal;
+
+ gboolean charts_opts_draw_pie;
+ gboolean charts_opts_pie_include_missing;
+
+
+ enum frq_scale charts_opts_scale;
+
+ GtkWidget *freqs;
+ GtkWidget *percents;
+ GtkWidget *pie;
+ GtkWidget *pie_include_missing;
+
+ GtkWidget *charts_dialog;
+};
+
+
+struct _PsppireDialogActionFrequenciesClass
+{
+ PsppireDialogActionClass parent_class;
+};
+
+
+GType psppire_dialog_action_frequencies_get_type (void) ;
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_FREQUENCIES_H__ */
G_DEFINE_TYPE (PsppireDialogActionLogistic, psppire_dialog_action_logistic, PSPPIRE_TYPE_DIALOG_ACTION);
-static void
-set_sensitivity_from_toggle (GtkToggleButton *togglebutton, gpointer data)
-{
- GtkWidget *w = data;
- gboolean active = gtk_toggle_button_get_active (togglebutton);
-
- gtk_widget_set_sensitive (w, active);
-}
-
-
static gboolean
dialog_state_valid (gpointer data)
{
#include <config.h>
#include <gtk/gtk.h>
+#include "dialog-common.h"
#include "psppire-val-chooser.h"
#include "libpspp/str.h"
{N_("_All other values"), NULL, else_set }
};
-static void
-set_sensitivity_from_toggle (GtkToggleButton *togglebutton, GtkWidget *w)
-{
- gboolean active = gtk_toggle_button_get_active (togglebutton);
-
- gtk_widget_set_sensitive (w, active);
-}
-
static void
psppire_val_chooser_init (PsppireValChooser *vr)
{
static char * generate_syntax (const struct runs *rd);
-/* Makes widget W's sensitivity follow the active state of TOGGLE */
-static void
-sensitive_if_active (GtkToggleButton *toggle, GtkWidget *w)
-{
- gboolean active = gtk_toggle_button_get_active (toggle);
-
- gtk_widget_set_sensitive (w, active);
-}
-
static void
refresh (struct runs *fd)
{
NULL);
g_signal_connect (fd.cb[CB_CUSTOM], "toggled",
- G_CALLBACK (sensitive_if_active), fd.entry);
+ G_CALLBACK (set_sensitivity_from_toggle), fd.entry);
psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
dialog_state_valid, &fd);
static gchar * generate_syntax (const struct select_cases_dialog *scd);
-static void
-set_sensitivity_from_toggle (GtkToggleButton *togglebutton, gpointer data)
-{
- GtkWidget *w = data;
- gboolean active = gtk_toggle_button_get_active (togglebutton);
-
- gtk_widget_set_sensitive (w, active);
-}
-
-static void
-set_sensitivity_from_toggle_invert (GtkToggleButton *togglebutton,
- gpointer data)
-{
- GtkWidget *w = data;
- gboolean active = gtk_toggle_button_get_active (togglebutton);
-
- gtk_widget_set_sensitive (w, !active);
-}
-
-
-
static const gchar label1[]=N_("Approximately %3d%% of all cases.");
static const gchar label2[]=N_("Exactly %3d cases from the first %3d cases.");
#include "psppire-var-view.h"
#include "psppire-val-chooser.h"
+#include "psppire-dialog-action-binomial.h"
#include "psppire-dialog-action-correlation.h"
+#include "psppire-dialog-action-crosstabs.h"
#include "psppire-dialog-action-descriptives.h"
#include "psppire-dialog-action-examine.h"
#include "psppire-dialog-action-factor.h"
+#include "psppire-dialog-action-frequencies.h"
#include "psppire-dialog-action-indep-samps.h"
#include "psppire-dialog-action-kmeans.h"
+#include "psppire-dialog-action-logistic.h"
#include "psppire-dialog-action-means.h"
#include "psppire-means-layer.h"
#include "psppire-dialog-action-rank.h"
psppire_var_view_get_type ();
psppire_value_entry_get_type ();
+ psppire_dialog_action_binomial_get_type ();
psppire_dialog_action_correlation_get_type ();
+ psppire_dialog_action_crosstabs_get_type ();
psppire_dialog_action_descriptives_get_type ();
psppire_dialog_action_examine_get_type ();
psppire_dialog_action_factor_get_type ();
+ psppire_dialog_action_frequencies_get_type ();
psppire_dialog_action_logistic_get_type ();
psppire_dialog_action_kmeans_get_type ();
psppire_dialog_action_means_get_type ();
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-2000, 2006-2007, 2009-2012 Free Software Foundation, Inc.
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
#include "math/random.h"
#include "output/driver.h"
#include "output/message-item.h"
-#include "ui/debugger.h"
#include "ui/source-init-opts.h"
#include "ui/terminal/terminal-opts.h"
#include "ui/terminal/terminal-reader.h"
recurse. */
signal (sig, SIG_DFL);
-#if DEBUGGING
- connect_debugger ();
-#endif
switch (sig)
{
case SIGABRT:
])
AT_CLEANUP
+
AT_SETUP([DATA LIST LIST with explicit delimiters])
AT_DATA([data-list.pspp], [dnl
data list list ('|','X') /A B C D.
1 12 123 1234 12345 .
])
AT_CLEANUP
+
+AT_SETUP([DATA LIST FREE and LIST report missing delimiters])
+AT_DATA([data-list.sps], [dnl
+DATA LIST FREE NOTABLE/s (a10).
+LIST.
+BEGIN DATA.
+'y'z
+END DATA.
+])
+AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl
+data-list.sps:4: warning: Missing delimiter following quoted string.
+
+Table: Data List
+s
+y @&t@
+z @&t@
+])
+AT_CLEANUP
+
+AT_SETUP([DATA LIST FREE and LIST assume a width if omitted])
+AT_DATA([data-list.sps], [dnl
+DATA LIST FREE TABLE/s (a) d (datetime) f (f).
+])
+AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl
+Table: Reading free-form data from INLINE.
+Variable,Format
+s,A1
+d,DATETIME17.0
+f,F1.0
+])
+AT_CLEANUP
[[any('a', 'a ', 'b', 'c')], [true]],
[[any('b ', 'a', 'b', 'c')], [true]],
[[any('c ', 'a', 'b', 'c ')], [true]],
- [[any(a, 'b', 'c', 'd')], [error],
+ [[any(a10, 'b', 'c', 'd')], [error],
[error: DEBUG EVALUATE: Function invocation any(format, string, string, string) does not match any known function. Candidates are:
ANY(number, number[, number]...)
ANY(string, string[, string]...).]],
[[datediff(date.mdy(7,18,2094), date.mdy(11,10,2038), 'quarters')], [222.00]],
[[datediff(date.mdy(2,29,1904), date.mdy(2,29,1900), 'quarters')], [15.00]],
[[datediff(date.mdy(2,29,1908), date.mdy(2,29,1904), 'quarters')], [16.00]],
- [[datediff(date.mdy(2,28,1903), date.mdy(2,29,1900), 'quarters')], [11.00]])
+ [[datediff(date.mdy(2,28,1903), date.mdy(2,29,1900), 'quarters')], [11.00]],
+
+dnl time of day is significant for DATEDIFF
+ [[datediff(date.mdy(10,15,1910) + 234, date.mdy(10,10,1910) + 123, 'days')],
+ [5.00]],
+ [[datediff(date.mdy(10,15,1910) + 123, date.mdy(10,10,1910) + 234, 'days')],
+ [4.00]],
+ [[datediff(date.mdy(10,24,1910) + 234, date.mdy(10,10,1910) + 123, 'weeks')],
+ [2.00]],
+ [[datediff(date.mdy(10,24,1910) + 123, date.mdy(10,10,1910) + 234, 'weeks')],
+ [1.00]],
+ [[datediff(date.mdy(10,10,1910) + 234, date.mdy(5,10,1910) + 123, 'months')],
+ [5.00]],
+ [[datediff(date.mdy(10,10,1910) + 123, date.mdy(5,10,1910) + 234, 'months')],
+ [4.00]],
+ [[datediff(date.mdy(5,10,1919) + 234, date.mdy(5,10,1910) + 123, 'years')],
+ [9.00]],
+ [[datediff(date.mdy(5,10,1919) + 123, date.mdy(5,10,1910) + 234, 'years')],
+ [8.00]],
+
+ [[datediff(date.mdy(10,10,1910) + 123, date.mdy(10,15,1910) + 234, 'days')],
+ [-5.00]],
+ [[datediff(date.mdy(10,10,1910) + 234, date.mdy(10,15,1910) + 123, 'days')],
+ [-4.00]],
+ [[datediff(date.mdy(10,10,1910) + 123, date.mdy(10,24,1910) + 234, 'weeks')],
+ [-2.00]],
+ [[datediff(date.mdy(10,10,1910) + 234, date.mdy(10,24,1910) + 123, 'weeks')],
+ [-1.00]],
+ [[datediff(date.mdy(5,10,1910) + 123, date.mdy(10,10,1910) + 234, 'months')],
+ [-5.00]],
+ [[datediff(date.mdy(5,10,1910) + 234, date.mdy(10,10,1910) + 123, 'months')],
+ [-4.00]],
+ [[datediff(date.mdy(5,10,1910) + 123, date.mdy(5,10,1919) + 234, 'years')],
+ [-9.00]],
+ [[datediff(date.mdy(5,10,1910) + 234, date.mdy(5,10,1919) + 123, 'years')],
+ [-8.00]])
CHECK_EXPR_EVAL([datesum],
dnl DATESUM with non-leap year
[[ctime.days(datesum(date.mdy(6,10,1648), 1, 'hours') - date.mdy(6,10,1648))], [0.04]],
[[ctime.days(datesum(date.mdy(6,30,1680), 2.5, 'hours') - date.mdy(6,30,1680))], [0.10]],
[[ctime.days(datesum(date.mdy(6,19,1768), -4, 'hours') - date.mdy(6,19,1768))], [-0.17]],
- [[ctime.days(datesum(date.mdy(8,2,1819), 5, 'hours') - date.mdy(8,2,1819))], [0.21]])
+ [[ctime.days(datesum(date.mdy(8,2,1819), 5, 'hours') - date.mdy(8,2,1819))], [0.21]],
+
+dnl DATESUM preserves time-of-day for units of days and longer.
+ [[ctime.days(datesum(date.mdy(8,2,1819) + time.hms(1,2,3), 5, 'days') - (date.mdy(8,2,1819) + time.hms(1,2,3)))], [5.00]],
+ [[ctime.days(datesum(date.mdy(8,2,1819) + time.hms(1,2,3), 5, 'weeks') - (date.mdy(8,2,1819) + time.hms(1,2,3)))], [35.00]],
+ [[ctime.days(datesum(date.mdy(8,2,1819) + time.hms(1,2,3), 5, 'months') - (date.mdy(8,2,1819) + time.hms(1,2,3)))], [153.00]],
+ [[ctime.days(datesum(date.mdy(8,2,1819) + time.hms(1,2,3), 5, 'years') - (date.mdy(8,2,1819) + time.hms(1,2,3)))], [1827.00]])
CHECK_EXPR_EVAL([miscellaneous],
dnl These test values are from Applied Statistics, Algorithm AS 310.
Table: X * Yabbadabbadoo [[count]].
,Yabbadabbadoo,,,,,,,
X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
-1.00,.0,.0,.0,.0,.0,.0,.0,.0
-2.00,.0,.0,.0,.0,.0,.0,.0,.0
-3.00,.0,.0,.0,.0,.0,.0,.0,.0
-4.00,.0,.0,.0,.0,1.0,.0,.0,1.0
-5.00,.0,.0,.0,.0,.0,.0,.0,.0
-6.00,.0,.0,.0,.0,.0,.0,.0,.0
-7.00,.0,.0,.0,.0,.0,.0,.0,.0
-Total,.0,.0,.0,.0,1.0,.0,.0,1.0
+1.00,.00,.00,.00,.00,.00,.00,.00,.00
+2.00,.00,.00,.00,.00,.00,.00,.00,.00
+3.00,.00,.00,.00,.00,.00,.00,.00,.00
+4.00,.00,.00,.00,.00,1.00,.00,.00,1.00
+5.00,.00,.00,.00,.00,.00,.00,.00,.00
+6.00,.00,.00,.00,.00,.00,.00,.00,.00
+7.00,.00,.00,.00,.00,.00,.00,.00,.00
+Total,.00,.00,.00,.00,1.00,.00,.00,1.00
])
AT_CLEANUP
Table: X * Y [count].
,Y,,,,,,,
X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
-1.00,.0,.0,.0,.0,.0,.0,.0,.0
-2.00,.0,.0,.0,.0,.0,.0,.0,.0
-3.00,.0,.0,.0,.0,.0,.0,.0,.0
-4.00,.0,.0,.0,.0,1.0,.0,.0,1.0
-5.00,.0,.0,.0,.0,.0,.0,.0,.0
-6.00,.0,.0,.0,.0,.0,.0,.0,.0
-7.00,.0,.0,.0,.0,.0,.0,.0,.0
-Total,.0,.0,.0,.0,1.0,.0,.0,1.0
+1.00,.00,.00,.00,.00,.00,.00,.00,.00
+2.00,.00,.00,.00,.00,.00,.00,.00,.00
+3.00,.00,.00,.00,.00,.00,.00,.00,.00
+4.00,.00,.00,.00,.00,1.00,.00,.00,1.00
+5.00,.00,.00,.00,.00,.00,.00,.00,.00
+6.00,.00,.00,.00,.00,.00,.00,.00,.00
+7.00,.00,.00,.00,.00,.00,.00,.00,.00
+Total,.00,.00,.00,.00,1.00,.00,.00,1.00
]])
AT_CLEANUP
x,F8.0
y,A18
-"crosstabs.sps:4: warning: BEGIN DATA: Missing value(s) for all variables from x onward. These will be filled with the system-missing value or blanks, as appropriate."
+"crosstabs.sps:4: warning: Missing value(s) for all variables from x onward. These will be filled with the system-missing value or blanks, as appropriate."
-"crosstabs.sps:6: warning: BEGIN DATA: Missing value(s) for all variables from x onward. These will be filled with the system-missing value or blanks, as appropriate."
+"crosstabs.sps:6: warning: Missing value(s) for all variables from x onward. These will be filled with the system-missing value or blanks, as appropriate."
Table: Summary.
,Cases,,,,,
Table: x * y [count].
,y,,,,
x,one unity ,three lots ,two duality ,zero none ,Total
-1.00,1.0,.0,.0,1.0,2.0
-2.00,.0,.0,1.0,.0,1.0
-3.00,.0,1.0,.0,.0,1.0
-Total,1.0,1.0,1.0,1.0,4.0
+1.00,1.00,.00,.00,1.00,2.00
+2.00,.00,.00,1.00,.00,1.00
+3.00,.00,1.00,.00,.00,1.00
+Total,1.00,1.00,1.00,1.00,4.00
]])
AT_CLEANUP
Table: y * z [count].
,z,,
y,1,2,Total
-1,4.0,3.0,7.0
-2,1.0,1.0,2.0
-Total,5.0,4.0,9.0
+1,4.00,3.00,7.00
+2,1.00,1.00,2.00
+Total,5.00,4.00,9.00
]])
AT_CLEANUP
Table: x * y [count].
,y,,
x,1.00,2.00,Total
-2.00,.0,1.0,1.0
-3.00,1.0,.0,1.0
-4.00,1.0,1.0,2.0
-Total,2.0,2.0,4.0
+2.00,.00,1.00,1.00
+3.00,1.00,.00,1.00
+4.00,1.00,1.00,2.00
+Total,2.00,2.00,4.00
Table: Chi-square tests.
Statistic,Value,df,Asymp. Sig. (2-tailed)
"Table: v1 * v2 [count, row %, column %, total %]."
,v2,,
v1,e ,f ,Total
-c ,3.0,1.0,4.0
-,75.0%,25.0%,100.0%
-,75.0%,50.0%,66.7%
-,50.0%,16.7%,66.7%
-d ,1.0,1.0,2.0
-,50.0%,50.0%,100.0%
-,25.0%,50.0%,33.3%
-,16.7%,16.7%,33.3%
-Total,4.0,2.0,6.0
-,66.7%,33.3%,100.0%
-,100.0%,100.0%,100.0%
-,66.7%,33.3%,100.0%
+c ,3.00,1.00,4.00
+,75.00%,25.00%,100.00%
+,75.00%,50.00%,66.67%
+,50.00%,16.67%,66.67%
+d ,1.00,1.00,2.00
+,50.00%,50.00%,100.00%
+,25.00%,50.00%,33.33%
+,16.67%,16.67%,33.33%
+Total,4.00,2.00,6.00
+,66.67%,33.33%,100.00%
+,100.00%,100.00%,100.00%
+,66.67%,33.33%,100.00%
Table: Chi-square tests.
Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
"Table: v1 * v2 [count, row %, column %, total %]."
,v2,,
v1,e ,f ,Total
-c ,.0,1.0,1.0
-,.0%,100.0%,100.0%
-,.0%,33.3%,25.0%
-,.0%,25.0%,25.0%
-d ,1.0,2.0,3.0
-,33.3%,66.7%,100.0%
-,100.0%,66.7%,75.0%
-,25.0%,50.0%,75.0%
-Total,1.0,3.0,4.0
-,25.0%,75.0%,100.0%
-,100.0%,100.0%,100.0%
-,25.0%,75.0%,100.0%
+c ,.00,1.00,1.00
+,.00%,100.00%,100.00%
+,.00%,33.33%,25.00%
+,.00%,25.00%,25.00%
+d ,1.00,2.00,3.00
+,33.33%,66.67%,100.00%
+,100.00%,66.67%,75.00%
+,25.00%,50.00%,75.00%
+Total,1.00,3.00,4.00
+,25.00%,75.00%,100.00%
+,100.00%,100.00%,100.00%
+,25.00%,75.00%,100.00%
Table: Chi-square tests.
Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
Table: x * y * z [count].
z,,y,,
,x,1,2,Total
-1,1,1.0,.0,1.0
-,3,1.0,.0,1.0
-,5,.0,1.0,1.0
-,7,1.0,.0,1.0
-,8,1.0,.0,1.0
-Total,,4.0,1.0,5.0
-2,2,.0,1.0,1.0
-,4,1.0,.0,1.0
-,6,1.0,.0,1.0
-,9,1.0,.0,1.0
-Total,,3.0,1.0,4.0
+1,1,1.00,.00,1.00
+,3,1.00,.00,1.00
+,5,.00,1.00,1.00
+,7,1.00,.00,1.00
+,8,1.00,.00,1.00
+Total,,4.00,1.00,5.00
+2,2,.00,1.00,1.00
+,4,1.00,.00,1.00
+,6,1.00,.00,1.00
+,9,1.00,.00,1.00
+Total,,3.00,1.00,4.00
Table: Chi-square tests.
z,Statistic,Value,df,Asymp. Sig. (2-tailed)
Table: x * y [count].
,y,,
x,2.00,1.00,Total
-4.00,.0,1.0,1.0
-3.00,2.0,1.0,3.0
-2.00,2.0,.0,2.0
-Total,4.0,2.0,6.0
+4.00,.00,1.00,1.00
+3.00,2.00,1.00,3.00
+2.00,2.00,.00,2.00
+Total,4.00,2.00,6.00
]])
AT_CLEANUP
abc,6,3.00,.84,2.00,4.00
])
AT_CLEANUP
+
+AT_SETUP([DESCRIPTIVES -- Z scores])
+AT_DATA([descriptives.sps], [dnl
+DATA LIST LIST NOTABLE /a b.
+BEGIN DATA.
+1 50
+2 60
+3 70
+END DATA.
+
+DESCRIPTIVES /VAR=a b /SAVE.
+LIST.
+])
+AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
+Table: Mapping of variables to corresponding Z-scores.
+Source,Target
+a,Za
+b,Zb
+
+Table: Valid cases = 3; cases with missing value(s) = 0.
+Variable,N,Mean,Std Dev,Minimum,Maximum
+a,3,2.00,1.00,1.00,3.00
+b,3,60.00,10.00,50.00,70.00
+
+Table: Data List
+a,b,Za,Zb
+1.00,50.00,-1.00,-1.00
+2.00,60.00,.00,.00
+3.00,70.00,1.00,1.00
+])
+AT_CLEANUP
+
+AT_SETUP([DESCRIPTIVES -- Z scores with SPLIT FILE])
+AT_DATA([descriptives.sps], [dnl
+DATA LIST LIST NOTABLE /group a b.
+BEGIN DATA.
+1 1 50
+1 2 60
+1 3 70
+2 100 6000
+2 200 7000
+2 400 9000
+2 500 10000
+END DATA.
+
+SPLIT FILE BY group.
+DESCRIPTIVES /VAR=a b /SAVE.
+LIST.
+])
+AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
+Table: Mapping of variables to corresponding Z-scores.
+Source,Target
+a,Za
+b,Zb
+
+Variable,Value,Label
+group,1.00,
+
+Table: Valid cases = 3; cases with missing value(s) = 0.
+Variable,N,Mean,Std Dev,Minimum,Maximum
+a,3,2.00,1.00,1.00,3.00
+b,3,60.00,10.00,50.00,70.00
+
+Variable,Value,Label
+group,2.00,
+
+Table: Valid cases = 4; cases with missing value(s) = 0.
+Variable,N,Mean,Std Dev,Minimum,Maximum
+a,4,300.00,182.57,100.00,500.00
+b,4,8000.00,1825.74,6000.00,10000.00
+
+Variable,Value,Label
+group,1.00,
+
+Table: Data List
+group,a,b,Za,Zb
+1.00,1.00,50.00,-1.00,-1.00
+1.00,2.00,60.00,.00,.00
+1.00,3.00,70.00,1.00,1.00
+
+Variable,Value,Label
+group,2.00,
+
+Table: Data List
+group,a,b,Za,Zb
+2.00,100.00,6000.00,-1.10,-1.10
+2.00,200.00,7000.00,-.55,-.55
+2.00,400.00,9000.00,.55,.55
+2.00,500.00,10000.00,1.10,1.10
+])
+AT_CLEANUP
])
AT_CLEANUP
+
+
+dnl Test for a bug which caused binomial to crash.
+AT_SETUP([NPAR TESTS BINOMIAL - crash])
+AT_DATA([nparX.sps], [dnl
+data list list /range *.
+begin data.
+0
+1
+end data.
+
+* This is invalid syntax
+NPAR TEST
+ /BINOMIAL(0.5) = Range().
+
+])
+AT_CHECK([pspp -O format=csv nparX.sps], [1], [ignore])
+
+AT_CLEANUP
+
+
+
AT_SETUP([NPAR TESTS CHISQUARE])
AT_DATA([npar.sps], [dnl
DATA LIST NOTABLE LIST /x * y * w *.
LIST.
])
AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
-"rank.sps:3: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
+"rank.sps:3: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
-"rank.sps:4: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
+"rank.sps:4: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
-"rank.sps:5: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
+"rank.sps:5: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
-"rank.sps:6: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
+"rank.sps:6: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
-"rank.sps:7: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
+"rank.sps:7: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
-"rank.sps:8: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
+"rank.sps:8: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
-"rank.sps:9: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
+"rank.sps:9: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
Variables Created By RANK
])
-AT_CHECK([pspp -O format=csv histogram.sps], [0], [ignore])
+dnl The --testing-mode flag is important!!
+AT_CHECK([pspp --testing-mode -O format=csv histogram.sps], [0], [ignore])
AT_CLEANUP
of any data file used for input.
proximate cause: Segmentation Violation
])
-AT_CHECK([sed -n '/\*\*\*/,$p
-/proximate/q' < stderr], [0], [expout])
+AT_CHECK([sed '/proximate/q' < stderr], [0], [expout])
AT_CLEANUP