X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fsort-cases-dialog.c;h=62fac58379b7aaf71f0de9fed8672c98ee3ed74a;hb=f606d3c31ea117f7b9cb187f3521c7051a8db2ba;hp=a722063bca70beb42f7ca4a4a990926fa369b4b1;hpb=0bd0098aec2ee31d9460c8d4c1263d0b5ccc4324;p=pspp diff --git a/src/ui/gui/sort-cases-dialog.c b/src/ui/gui/sort-cases-dialog.c index a722063bca..62fac58379 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));