[gnumeric] Sheet: introduce gnm_sheet_get_size.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Sheet: introduce gnm_sheet_get_size.
- Date: Mon, 27 Apr 2009 14:38:15 -0400 (EDT)
commit 0b1d22cc5dae81efdc2e1d488e0cca004086f54b
Author: Morten Welinder <terra gnome org>
Date: Mon Apr 27 11:47:15 2009 -0400
Sheet: introduce gnm_sheet_get_size.
---
ChangeLog | 4 ++++
src/sheet.c | 27 ++++++++-------------------
src/sheet.h | 7 ++++---
3 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 72a3a18..c277677 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2009-04-27 Morten Welinder <terra gnome org>
+ * src/sheet.c (gnm_sheet_get_size): New function replacing
+ gnm_sheet_get_max_cols and gnm_sheet_get_max_rows. Turn those
+ into macros.
+
* src/sheet.h (struct _Sheet): Move max_cols and max_rows into
new member size of type GnmSheetSize.
diff --git a/src/sheet.c b/src/sheet.c
index daa9acf..d299c33 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -5704,32 +5704,21 @@ gnm_sheet_foreach_name (Sheet const *sheet, GHFunc func, gpointer data)
gnm_named_expr_collection_foreach (sheet->names, func, data);
}
-int
-gnm_sheet_get_max_rows (Sheet const *sheet)
+GnmSheetSize const *
+gnm_sheet_get_size (Sheet const *sheet)
{
- if (G_UNLIKELY (!sheet)) {
- g_warning ("NULL sheet in gnm_sheet_get_max_rows!");
- /* FIXME: This needs to go. */
- return GNM_DEFAULT_ROWS;
- }
+ static const GnmSheetSize default_size = {
+ GNM_DEFAULT_COLS, GNM_DEFAULT_ROWS
+ };
- if (G_UNLIKELY (sheet->being_constructed))
- g_warning ("Access to sheet size during construction!");
-
- return sheet->size.max_rows;
-}
-
-int
-gnm_sheet_get_max_cols (Sheet const *sheet)
-{
if (G_UNLIKELY (!sheet)) {
- g_warning ("NULL sheet in gnm_sheet_get_max_cols!");
+ g_warning ("NULL sheet in gnm_sheet_get_size!");
/* FIXME: This needs to go. */
- return GNM_DEFAULT_COLS;
+ return &default_size;
}
if (G_UNLIKELY (sheet->being_constructed))
g_warning ("Access to sheet size during construction!");
- return sheet->size.max_cols;
+ return &sheet->size;
}
diff --git a/src/sheet.h b/src/sheet.h
index 889eadc..273444c 100644
--- a/src/sheet.h
+++ b/src/sheet.h
@@ -11,7 +11,7 @@
G_BEGIN_DECLS
struct _GnmSheetSize {
- int max_rows, max_cols;
+ int max_cols, max_rows;
};
typedef struct _SheetPrivate SheetPrivate;
@@ -134,8 +134,9 @@ void gnm_sheet_suggest_size (int *cols, int *rows);
GOUndo *gnm_sheet_resize (Sheet *sheet, int cols, int rows, GOCmdContext *cc);
-int gnm_sheet_get_max_rows (Sheet const *sheet);
-int gnm_sheet_get_max_cols (Sheet const *sheet);
+GnmSheetSize const *gnm_sheet_get_size (Sheet const *sheet);
+#define gnm_sheet_get_max_rows(sheet) (gnm_sheet_get_size(sheet)->max_rows)
+#define gnm_sheet_get_max_cols(sheet) (gnm_sheet_get_size(sheet)->max_cols)
#define gnm_sheet_get_last_col(sheet) (gnm_sheet_get_max_cols(sheet) - 1)
#define gnm_sheet_get_last_row(sheet) (gnm_sheet_get_max_rows(sheet) - 1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]