projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
separate sack integration test binary
[pspp]
/
src
/
ui
/
gui
/
psppire-dialog-action-indep-samps.c
diff --git
a/src/ui/gui/psppire-dialog-action-indep-samps.c
b/src/ui/gui/psppire-dialog-action-indep-samps.c
index 3747d3e83d9c5e0dda630523eef90f399184619a..974c1e97f9935ba145859aa34b8dbd9c16c71b22 100644
(file)
--- a/
src/ui/gui/psppire-dialog-action-indep-samps.c
+++ b/
src/ui/gui/psppire-dialog-action-indep-samps.c
@@
-1,5
+1,5
@@
/* PSPPIRE - a graphical user interface for PSPP.
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007, 2009, 2010, 2011, 2012 Free Software Foundation
+ Copyright (C) 2007, 2009, 2010, 2011, 2012
, 2016
Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-49,10
+49,10
@@
dialog_state_valid (gpointer data)
if (NULL == act->grp_var)
return FALSE;
if (NULL == act->grp_var)
return FALSE;
- if (
0 == gtk_tree_model_get_iter_first (vars, ¬used))
+ if (0 == gtk_tree_model_get_iter_first (vars, ¬used))
return FALSE;
return FALSE;
- if (
act->group_defn == GROUPS_UNDEF)
+ if (act->group_defn == GROUPS_UNDEF)
return FALSE;
return TRUE;
return FALSE;
return TRUE;
@@
-70,11
+70,13
@@
refresh (PsppireDialogAction *da)
if (act->grp_var)
{
if (act->grp_var)
{
-
int width = var_get_width (act->grp_var)
;
+
const int width = act->grp_var_width
;
value_destroy (&act->cut_point, width);
value_destroy (&act->grp_val[0], width);
value_destroy (&act->grp_val[1], width);
value_destroy (&act->cut_point, width);
value_destroy (&act->grp_val[0], width);
value_destroy (&act->grp_val[1], width);
+ var_unref (act->grp_var);
act->grp_var = NULL;
act->grp_var = NULL;
+ act->grp_var_width = -1;
}
psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[0]), NULL);
}
psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[0]), NULL);
@@
-95,15
+97,15
@@
value_entry_contains_invalid (PsppireValueEntry *ve, const struct variable *var)
{
gboolean result = FALSE;
{
gboolean result = FALSE;
- if (var)
+ if (var)
{
union value val;
const int width = var_get_width (var);
value_init (&val, width);
{
union value val;
const int width = var_get_width (var);
value_init (&val, width);
- if (
psppire_value_entry_get_value (ve, &val, width))
+ if (psppire_value_entry_get_value (ve, &val, width))
{
{
- if (var_is_value_missing (var, &val
, MV_SYSTEM)
)
+ if (var_is_value_missing (var, &val
) == MV_SYSTEM
)
{
result = TRUE;
}
{
result = TRUE;
}
@@
-124,6
+126,9
@@
define_groups_state_valid (gpointer data)
{
PsppireDialogActionIndepSamps *act = data;
{
PsppireDialogActionIndepSamps *act = data;
+ if (act->grp_var == NULL)
+ return FALSE;
+
if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (act->dg_values_toggle_button)))
{
if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (act->dg_values_toggle_button)))
{
@@
-151,18
+156,21
@@
run_define_groups (PsppireDialogActionIndepSamps *act)
{
gint response;
PsppireDialogAction *da = PSPPIRE_DIALOG_ACTION (act);
{
gint response;
PsppireDialogAction *da = PSPPIRE_DIALOG_ACTION (act);
+ GtkWidget *parent1 = gtk_widget_get_parent (act->dg_table1);
+ GtkWidget *parent2 = gtk_widget_get_parent (act->dg_table2);
- if ( act->dg_table2->parent)
- gtk_container_remove (GTK_CONTAINER (act->dg_table2->parent), act->dg_table2);
+ g_return_if_fail (act->grp_var);
- if (
act->dg_table1->parent
)
- gtk_container_remove (GTK_CONTAINER (
act->dg_table1->parent
), act->dg_table1);
+ if (
parent1
)
+ gtk_container_remove (GTK_CONTAINER (
parent1
), act->dg_table1);
+ if (parent2)
+ gtk_container_remove (GTK_CONTAINER (parent2), act->dg_table2);
- if (
var_is_numeric (act->grp_var))
+ if (var_is_numeric (act->grp_var))
{
{
- gtk_
table_attach_defaults (GTK_TABLE
(act->dg_table1), act->dg_table2,
-
1, 2, 1, 2
);
+ gtk_
grid_attach (GTK_GRID
(act->dg_table1), act->dg_table2,
+
1, 1, 1, 1
);
gtk_container_add (GTK_CONTAINER (act->dg_box), act->dg_table1);
}
gtk_container_add (GTK_CONTAINER (act->dg_box), act->dg_table1);
}
@@
-180,7
+188,7
@@
run_define_groups (PsppireDialogActionIndepSamps *act)
psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[1]), act->grp_var);
psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (act->dg_cut_point_entry), act->grp_var);
psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[1]), act->grp_var);
psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (act->dg_cut_point_entry), act->grp_var);
- if (
act->group_defn != GROUPS_CUT_POINT
)
+ if (
act->group_defn != GROUPS_CUT_POINT
)
{
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (act->dg_cut_point_toggle_button), TRUE);
{
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (act->dg_cut_point_toggle_button), TRUE);
@@
-236,13
+244,13
@@
on_grp_var_change (GtkEntry *entry, PsppireDialogActionIndepSamps *act)
PsppireDialogAction *da = PSPPIRE_DIALOG_ACTION (act);
const gchar *text = gtk_entry_get_text (entry);
PsppireDialogAction *da = PSPPIRE_DIALOG_ACTION (act);
const gchar *text = gtk_entry_get_text (entry);
-
const struct variable *v = psppire_dict_lookup_var (da->dict, text)
;
+
struct variable *v = da->dict ? psppire_dict_lookup_var (da->dict, text) : NULL
;
gtk_widget_set_sensitive (act->define_groups_button, v != NULL);
if (act->grp_var)
{
gtk_widget_set_sensitive (act->define_groups_button, v != NULL);
if (act->grp_var)
{
-
int width = var_get_width (act->grp_var)
;
+
const int width = act->grp_var_width
;
value_destroy (&act->cut_point, width);
value_destroy (&act->grp_val[0], width);
value_destroy (&act->grp_val[1], width);
value_destroy (&act->cut_point, width);
value_destroy (&act->grp_val[0], width);
value_destroy (&act->grp_val[1], width);
@@
-263,13
+271,18
@@
on_grp_var_change (GtkEntry *entry, PsppireDialogActionIndepSamps *act)
}
else
{
}
else
{
-
act->cut_point.short_string
[0] = '\0';
-
act->grp_val[0].short_string
[0] = '\0';
-
act->grp_val[1].short_string
[0] = '\0';
+
act->cut_point.s
[0] = '\0';
+
act->grp_val[0].s
[0] = '\0';
+
act->grp_val[1].s
[0] = '\0';
}
}
}
}
- act->grp_var = v;
+ struct variable *old_grp_var = act->grp_var;
+ if (v)
+ act->grp_var = var_ref (v);
+ if (old_grp_var)
+ var_unref (old_grp_var);
+ act->grp_var_width = v ? var_get_width (v) : -1;
}
static void
}
static void
@@
-285,22
+298,22
@@
set_group_criterion_type (GtkToggleButton *button,
}
}
-static
void
-psppire_dialog_action_indep_samps_activate (
GtkAction *a
)
+static
GtkBuilder *
+psppire_dialog_action_indep_samps_activate (
PsppireDialogAction *a, GVariant *param
)
{
PsppireDialogActionIndepSamps *act = PSPPIRE_DIALOG_ACTION_INDEP_SAMPS (a);
PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
{
PsppireDialogActionIndepSamps *act = PSPPIRE_DIALOG_ACTION_INDEP_SAMPS (a);
PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
- GtkBuilder *xml = builder_new ("
t-test
.ui");
+ GtkBuilder *xml = builder_new ("
indep-samples
.ui");
- pda->dialog = get_widget_assert (xml,"
t-test-independent-samples-dialog");
- pda->source = get_widget_assert (xml, "indep-samples-t
-test-t
reeview1");
+ pda->dialog = get_widget_assert (xml,"
independent-samples-dialog");
+ pda->source = get_widget_assert (xml, "indep-samples-treeview1");
act->define_groups_button = get_widget_assert (xml, "define-groups-button");
act->define_groups_button = get_widget_assert (xml, "define-groups-button");
- act->options_button = get_widget_assert (xml, "indep-samples-
t-test-
options-button");
+ act->options_button = get_widget_assert (xml, "indep-samples-options-button");
act->def_grps_dialog = get_widget_assert (xml, "define-groups-dialog");
act->def_grps_dialog = get_widget_assert (xml, "define-groups-dialog");
- act->group_var_entry = get_widget_assert (xml, "indep-samples-
t-test-
entry");
- act->test_vars_tv = get_widget_assert (xml, "indep-samples-t
-test-t
reeview2");
+ act->group_var_entry = get_widget_assert (xml, "indep-samples-entry");
+ act->test_vars_tv = get_widget_assert (xml, "indep-samples-treeview2");
act->dg_dialog = get_widget_assert (xml, "define-groups-dialog");
act->dg_grp_entry[0] = get_widget_assert (xml, "group1-entry");
act->dg_dialog = get_widget_assert (xml, "define-groups-dialog");
act->dg_grp_entry[0] = get_widget_assert (xml, "group1-entry");
@@
-323,9
+336,6
@@
psppire_dialog_action_indep_samps_activate (GtkAction *a)
g_signal_connect (act->dg_values_toggle_button, "toggled",
G_CALLBACK (set_group_criterion_type), act);
g_signal_connect (act->dg_values_toggle_button, "toggled",
G_CALLBACK (set_group_criterion_type), act);
-
- g_object_unref (xml);
-
psppire_dialog_action_set_refresh (pda, refresh);
psppire_dialog_action_set_valid_predicate (pda,
psppire_dialog_action_set_refresh (pda, refresh);
psppire_dialog_action_set_valid_predicate (pda,
@@
-341,14
+351,15
@@
psppire_dialog_action_indep_samps_activate (GtkAction *a)
g_signal_connect (act->group_var_entry, "changed",
G_CALLBACK (on_grp_var_change), act);
g_signal_connect (act->group_var_entry, "changed",
G_CALLBACK (on_grp_var_change), act);
- if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_indep_samps_parent_class)->activate)
- PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_indep_samps_parent_class)->activate (pda);
+ on_grp_var_change (GTK_ENTRY (act->group_var_entry), act);
+
+ return xml;
}
static char *
}
static char *
-generate_syntax (PsppireDialogAction *a)
+generate_syntax (
const
PsppireDialogAction *a)
{
PsppireDialogActionIndepSamps *act = PSPPIRE_DIALOG_ACTION_INDEP_SAMPS (a);
gchar *text;
{
PsppireDialogActionIndepSamps *act = PSPPIRE_DIALOG_ACTION_INDEP_SAMPS (a);
gchar *text;
@@
-366,16
+377,16
@@
generate_syntax (PsppireDialogAction *a)
g_string_append (str, "(");
{
g_string_append (str, "(");
{
- const union value *val =
+ const union value *val =
(act->group_defn == GROUPS_VALUES) ?
&act->grp_val[0] :
&act->cut_point;
(act->group_defn == GROUPS_VALUES) ?
&act->grp_val[0] :
&act->cut_point;
- struct string strx;
+ struct string strx;
ds_init_empty (&strx);
ds_init_empty (&strx);
- s
yntax_gen_value (&strx, val, var_get_width (act->grp_var),
-
var_get_print_format (act->grp_var)
);
-
+ s
truct fmt_spec f = var_get_print_format (act->grp_var);
+
syntax_gen_value (&strx, val, var_get_width (act->grp_var), &f
);
+
g_string_append (str, ds_cstr (&strx));
ds_destroy (&strx);
}
g_string_append (str, ds_cstr (&strx));
ds_destroy (&strx);
}
@@
-387,10
+398,11
@@
generate_syntax (PsppireDialogAction *a)
{
struct string strx;
ds_init_empty (&strx);
{
struct string strx;
ds_init_empty (&strx);
-
+
+ struct fmt_spec f = var_get_print_format (act->grp_var);
syntax_gen_value (&strx, &act->grp_val[1], var_get_width (act->grp_var),
syntax_gen_value (&strx, &act->grp_val[1], var_get_width (act->grp_var),
-
var_get_print_format (act->grp_var)
);
-
+
&f
);
+
g_string_append (str, ds_cstr (&strx));
ds_destroy (&strx);
}
g_string_append (str, ds_cstr (&strx));
ds_destroy (&strx);
}
@@
-413,9
+425,7
@@
generate_syntax (PsppireDialogAction *a)
static void
psppire_dialog_action_indep_samps_class_init (PsppireDialogActionIndepSampsClass *class)
{
static void
psppire_dialog_action_indep_samps_class_init (PsppireDialogActionIndepSampsClass *class)
{
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
- action_class->activate = psppire_dialog_action_indep_samps_activate;
+ PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_indep_samps_activate;
PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
}
PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
}
@@
-425,6
+435,7
@@
static void
psppire_dialog_action_indep_samps_init (PsppireDialogActionIndepSamps *act)
{
act->grp_var = NULL;
psppire_dialog_action_indep_samps_init (PsppireDialogActionIndepSamps *act)
{
act->grp_var = NULL;
+ act->grp_var_width = -1;
act->group_defn = GROUPS_UNDEF;
}
act->group_defn = GROUPS_UNDEF;
}