[gnumeric] Introspection: changing and querying sheet style.



commit 433ca8325b48f0f6ff6ca39f8a4734cad2e1320b
Author: Morten Welinder <terra gnome org>
Date:   Thu Apr 12 19:38:30 2018 -0400

    Introspection: changing and querying sheet style.

 README-introspection               |    5 +++--
 src/sheet-style.c                  |   14 +++++++-------
 test/t3001-introspection-simple.py |    9 +++++++--
 3 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/README-introspection b/README-introspection
index 658b699..e3da5f5 100644
--- a/README-introspection
+++ b/README-introspection
@@ -10,7 +10,6 @@ be useful in this setting and actually work.
 
 This is incomplete.  In particular, I'll have to look at
 * Expressions other than via text
-* Applying style information
 * File i/o
 * Copy and paste
 * Installing a gi override module for more pythony structure handling
@@ -41,6 +40,8 @@ Sheet: [GObject]
   cells(range)
   cells_count()
   is_cell_empty(col,row)
+  style_apply_range(range,style)
+  style_get(col,row)
   props.name
   props.workbook
   props.rtl
@@ -80,7 +81,7 @@ Sheet: [GObject]
 GnmCell: [Boxed structure] [2]
   name()
   get_value()
-
+  pos
 
 GnmSheetSize: [Simple structure]
   max_cols
diff --git a/src/sheet-style.c b/src/sheet-style.c
index 3f40ee9..94ee564 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -1491,11 +1491,11 @@ sheet_style_default (Sheet const *sheet)
 /**
  * sheet_style_get:
  * @sheet: #Sheet
- * @col:
- * @row:
+ * @col: column number
+ * @row: row number
  *
- * Find the fully qualified style applicable to the specified cellpos.
- * Does _not_ add a reference.
+ * Returns: (transfer none): find the fully qualified style applicable to
+ * the specified cell position
  **/
 GnmStyle const *
 sheet_style_get (Sheet const *sheet, int col, int row)
@@ -1747,9 +1747,9 @@ style_row_init (GnmBorder const * * *prev_vert,
 
 /**
  * sheet_style_apply_range:
- * @sheet:
- * @range:
- * @pstyle:
+ * @sheet: #Sheet
+ * @range: #GnmRange to apply over
+ * @pstyle: (transfer full): A partial style to apply
  *
  * Apply a partial style to a region.
  * The routine absorbs a reference to the partial style.
diff --git a/test/t3001-introspection-simple.py b/test/t3001-introspection-simple.py
index 40442e3..74cb117 100755
--- a/test/t3001-introspection-simple.py
+++ b/test/t3001-introspection-simple.py
@@ -25,9 +25,12 @@ sheet.cell_set_text(0,4,"zzz")
 sheet.cell_set_value(0,5,Gnm.Value.new_string("abc"))
 sheet.cell_set_value(0,6,Gnm.Value.new_bool(1))
 
+# Make A1:A2 bold
 st = Gnm.Style.new()
 st.set_font_bold(1)
-# FIXME: Apply somewhere
+r = Gnm.Range()
+r.init(0,0,0,1)
+sheet.style_apply_range(r,st)
 
 # Recalculate all cells that need it
 wb.recalc()
@@ -42,4 +45,6 @@ for i in range(7):
 
 print "\nList of cells in sheet:"
 for c in sheet.cells(None):
-    print c.name()
+    st = sheet.style_get (c.pos.col,c.pos.row)
+    bold = st.get_font_bold()
+    print("{}: {}".format(c.name(), ("[bold]" if bold else "")))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]