From: John Darrington Date: Sun, 31 May 2020 11:31:45 +0000 (+0200) Subject: psppire: Deal properly with inverted variable selections. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56e6166660c0f1388cad4cb4d3189e026bc84dd5;p=pspp psppire: Deal properly with inverted variable selections. When deleting variables, if the start of a selected range is greater than the end of the range, then swap the start and end. --- diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 7ddb0bff9c..8bfb74df16 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -445,6 +445,13 @@ psppire_data_editor_var_delete_variables (PsppireDataEditor *de) { SswRange *range = SSW_SHEET(de->var_sheet)->selection; + if (range->start_x > range->end_x) + { + gint temp = range->start_x; + range->start_x = range->end_x; + range->end_x = temp; + } + psppire_dict_delete_variables (de->dict, range->start_y, (range->end_y - range->start_y + 1)); diff --git a/src/ui/gui/psppire-data-sheet.c b/src/ui/gui/psppire-data-sheet.c index 3774bfbfd8..83bc892e15 100644 --- a/src/ui/gui/psppire-data-sheet.c +++ b/src/ui/gui/psppire-data-sheet.c @@ -273,6 +273,13 @@ psppire_data_sheet_delete_variables (PsppireDataSheet *sheet) PsppireDataStore *data_store = NULL; g_object_get (sheet, "data-model", &data_store, NULL); + if (range->start_x > range->end_x) + { + gint temp = range->start_x; + range->start_x = range->end_x; + range->end_x = temp; + } + psppire_dict_delete_variables (data_store->dict, range->start_x, (range->end_x - range->start_x + 1)); diff --git a/src/ui/gui/psppire-variable-sheet.c b/src/ui/gui/psppire-variable-sheet.c index 41c428fffc..149403743a 100644 --- a/src/ui/gui/psppire-variable-sheet.c +++ b/src/ui/gui/psppire-variable-sheet.c @@ -248,6 +248,13 @@ delete_variables (SswSheet *sheet) PsppireDict *dict = NULL; g_object_get (sheet, "data-model", &dict, NULL); + if (range->start_x > range->end_x) + { + gint temp = range->start_x; + range->start_x = range->end_x; + range->end_x = temp; + } + psppire_dict_delete_variables (dict, range->start_y, (range->end_y - range->start_y + 1));