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=0eb0eaa678119166e44d8d5ff0d6c5f52c92bf9d;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp diff --git a/src/ui/gui/sort-cases-dialog.c b/src/ui/gui/sort-cases-dialog.c index 0eb0eaa678..62fac58379 100644 --- a/src/ui/gui/sort-cases-dialog.c +++ b/src/ui/gui/sort-cases-dialog.c @@ -45,13 +45,28 @@ 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) { gchar *text; GString *string = g_string_new ("SORT CASES BY "); gint n_vars = append_variable_names (string, - scd->dict, GTK_TREE_VIEW (scd->tv)); + scd->dict, GTK_TREE_VIEW (scd->tv), 0); if ( n_vars == 0 ) g_string_assign (string, ""); @@ -107,6 +122,7 @@ sort_cases_dialog (GObject *o, gpointer data) source, dest, insert_source_row_into_tree_view, + NULL, NULL); g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), dest); @@ -116,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));