[gnumeric] Introspection: switch to higher-level save interface.



commit 14eb6f4ee371d56eb0b0b2f26c36717617483b9f
Author: Morten Welinder <terra gnome org>
Date:   Sat Apr 14 13:36:28 2018 -0400

    Introspection: switch to higher-level save interface.
    
    This will handle the modtime tracking.

 ChangeLog                      |    6 ++++++
 README-introspection           |    5 +++--
 src/func.c                     |    6 +++---
 src/func.h                     |    2 +-
 src/gui-file.c                 |    6 +++---
 src/ssconvert.c                |    4 ++--
 src/workbook-view.c            |   24 ++++++++++++------------
 src/workbook-view.h            |    6 +++---
 test/t3002-introspection-io.py |    7 +++++--
 9 files changed, 38 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 308930e..0db1341 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-14  Morten Welinder  <terra gnome org>
+
+       * src/workbook-view.c (workbook_view_save_as): Rename from
+       wb_view_save_as for introspection.
+       (workbook_view_save): Rename from wb_view_save for introspection.
+
 2018-04-13  Morten Welinder  <terra gnome org>
 
        * src/workbook-view.c (workboook_view_save_to_uri): Renamed from
diff --git a/README-introspection b/README-introspection
index 3a2bd50..c7022b5 100644
--- a/README-introspection
+++ b/README-introspection
@@ -39,7 +39,8 @@ GODoc: [GObject]
 
 WorkbookView: [GObject]
   new_from_uri(uri,opener,iocontext,encoding)
-  save_to_uri(uri,saver,iocontext)
+  save(cmdctx)
+  save_as(uri,saver,cmdctx)
   props.workbook
   props.preferred_width
   props.preferred_height
@@ -249,7 +250,7 @@ GOFormat: [Boxed structure]
 
 
 GOIOContext: [GObject]
-  new(cmdtxt)
+  new(cmdctx)
 
 
 GnmCmdContextStderr: [GObject]
diff --git a/src/func.c b/src/func.c
index e23530a..473e6f4 100644
--- a/src/func.c
+++ b/src/func.c
@@ -750,19 +750,19 @@ gnm_func_set_user_data (GnmFunc *func, gpointer user_data)
 /**
  * gnm_func_get_name:
  * @func: #GnmFunc to query
- * @localized_function_names: if %TRUE, use localized name
+ * @localized: if %TRUE, use localized name
  *
  * Returns: (transfer none): @func's name
  */
 char const *
-gnm_func_get_name (GnmFunc const *func, gboolean localized_function_names)
+gnm_func_get_name (GnmFunc const *func, gboolean localized)
 {
        int i;
        GnmFunc *fd = (GnmFunc *)func;
 
        g_return_val_if_fail (func != NULL, NULL);
 
-       if (!localized_function_names)
+       if (!localized)
                return func->name;
 
        if (func->localized_name)
diff --git a/src/func.h b/src/func.h
index 5936985..4a82e22 100644
--- a/src/func.h
+++ b/src/func.h
@@ -230,7 +230,7 @@ GnmFunc        *gnm_func_ref             (GnmFunc *func);
 void       gnm_func_unref           (GnmFunc *func);
 void        gnm_func_load_if_stub    (GnmFunc *func);
 void       gnm_func_load_stub       (GnmFunc *fn_def);
-char const *gnm_func_get_name       (GnmFunc const *fn_def,
+char const *gnm_func_get_name       (GnmFunc const *func,
                                      gboolean localized);
 gpointer    gnm_func_get_user_data   (GnmFunc const *func);
 void        gnm_func_set_user_data   (GnmFunc *func, gpointer user_data);
diff --git a/src/gui-file.c b/src/gui-file.c
index 7c8d8fb..9a19344 100644
--- a/src/gui-file.c
+++ b/src/gui-file.c
@@ -728,7 +728,7 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view, GnmFileSaveAsStyle type,
                /* Destroy early so no-one can repress the Save button.  */
                gtk_widget_destroy (GTK_WIDGET (fsel));
                fsel = NULL;
-               if (wb_view_save_as (wb_view, fs, uri, GO_CMD_CONTEXT (wbcg)))
+               if (workbook_view_save_as (wb_view, fs, uri, GO_CMD_CONTEXT (wbcg)))
                        workbook_update_history (wb, type);
        }
 
@@ -838,7 +838,7 @@ gui_file_save (WBCGtk *wbcg, WorkbookView *wb_view)
                }
 
                if (ok)
-                       ok = wb_view_save (wb_view, GO_CMD_CONTEXT (wbcg));
+                       ok = workbook_view_save (wb_view, GO_CMD_CONTEXT (wbcg));
                if (ok)
                        workbook_update_history (wb, GNM_FILE_SAVE_AS_STYLE_SAVE);
                g_object_unref (wb);
