[gnumeric] Introspection: add basic io
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Introspection: add basic io
- Date: Sat, 14 Apr 2018 01:23:27 +0000 (UTC)
commit 00ae6fb48de0c7f073ae422bc69fa71476784f4e
Author: Morten Welinder <terra gnome org>
Date: Fri Apr 13 21:22:58 2018 -0400
Introspection: add basic io
ChangeLog | 5 +++++
component/gnumeric.c | 3 ++-
src/sheet.c | 2 +-
src/sheet.h | 2 +-
src/ssdiff.c | 5 +++--
src/tools/gnm-solver.c | 2 +-
src/validation.c | 2 +-
src/wbc-gtk-actions.c | 2 +-
src/workbook-view.c | 26 +++++++++++++++++---------
src/workbook-view.h | 10 ++++++----
test/GnumericTest.pm | 1 +
test/Makefile.am | 3 ++-
test/t3002-introspection-io.pl | 29 +++++++++++++++++++++++++++++
test/t3002-introspection-io.py | 24 ++++++++++++++++++++++++
14 files changed, 94 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 32b1c57..308930e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2018-04-13 Morten Welinder <terra gnome org>
+ * src/workbook-view.c (workboook_view_save_to_uri): Renamed from
+ wb_view_save_to_uri for introspection.
+ (workbook_view_save_to_output): Renamed from
+ wb_view_save_to_output for introspection.
+
* src/style-color.c (gnm_style_color_get_type): Duplicate of
gnm_color_get_type, more or less.
diff --git a/component/gnumeric.c b/component/gnumeric.c
index 013de38..40237d7 100644
--- a/component/gnumeric.c
+++ b/component/gnumeric.c
@@ -95,7 +95,8 @@ go_gnm_component_get_data (GOComponent *component, gpointer *data, int *length,
GOFileSaver *gfs = workbook_get_file_saver (gognm->wb);
if (gfs == NULL)
gfs = go_file_saver_get_default ();
- wbv_save_to_output (gognm->wv, gfs, output, io_context);
+ workbook_view_save_to_output (gognm->wv, gfs, output,
+ io_context);
*data = (gpointer) gsf_output_memory_get_bytes (GSF_OUTPUT_MEMORY (output));
*length = gsf_output_size (output);
*clearfunc = g_object_unref;
diff --git a/src/sheet.c b/src/sheet.c
index 26d40b1..262548e 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -1729,7 +1729,7 @@ sheet_apply_style (Sheet *sheet,
* sheet_apply_style_gi: (rename-to sheet_apply_style)
* @sheet: the sheet in which can be found
* @range: the range to which should be applied
- * @mstyle: A #GnmStyle partial style
+ * @style: A #GnmStyle partial style
*
* A mid level routine that applies the supplied partial style @style to the
* target @range and performs the necessary respanning and redrawing.
diff --git a/src/sheet.h b/src/sheet.h
index 2e6f987..abce118 100644
--- a/src/sheet.h
+++ b/src/sheet.h
@@ -340,7 +340,7 @@ GOUndo * sheet_range_set_expr_undo (GnmSheetRange *sr,
GnmExprTop const *texpr);
GOUndo * sheet_range_set_markup_undo (GnmSheetRange *sr,
PangoAttrList *markup);
-void sheet_apply_style (Sheet *sheet, GnmRange const *range, GnmStyle *mstyle);
+void sheet_apply_style (Sheet *sheet, GnmRange const *range, GnmStyle *style);
GOUndo * sheet_apply_style_undo (GnmSheetRange *sr,
GnmStyle *style);
void sheet_apply_border (Sheet *sheet, GnmRange const *range, GnmBorder **borders);
diff --git a/src/ssdiff.c b/src/ssdiff.c
index 6a248c0..03ff52e 100644
--- a/src/ssdiff.c
+++ b/src/ssdiff.c
@@ -792,8 +792,9 @@ static void
highlight_diff_end (gpointer user)
{
DiffState *state = user;
- wbv_save_to_output (state->highlight.wbv, state->highlight_fs,
- state->output, state->ioc);
+ workbook_view_save_to_output (state->highlight.wbv,
+ state->highlight_fs,
+ state->output, state->ioc);
}
static void
diff --git a/src/tools/gnm-solver.c b/src/tools/gnm-solver.c
index f026eda..82aa6b3 100644
--- a/src/tools/gnm-solver.c
+++ b/src/tools/gnm-solver.c
@@ -1313,7 +1313,7 @@ gnm_solver_saveas (GnmSolver *solver, WorkbookControl *wbc,
output = gsf_output_stdio_new_FILE (*filename, file, TRUE);
io_context = go_io_context_new (GO_CMD_CONTEXT (wbc));
- wbv_save_to_output (wbv, fs, output, io_context);
+ workbook_view_save_to_output (wbv, fs, output, io_context);
ok = !go_io_error_occurred (io_context);
g_object_unref (io_context);
g_object_unref (output);
diff --git a/src/validation.c b/src/validation.c
index 0ea4da7..8a2b8c6 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -363,7 +363,7 @@ gnm_validation_equal (GnmValidation const *a, GnmValidation const *b,
GnmValidation *
gnm_validation_ref (GnmValidation const *v)
{
- g_return_if_fail (v != NULL);
+ g_return_val_if_fail (v != NULL, NULL);
((GnmValidation *)v)->ref_count++;
return ((GnmValidation *)v);
}
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 65bab45..cc8cd05 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -142,7 +142,7 @@ static GNM_ACTION_DEF (cb_file_sendto) {
g_free (basename);
uri = go_filename_to_uri (full_name);
- wb_view_save_to_uri (wbv, fs, uri, io_context);
+ workbook_view_save_to_uri (wbv, fs, uri, io_context);
if (go_io_error_occurred (io_context) ||
go_io_warning_occurred (io_context))
diff --git a/src/workbook-view.c b/src/workbook-view.c
index a87276c..1a0ab8b 100644
--- a/src/workbook-view.c
+++ b/src/workbook-view.c
@@ -1082,7 +1082,7 @@ workbook_view_new (Workbook *wb)
}
/**
- * wbv_save_to_output:
+ * workbook_view_save_to_output:
* @wbv: #WorkbookView
* @fs: #GOFileSaver
* @output: #GsfOutput
@@ -1091,8 +1091,8 @@ workbook_view_new (Workbook *wb)
* NOTE : Temporary api until we get the new output framework.
**/
void
-wbv_save_to_output (WorkbookView *wbv, GOFileSaver const *fs,
- GsfOutput *output, GOIOContext *io_context)
+workbook_view_save_to_output (WorkbookView *wbv, GOFileSaver const *fs,
+ GsfOutput *output, GOIOContext *io_context)
{
GError const *err;
char const *msg;
@@ -1116,9 +1116,17 @@ wbv_save_to_output (WorkbookView *wbv, GOFileSaver const *fs,
go_cmd_context_error_export (GO_CMD_CONTEXT (io_context), msg);
}
+/**
+ * workbook_view_save_to_uri:
+ * @wbv: #WorkbookView
+ * @fs: #GOFileSaver
+ * @uri: destination URI
+ * @io_context: #GOIOContext
+ *
+ **/
void
-wb_view_save_to_uri (WorkbookView *wbv, GOFileSaver const *fs,
- char const *uri, GOIOContext *io_context)
+workbook_view_save_to_uri (WorkbookView *wbv, GOFileSaver const *fs,
+ char const *uri, GOIOContext *io_context)
{
char *msg = NULL;
GError *err = NULL;
@@ -1135,7 +1143,7 @@ wb_view_save_to_uri (WorkbookView *wbv, GOFileSaver const *fs,
go_cmd_context_error_export (GO_CMD_CONTEXT (io_context), msg);
g_free (msg);
} else {
- wbv_save_to_output (wbv, fs, output, io_context);
+ workbook_view_save_to_output (wbv, fs, output, io_context);
g_object_unref (output);
}
}
@@ -1196,7 +1204,7 @@ wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs, char const *uri,
io_context = go_io_context_new (cc);
go_cmd_context_set_sensitive (cc, FALSE);
- wb_view_save_to_uri (wbv, fs, uri, io_context);
+ workbook_view_save_to_uri (wbv, fs, uri, io_context);
go_cmd_context_set_sensitive (cc, TRUE);
has_error = go_io_error_occurred (io_context);
@@ -1265,7 +1273,7 @@ wb_view_save (WorkbookView *wbv, GOCmdContext *context)
_("Default file saver is not available."));
else {
char const *uri = go_doc_get_uri (GO_DOC (wb));
- wb_view_save_to_uri (wbv, fs, uri, io_context);
+ workbook_view_save_to_uri (wbv, fs, uri, io_context);
}
has_error = go_io_error_occurred (io_context);
@@ -1406,7 +1414,7 @@ workbook_view_new_from_input (GsfInput *input,
* workbook_view_new_from_uri:
* @uri: URI for file
* @file_opener: (allow-none): #GOFileOpener
- * @io_context: (allow-none): Context to display errors.
+ * @io_context: Context to display errors.
* @encoding: (allow-none): Encoding for @file_opener that understands it
*
* Reads @uri file using given file opener @file_opener, or probes for a valid
diff --git a/src/workbook-view.h b/src/workbook-view.h
index 0e93826..66e2423 100644
--- a/src/workbook-view.h
+++ b/src/workbook-view.h
@@ -90,10 +90,12 @@ void wb_view_auto_expr_recalc (WorkbookView *wbv);
gboolean wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs,
char const *uri, GOCmdContext *cc);
gboolean wb_view_save (WorkbookView *wbv, GOCmdContext *cc);
-void wbv_save_to_output (WorkbookView *wbv, GOFileSaver const *fs,
- GsfOutput *output, GOIOContext *io_context);
-void wb_view_save_to_uri (WorkbookView *wbv, GOFileSaver const *fs,
- char const *uri, GOIOContext *io_context);
+void workbook_view_save_to_output (WorkbookView *wbv,
+ GOFileSaver const *fs,
+ GsfOutput *output,
+ GOIOContext *io_context);
+void workbook_view_save_to_uri (WorkbookView *wbv, GOFileSaver const *fs,
+ char const *uri, GOIOContext *io_context);
WorkbookView *workbook_view_new_from_input (GsfInput *input,
const char *uri,
diff --git a/test/GnumericTest.pm b/test/GnumericTest.pm
index d659ae3..5e5a39f 100644
--- a/test/GnumericTest.pm
+++ b/test/GnumericTest.pm
@@ -272,6 +272,7 @@ sub corpus {
sub test_command {
my ($cmd,$test) = @_;
+ print STDERR "# $cmd\n" if $verbose;
my $output = `$cmd 2>&1`;
my $err = $?;
die "Failed command: $cmd\n" if $err;
diff --git a/test/Makefile.am b/test/Makefile.am
index de42601..ce20a32 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -181,7 +181,8 @@ SUPPS = common.supp gui.supp t8003-valgrind-pdf.supp
INTROSPECTION_TSTS = \
t3000-introspection-basic.pl \
- t3001-introspection-simple.pl
+ t3001-introspection-simple.pl \
+ t3002-introspection-io.pl
INTROSPECTION_SUPPS = \
$(INTROSPECTION_TSTS:.pl=.py)
diff --git a/test/t3002-introspection-io.pl b/test/t3002-introspection-io.pl
new file mode 100755
index 0000000..b1cce2a
--- /dev/null
+++ b/test/t3002-introspection-io.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+# -----------------------------------------------------------------------------
+
+use strict;
+use lib ($0 =~ m|^(.*/)| ? $1 : ".");
+use GnumericTest;
+
+&setup_python_environment ();
+
+my $python_script = $0;
+$python_script =~ s/\.pl$/.py/;
+
+for my $file ('format-tests.gnumeric') {
+ my $src = "$samples/$file";
+ my $dst = $file;
+ $dst =~ s{\.([^./]+)$}{-copy.$1};
+
+ unlink $dst;
+ &GnumericTest::junkfile ($dst);
+
+ &test_command ($PYTHON . ' ' .
+ &GnumericTest::quotearg ($python_script, $src, $dst),
+ sub { 1 });
+
+ &test_command (&GnumericTest::quotearg ($ssdiff, '--xml', $src, $dst),
+ sub { 1 });
+
+ &GnumericTest::removejunk ($dst);
+}
diff --git a/test/t3002-introspection-io.py b/test/t3002-introspection-io.py
new file mode 100755
index 0000000..e945766
--- /dev/null
+++ b/test/t3002-introspection-io.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+# -----------------------------------------------------------------------------
+
+import gi
+gi.require_version('Gnm', '1.12')
+gi.require_version('GOffice', '0.10')
+from gi.repository import Gnm
+from gi.repository import GOffice
+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)
+
+fs = GOffice.FileSaver.for_file_name (dst_uri)
+wbv.save_to_uri (fs, dst_uri, ioc)
+
+ioc = None
+wbv = None
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]