G_DEFINE_TYPE (PsppireDialogActionReliability, psppire_dialog_action_reliability, PSPPIRE_TYPE_DIALOG_ACTION);
+enum
+ {
+ ALPHA = 0,
+ SPLIT = 1
+ };
+
static char *
generate_syntax (PsppireDialogAction *act)
{
g_string_append (string, "\n\t/MODEL=");
- if ( 0 == gtk_combo_box_get_active (GTK_COMBO_BOX (rd->model_combo)))
+ if ( ALPHA == gtk_combo_box_get_active (GTK_COMBO_BOX (rd->model_combo)))
g_string_append (string, "ALPHA");
else
g_string_append_printf (string, "SPLIT (%d)",
}
static void
-on_method_change (PsppireDialogActionReliability *pda)
+update_split_control (PsppireDialogActionReliability *pda)
{
+ GtkTreeModel *liststore =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (pda->variables));
+
+ gint n_vars = gtk_tree_model_iter_n_children (liststore, NULL);
+
+ gint sp = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (pda->split_spinbutton));
+
+ if (sp >= n_vars)
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (pda->split_spinbutton), n_vars - 1);
+
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (pda->split_spinbutton),
+ 0, n_vars - 1);
+
gtk_widget_set_sensitive (pda->split_point_hbox,
- ( 1 == gtk_combo_box_get_active (GTK_COMBO_BOX (pda->model_combo))));
+ ( SPLIT == gtk_combo_box_get_active (GTK_COMBO_BOX (pda->model_combo))));
}
gtk_tree_view_get_model (GTK_TREE_VIEW (pda->variables));
gtk_list_store_clear (GTK_LIST_STORE (liststore));
- gtk_combo_box_set_active (GTK_COMBO_BOX (pda->model_combo), 0);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (pda->model_combo), ALPHA);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (pda->split_spinbutton), 0);
{
PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
PsppireDialogActionReliability *act = PSPPIRE_DIALOG_ACTION_RELIABILITY (a);
-
+ GtkTreeModel *liststore ;
GtkBuilder *xml = builder_new ("reliability.ui");
pda->dialog = get_widget_assert (xml, "reliability-dialog");
pda->source = get_widget_assert (xml, "dict-view");
act->model_combo = get_widget_assert (xml, "combobox1");
act->split_spinbutton = get_widget_assert (xml, "spinbutton1");
+ liststore =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (act->variables));
+
+
act->scale_if_item_deleted_checkbutton = get_widget_assert (xml, "totals-checkbutton");
g_signal_connect_swapped (act->model_combo, "changed",
- G_CALLBACK (on_method_change), pda);
+ G_CALLBACK (update_split_control), pda);
+
+
+ g_signal_connect_swapped (liststore, "row-inserted",
+ G_CALLBACK (update_split_control), pda);
+ g_signal_connect_swapped (liststore, "row-deleted",
+ G_CALLBACK (update_split_control), pda);
+
psppire_dialog_action_set_refresh (pda, refresh);
psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);