@@ -884,7 +884,7 @@ gui_file_export_repeat (WBCGtk *wbcg)
                    go_gtk_dialog_run (GTK_DIALOG (dialog), wbcg_toplevel (wbcg))) {
                        /* We need to copy wb->last_export_uri since it will be reset during saving */
                        gchar *uri = g_strdup (last_uri);
-                       if(wb_view_save_as (wb_view, fs, uri, GO_CMD_CONTEXT (wbcg))) {
+                       if(workbook_view_save_as (wb_view, fs, uri, GO_CMD_CONTEXT (wbcg))) {
                                workbook_update_history (wb, GNM_FILE_SAVE_AS_STYLE_EXPORT);
                                g_free (uri);
                                return TRUE;
diff --git a/src/ssconvert.c b/src/ssconvert.c
index 1a6398e..addb9a4 100644
--- a/src/ssconvert.c
+++ b/src/ssconvert.c
@@ -848,7 +848,7 @@ convert (char const *inarg, char const *outarg, char const *mergeargs[],
                                workbook_sheet_move (sheet, -oldn);
                                wb_view_sheet_focus (wbv, sheet);
 
-                               res = !wb_view_save_as (wbv, fs, tmpfile, cc);
+                               res = !workbook_view_save_as (wbv, fs, tmpfile, cc);
                                workbook_sheet_move (sheet, +oldn);
                                g_free (tmpfile);
                                if (res)
@@ -863,7 +863,7 @@ convert (char const *inarg, char const *outarg, char const *mergeargs[],
                                      "Only the current sheet will be saved.  To get around this limitation, 
use -S.\n"),
                                    go_file_saver_get_id (fs));
        }
-       res = !wb_view_save_as (wbv, fs, outfile, cc);
+       res = !workbook_view_save_as (wbv, fs, outfile, cc);
 
  out:
        if (wb)
diff --git a/src/workbook-view.c b/src/workbook-view.c
index 1a0ab8b..d982855 100644
--- a/src/workbook-view.c
+++ b/src/workbook-view.c
@@ -1174,11 +1174,11 @@ get_uri_modtime (GsfInput *input, const char *uri)
 }
 
 /**
- * wb_view_save_as:
+ * workbook_view_save_as:
  * @wbv: Workbook View
  * @fs: GOFileSaver object
  * @uri: URI to save as.
- * @cc:
+ * @cc: The #GOCmdContext that invoked the operation
  *
  * Saves @wbv and workbook it's attached to into @uri file using
  * @fs file saver.  If the format sufficiently advanced make it the saver
@@ -1187,8 +1187,8 @@ get_uri_modtime (GsfInput *input, const char *uri)
  * Return value: %TRUE if file was successfully saved and %FALSE otherwise.
  */
 gboolean
-wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs, char const *uri,
-                GOCmdContext *cc)
+workbook_view_save_as (WorkbookView *wbv, GOFileSaver *fs, char const *uri,
+                      GOCmdContext *cc)
 {
        GOIOContext *io_context;
        Workbook  *wb;
@@ -1237,9 +1237,9 @@ wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs, char const *uri,
 }
 
 /**
- * wb_view_save:
+ * workbook_view_save:
  * @wbv: The view to save.
- * @cc: The context that invoked the operation
+ * @cc: The #GOCmdContext that invoked the operation
  *
  * Saves @wbv and workbook it's attached to into file assigned to the
  * workbook using workbook's file saver. If the workbook has no file
@@ -1248,7 +1248,7 @@ wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs, char const *uri,
  * Return value: %TRUE if file was successfully saved and %FALSE otherwise.
  */
 gboolean
-wb_view_save (WorkbookView *wbv, GOCmdContext *context)
+workbook_view_save (WorkbookView *wbv, GOCmdContext *context)
 {
        GOIOContext     *io_context;
        Workbook        *wb;
@@ -1304,10 +1304,10 @@ wb_view_save (WorkbookView *wbv, GOCmdContext *context)
  * @encoding: (allow-none): Encoding for @file_opener that understand it
  *
  * Reads @uri file using given file opener @file_opener, or probes for a valid
- * possibility if @file_opener is NULL.  Reports problems to @io_context.
+ * possibility if @file_opener is %NULL.  Reports problems to @io_context.
  *
- * Return value: (transfer full): the newly allocated WorkbookView or %NULL
- * on error.
+ * Return value: (transfer full) (nullable): the newly allocated WorkbookView
+ * or %NULL on error.
  **/
 WorkbookView *
 workbook_view_new_from_input (GsfInput *input,
@@ -1420,8 +1420,8 @@ workbook_view_new_from_input (GsfInput *input,
  * Reads @uri file using given file opener @file_opener, or probes for a valid
  * possibility if @file_opener is %NULL.  Reports problems to @io_context.
  *
- * Return value: (transfer full): the newly allocated WorkbookView or %NULL
- * on error.
+ * Return value: (transfer full) (nullable): the newly allocated WorkbookView
+ * or %NULL on error.
  **/
 WorkbookView *
 workbook_view_new_from_uri (char const *uri,
diff --git a/src/workbook-view.h b/src/workbook-view.h
index 66e2423..f0adc76 100644
--- a/src/workbook-view.h
+++ b/src/workbook-view.h
@@ -87,9 +87,9 @@ void           wb_view_edit_line_set    (WorkbookView *wbv,
 void            wb_view_auto_expr_recalc (WorkbookView *wbv);
 
 /* I/O routines */
-gboolean wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs,
-                         char const *uri, GOCmdContext *cc);
-gboolean wb_view_save   (WorkbookView *wbv, GOCmdContext *cc);
+gboolean workbook_view_save_as (WorkbookView *wbv, GOFileSaver *fs,
+                               char const *uri, GOCmdContext *cc);
+gboolean workbook_view_save     (WorkbookView *wbv, GOCmdContext *cc);
 void    workbook_view_save_to_output (WorkbookView *wbv,
                                       GOFileSaver const *fs,
                                       GsfOutput *output,
diff --git a/test/t3002-introspection-io.py b/test/t3002-introspection-io.py
index e4dc522..93edc9b 100755
--- a/test/t3002-introspection-io.py
+++ b/test/t3002-introspection-io.py
@@ -28,8 +28,11 @@ 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))
+if wbv.save_as (fs, dst_uri, cc):
+    print("Saved {}".format(wb.props.uri))
+else:
+    print("Failed to save to {}".format(dst_uri))
+
 
 # Remove our references to the objects
 wb = None


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