[gnumeric] Introspection: update bless api



commit 0304cb4ff809a66fd03e3ef46cccefd0a789997c
Author: Morten Welinder <terra gnome org>
Date:   Fri Apr 13 21:37:25 2018 -0400

    Introspection: update bless api

 README-introspection           |   35 ++++++++++++++++++++++++++++++++---
 test/t3002-introspection-io.py |   13 ++++++++++---
 2 files changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/README-introspection b/README-introspection
index c363309..7843bc5 100644
--- a/README-introspection
+++ b/README-introspection
@@ -1,16 +1,21 @@
 Today is 20180412.  If that seems a long time ago, this document might
 be outdated.
 
+Note: For tests you must either "make install" first or else run the
+python script via the corresponding *.pl file.
+
 test/t3001-introspection-simple.py shows a sample of using introspection
-to work with a spreadsheet.  Note: you must either "make install" first
-or else run it the corresponding *.pl file.
+to work with a spreadsheet.
+
+test/t3002-introspection-io.py shows a sample of using introspection
+to load and save files.
+
 
 The following is a list of types and the API that is expected to both
 be useful in this setting and actually work.
 
 This is incomplete.  In particular, I'll have to look at
 * Expressions other than via text
-* File i/o
 * Installing a gi override module for more pythony structure handling
 
 -----------------------------------------------------------------------------
@@ -32,6 +37,14 @@ GODoc: [GObject]
   props.pristine
 
 
+WorkbookView: [GObject]
+  new_from_uri(uri,opener,iocontext,encoding)
+  save_to_uri(uri,saver,iocontext)
+  props.workbook
+  props.preferred_width
+  props.preferred_height
+
+
 Sheet: [GObject]
   get_size()
   cell_set_value(col,row,value)      [1]
@@ -235,10 +248,26 @@ GOFormat: [Boxed structure]
   toggle_1000sep
 
 
+GOIOContext: [GObject]
+  new(cmdtxt)
+
+
+GnmCmdContextStderr: [GObject]
+  new()
+
+
+GOFileSaver: [GObject]
+  get_default()
+  for_file_name(filename_or_uri)
+  for_mime_type(mimetype)
+  for_id(saverid)
 
 Gnm (i.e., not in a class):
   clipboard_copy_range(sheet,range)
 
+GOffice (i.e., not in a class):
+  filename_to_uri(filename)
+
 
 
 
diff --git a/test/t3002-introspection-io.py b/test/t3002-introspection-io.py
index e945766..a232bf2 100755
--- a/test/t3002-introspection-io.py
+++ b/test/t3002-introspection-io.py
@@ -10,15 +10,22 @@ Gnm.init()
 
 import sys
 src_uri = GOffice.filename_to_uri (sys.argv[1])
-print(src_uri)
 dst_uri = GOffice.filename_to_uri (sys.argv[2])
-print(dst_uri)
 
 ioc = GOffice.IOContext.new (Gnm.CmdContextStderr.new ())
-wbv =  Gnm.WorkbookView.new_from_uri (src_uri, None, ioc, None)
 
+# Read a file
+wbv = Gnm.WorkbookView.new_from_uri (src_uri, None, ioc, None)
+wb = wbv.props.workbook
+print("Loaded {}".format(wb.props.uri))
+
+# Save a file
 fs = GOffice.FileSaver.for_file_name (dst_uri)
 wbv.save_to_uri (fs, dst_uri, ioc)
+print("Saved {}".format(dst_uri))
 
+# Remove our references to the objects
+wb = None
+wbv = None
 ioc = None
 wbv = None


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