Commit 14eb6f4e authored by Morten Welinder's avatar Morten Welinder

Introspection: switch to higher-level save interface.

This will handle the modtime tracking.
parent a005264f
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
......
......@@ -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]
......
......@@ -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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)
......
......@@ -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,
......
......@@ -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,
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment