From: John Darrington Date: Thu, 20 Nov 2008 23:23:08 +0000 (+0900) Subject: Prevent sheet from stepping outside its valid cell range. X-Git-Tag: v0.7.1~133 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=486a6c2150055f50061220ac01b4f26d68618c1a;p=pspp-builds.git Prevent sheet from stepping outside its valid cell range. --- diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index ba59e677..4728891b 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -58,6 +58,7 @@ #include "gtksheet.h" #include "gtkextra-marshal.h" #include "gsheetmodel.h" +#include /* sheet flags */ enum @@ -4371,6 +4372,16 @@ step_sheet (GtkSheet *sheet, GtkScrollType dir) break; } + + maximize_int (&new_row, 0); + maximize_int (&new_col, 0); + + minimize_int (&new_row, + g_sheet_row_get_row_count (sheet->row_geometry) - 1); + + minimize_int (&new_col, + g_sheet_column_get_column_count (sheet->column_geometry) - 1); + g_signal_emit (sheet, sheet_signals[TRAVERSE], 0, current_row, current_col, &new_row, &new_col, &forbidden); diff --git a/src/libpspp/misc.h b/src/libpspp/misc.h index 3b025157..c2f865d9 100644 --- a/src/libpspp/misc.h +++ b/src/libpspp/misc.h @@ -77,4 +77,23 @@ maximize (double *dest, double src) *dest = src; } + +/* Set *DEST to the lower of *DEST and SRC */ +static inline void +minimize_int (int *dest, int src) +{ + if (src < *dest) + *dest = src; +} + + +/* Set *DEST to the greater of *DEST and SRC */ +static inline void +maximize_int (int *dest, int src) +{ + if (src > *dest) + *dest = src; +} + + #endif /* libpspp/misc.h */