From 17cc22594edc09fa76e03777a9019ec579cd8a1a Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 8 Feb 2008 03:33:43 +0000 Subject: [PATCH] Added valid predicates to transpose and sort dialogs. --- src/ui/gui/ChangeLog | 5 +++++ src/ui/gui/sort-cases-dialog.c | 20 ++++++++++++++++++++ src/ui/gui/transpose-dialog.c | 25 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 608a83f6..711624d0 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,8 @@ +2008-02-08 John Darrington + + * sort-cases-dialog.c transpose-dialog.c: Added dialog_valid + predicates. + 2008-02-04 John Darrington * checkbox-treeview.c: In toggle callback, use the treeview's diff --git a/src/ui/gui/sort-cases-dialog.c b/src/ui/gui/sort-cases-dialog.c index a722063b..62fac583 100644 --- a/src/ui/gui/sort-cases-dialog.c +++ b/src/ui/gui/sort-cases-dialog.c @@ -45,6 +45,21 @@ struct sort_cases_dialog GtkToggleButton *ascending; }; + +static gboolean +dialog_state_valid (gpointer data) +{ + struct sort_cases_dialog *scd = data; + GtkTreeModel *model = gtk_tree_view_get_model (scd->tv); + + gint n_rows = gtk_tree_model_iter_n_children (model, NULL); + + if ( n_rows == 0 ) + return FALSE; + + return TRUE; +} + static char * generate_syntax (const struct sort_cases_dialog *scd) { @@ -117,6 +132,11 @@ sort_cases_dialog (GObject *o, gpointer data) scd.ascending = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "sort-cases-radiobutton0")); + + psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog), + dialog_state_valid, &scd); + + response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); diff --git a/src/ui/gui/transpose-dialog.c b/src/ui/gui/transpose-dialog.c index 3a1f3a93..cdd3364d 100644 --- a/src/ui/gui/transpose-dialog.c +++ b/src/ui/gui/transpose-dialog.c @@ -55,6 +55,28 @@ refresh (PsppireDialog *dialog, gpointer data) gtk_entry_set_text (GTK_ENTRY (entry), ""); } +static gboolean +dialog_state_valid (gpointer data) +{ + GladeXML *xml = data; + + GtkWidget *tv = get_widget_assert (xml, "variables-treeview"); + GtkWidget *entry = get_widget_assert (xml, "new-name-entry"); + + GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (tv)); + + gint n_rows = gtk_tree_model_iter_n_children (model, NULL); + + if ( n_rows == 0 ) + return FALSE; + + if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (entry)))) + return FALSE; + + return TRUE; +} + + void transpose_dialog (GObject *o, gpointer data) { @@ -99,6 +121,9 @@ transpose_dialog (GObject *o, gpointer data) gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog), + dialog_state_valid, xml); + response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); switch (response) -- 2.30.2