[gnumeric] Add support for introspection. [#670271]
- From: Jean BrÃfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add support for introspection. [#670271]
- Date: Wed, 11 Jul 2012 18:12:25 +0000 (UTC)
commit be976c267daf428f0b231928b442ca1b8211a820
Author: Jean Brefort <jean brefort normalesup org>
Date: Wed Jul 11 20:11:27 2012 +0200
Add support for introspection. [#670271]
ChangeLog | 18 +++++++
NEWS | 3 +
configure.in | 87 +++++++++++++++++++++++++++++++++++-
plugins/python-loader/ChangeLog | 4 ++
plugins/python-loader/gnm-python.c | 57 -----------------------
src/Makefile.am | 38 ++++++++++++++++
src/application.c | 8 +++-
src/cell.c | 24 ++++++++++
src/cell.h | 2 +
src/complex.h | 4 +-
src/format-template.h | 4 +-
src/func.c | 2 +
src/gnm-style-impl.h | 6 +-
src/parse-util.h | 6 +-
src/print-info.h | 10 ++--
src/sheet.c | 3 +
src/stf-parse.h | 4 +-
src/style-font.h | 2 +-
src/workbook-control-priv.h | 6 +-
19 files changed, 207 insertions(+), 81 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6d2ce81..8df84bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2012-07-11 Jean Brefort <jean brefort normalesup org>
+
+ * configure.in: add support for introspection. [#670271]
+ * src/Makefile.am: ditto.
+ * src/application.c: ditto.
+ * src/cell.c (cell_copy), (cell_free), (gnm_cell_get_type): ditto.
+ * src/cell.h: ditto.
+ * src/complex.h: ditto.
+ * src/format-template.h: ditto.
+ * src/func.c: ditto.
+ * src/gnm-style-impl.h: ditto.
+ * src/parse-util.h: ditto.
+ * src/print-info.h: ditto.
+ * src/sheet.c: ditto.
+ * src/stf-parse.h: ditto.
+ * src/style-font.h: ditto.
+ * src/workbook-control-priv.h: ditto.
+
2012-07-03 Morten Welinder <terra gnome org>
* src/ranges.c (gnm_sheet_range_hash, gnm_range_hash): Delete
diff --git a/NEWS b/NEWS
index ed0cf23..1fd72a8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.11.5
+Jean:
+ * Add support for introspection. [#670271]
+
Morten:
* Solver translation fixes.
* Teach non-linear solver about constraints. [Part of #620368]
diff --git a/configure.in b/configure.in
index 0e7913c..4cd639c 100644
--- a/configure.in
+++ b/configure.in
@@ -850,8 +850,8 @@ if test "x$python_msg" = xyes; then
fi
if test "x$python_msg" = xyes; then
- m4_define([pygobject_required_version], [2.12.0])
- PKG_CHECK_MODULES(PYGOBJECT, pygobject-2.0 >= pygobject_required_version,,
+ m4_define([pygobject_required_version], [3.0.0])
+ PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0 >= pygobject_required_version,,
[python_msg="Missing pygobject"])
fi
@@ -933,6 +933,89 @@ AC_SUBST(MONO_CFLAGS)
AC_SUBST(MONO_LIBS)
])
+# GObject Introspection
+GIR_REQ=1.0.0
+AC_ARG_ENABLE(introspection,
+ AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+ [Enable introspection for this build]),,
+ [enable_introspection=no])
+
+AC_MSG_CHECKING([for gobject-introspection])
+
+dnl presence/version checking
+AS_CASE([$enable_introspection],
+[no], [
+ found_introspection="no (disabled, use --enable-introspection to enable)"
+],
+[yes],[
+ PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+ AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+ PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $GIR_REQ],
+ found_introspection=yes,
+ AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
+],
+[auto],[
+ PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $GIR_REQ], found_introspection=yes, found_introspection=no)
+dnl Canonicalize enable_introspection
+enable_introspection=$found_introspection
+],
+[
+ AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+])
+
+AC_MSG_RESULT([$found_introspection])
+
+INTROSPECTION_SCANNER=
+INTROSPECTION_COMPILER=
+INTROSPECTION_GENERATE=
+INTROSPECTION_GIRDIR=
+INTROSPECTION_TYPELIBDIR=
+if test "x$found_introspection" = "xyes"; then
+ INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+ INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+ INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+ INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+ INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+ INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+ INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+ INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+fi
+AC_SUBST(INTROSPECTION_SCANNER)
+AC_SUBST(INTROSPECTION_COMPILER)
+AC_SUBST(INTROSPECTION_GENERATE)
+AC_SUBST(INTROSPECTION_GIRDIR)
+AC_SUBST(INTROSPECTION_TYPELIBDIR)
+AC_SUBST(INTROSPECTION_CFLAGS)
+AC_SUBST(INTROSPECTION_LIBS)
+AC_SUBST(INTROSPECTION_MAKEFILE)
+
+AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+dnl we need to change the install directories for distcheck
+AC_ARG_WITH([gir-dir],
+ AS_HELP_STRING(
+ [--with-gir-dir],
+ [
+ path to gir repository
+ (automatically detected via pkg-config)
+ ]
+ ),
+ [GIRDIR=$withval],
+ [GIRDIR=$INTROSPECTION_GIRDIR]
+)
+AC_SUBST(GIRDIR)
+AC_ARG_WITH([typelib-dir],
+ AS_HELP_STRING(
+ [--with-typelib-dir],
+ [
+ path to typelibs repository
+ (automatically detected via pkg-config)
+ ]
+ ),
+ [TYPELIBDIR=$withval],
+ [TYPELIBDIR=$INTROSPECTION_TYPELIBDIR]
+)
+AC_SUBST(TYPELIBDIR)
+
dnl **************************************************
dnl * Config defaults
dnl **************************************************
diff --git a/plugins/python-loader/ChangeLog b/plugins/python-loader/ChangeLog
index dc526a2..c1c9d01 100644
--- a/plugins/python-loader/ChangeLog
+++ b/plugins/python-loader/ChangeLog
@@ -1,3 +1,7 @@
+2012-07-11 Jean Brefort <jean brefort normalesup org>
+
+ * gnm-python.c (gnm_python_object_get): make python support work again.
+
2012-07-08 Morten Welinder <terra gnome org>
* python-loader.c (gplp_func_file_open): Add dummy encoding
diff --git a/plugins/python-loader/gnm-python.c b/plugins/python-loader/gnm-python.c
index bc27cc8..28dbe85 100644
--- a/plugins/python-loader/gnm-python.c
+++ b/plugins/python-loader/gnm-python.c
@@ -19,8 +19,6 @@
#include <unistd.h>
#include <Python.h>
-#define NO_IMPORT_PYGOBJECT
-#include <pygobject.h>
struct _GnmPython {
GObject parent_instance;
@@ -108,60 +106,6 @@ gnm_python_class_init (GObjectClass *gobject_class)
/* ---------- */
-
-/* Initialize _PyGObject_API. To get the gtk2 version of gobject, we first
- * have to do the C equivalent of
- * import pygtk
- * pygtk.require('2.0')
- * import gobject
- */
-static void
-gnm_init_pygobject (GOErrorInfo **err)
-{
- PyObject *pygtk, *mdict, *require, *ret, *gobject, *cobject;
-
- GO_INIT_RET_ERROR_INFO (err);
- _PyGObject_API = NULL;
- pygtk = PyImport_ImportModule((char *) "pygtk");
- if (pygtk == NULL) {
- if (err != NULL)
- *err = go_error_info_new_printf (_("Could not import %s."),
- "pygtk");
- return;
- }
- mdict = PyModule_GetDict (pygtk);
- require = PyDict_GetItemString (mdict, (char *) "require");
- if (!PyFunction_Check (require)) {
- *err = go_error_info_new_printf (_("Could not find %s."),
- "pygtk.require");
- return;
- } else {
- ret = PyObject_CallFunction
- (require, (char *) "O",
- PyString_FromString ((char *) "2.0"));
- if (!ret) {
- *err = go_error_info_new_printf (_("Could not initialize Python bindings for Gtk+, etc: %s"),
- py_exc_to_string ());
- return;
- }
- }
- gobject = PyImport_ImportModule((char *) "gobject");
- if (gobject == NULL) {
- *err = go_error_info_new_printf (_("Could not import %s."),
- "gobject");
- return;
- }
- mdict = PyModule_GetDict(gobject);
- cobject = PyDict_GetItemString(mdict, (char *) "_PyGObject_API");
- if (!PyCObject_Check(cobject)) {
- *err = go_error_info_new_printf (_("Could not find %s"),
- "_PyGObject_API");
- return;
- } else {
- _PyGObject_API = (struct _PyGObject_Functions *)PyCObject_AsVoidPtr(cobject);
- }
-}
-
GnmPython *
gnm_python_object_get (GOErrorInfo **err)
{
@@ -172,7 +116,6 @@ gnm_python_object_get (GOErrorInfo **err)
PyEval_InitThreads ();
#endif
}
- gnm_init_pygobject (err);
if (err && *err != NULL) {
Py_Finalize ();
return NULL;
diff --git a/src/Makefile.am b/src/Makefile.am
index c485399..a6657a2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -484,3 +484,41 @@ gtkaction_DATA = GNOME_Gnumeric-gtk.xml
GNOME_Gnumeric-gtk.xml: GNOME_Gnumeric-gtk.xml.in
sed -e 's/ _name *=/ name=/' <$< >$@
DISTCLEANFILES = GNOME_Gnumeric-gtk.xml
+
+BUILT_GIRSOURCES = Gnm- GNUMERIC_API_VER@.gir
+
+Gnm- GNUMERIC_API_VER@.gir: $(libspreadsheet_include_HEADER)
+Gnm- GNUMERIC_API_VER@.gir: $(libspreadsheet_la_SOURCES)
+Gnm- GNUMERIC_API_VER@.gir: libspreadsheet.la
+Gnm- GNUMERIC_API_VER@.gir: $(INTROSPECTION_SCANNER) Makefile
+ $(AM_V_GEN) $(INTROSPECTION_SCANNER) -v --namespace Gnm \
+ --nsversion="@GNUMERIC_API_VER@" \
+ --add-include-path=$(srcdir) --add-include-path=. \
+ --include=GObject-2.0 \
+ --include=Gio-2.0 \
+ --include=libxml2-2.0 \
+ --include=Gsf-1 \
+ --include=GOffice-0.10 \
+ --library=libspreadsheet.la \
+ --libtool="$(LIBTOOL)" \
+ --output $@ \
+ --pkg libspreadsheet- GNUMERIC_API_VER@ \
+ --accept-unprefixed \
+ -I$(top_srcdir) \
+ $(libspreadsheet_include_HEADERS) $(libspreadsheet_la_SOURCES)
+
+if HAVE_INTROSPECTION
+
+girdir = $(GIRDIR)
+gir_DATA = $(BUILT_GIRSOURCES)
+
+typelibsdir = $(TYPELIBDIR)
+typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelibs_DATA)
+
+%.typelib: %.gir $(INTROSPECTION_COMPILER)
+ $(AM_V_GEN) LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. $(INTROSPECTION_COMPILER) --includedir=$(srcdir) --includedir=. $(G_IR_COMPILER_OPTS) $< -o $(builddir)/$(@F)
+
+endif # HAVE_INTROSPECTION
+
diff --git a/src/application.c b/src/application.c
index 17293c1..138be1b 100644
--- a/src/application.c
+++ b/src/application.c
@@ -441,7 +441,13 @@ gnm_app_workbook_foreach (GnmWbIterFunc cback, gpointer data)
return TRUE;
}
-/* Get nth workbook. Index is zero-based. */
+/**
+ * gnm_app_workbook_get_by_index:
+ * @i: index
+ *
+ * Get nth workbook. Index is zero-based.
+ * Return value: (transfer none): the nth workbook if any.
+ */
Workbook *
gnm_app_workbook_get_by_index (int i)
{
diff --git a/src/cell.c b/src/cell.c
index 52f4d1a..32d8db5 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -1004,3 +1004,27 @@ gnm_cell_convert_expr_to_value (GnmCell *cell)
cell->base.texpr = NULL;
}
+static GnmCell *
+cell_copy (GnmCell *cell)
+{
+ return cell;
+}
+
+static GnmCell *
+cell_free (GnmCell *cell)
+{
+}
+
+GType
+gnm_cell_get_type (void)
+{
+ static GType type_cell = 0;
+
+ if (!type_cell)
+ type_cell = g_boxed_type_register_static
+ ("GnmCell",
+ (GBoxedCopyFunc) cell_copy,
+ (GBoxedFreeFunc) cell_free);
+
+ return type_cell;
+}
diff --git a/src/cell.h b/src/cell.h
index 152c4c1..02d6e3b 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -29,6 +29,8 @@ struct _GnmCell {
GnmValue *value; /* computed or entered (Must be non NULL) */
};
+GType gnm_cell_get_type (void);
+
/**
* GnmCell state checking
*/
diff --git a/src/complex.h b/src/complex.h
index f4385e1..767758f 100644
--- a/src/complex.h
+++ b/src/complex.h
@@ -9,7 +9,7 @@
G_BEGIN_DECLS
#ifdef GNM_WITH_LONG_DOUBLE
-typedef go_complexl complex_t;
+#define complex_t go_complexl
#define complex_init go_complex_initl
#define complex_add go_complex_addl
#define complex_sub go_complex_subl
@@ -31,7 +31,7 @@ typedef go_complexl complex_t;
#define complex_to_polar go_complex_to_polarl
#define complex_from_polar go_complex_from_polarl
#else
-typedef go_complex complex_t;
+#define complex_t go_complex
#define complex_init go_complex_init
#define complex_add go_complex_add
#define complex_sub go_complex_sub
diff --git a/src/format-template.h b/src/format-template.h
index e1b2d73..31acad7 100644
--- a/src/format-template.h
+++ b/src/format-template.h
@@ -89,8 +89,8 @@ struct _GnmFormatTemplate {
gboolean font;
gboolean patterns;
gboolean alignment;
-
- struct {
+
+ struct _FormatEdges {
gboolean left;
gboolean right;
gboolean top;
diff --git a/src/func.c b/src/func.c
index ddc591b..fdfe9ab 100644
--- a/src/func.c
+++ b/src/func.c
@@ -1003,6 +1003,8 @@ gnm_func_unref (GnmFunc *func)
func->ref_notify (func, 0);
}
+/**
+ */
GnmFunc *
gnm_func_lookup (char const *name, Workbook *scope)
{
diff --git a/src/gnm-style-impl.h b/src/gnm-style-impl.h
index 2cbdcb1..1d3af77 100644
--- a/src/gnm-style-impl.h
+++ b/src/gnm-style-impl.h
@@ -29,16 +29,16 @@ struct _GnmStyle {
PangoContext *font_context;
/* public */
- struct {
+ struct _GnmStyleColor {
GnmColor *font;
GnmColor *back;
GnmColor *pattern;
- } color;
+ } color;
GnmBorder *borders[MSTYLE_BORDER_DIAGONAL - MSTYLE_BORDER_TOP + 1];
guint32 pattern;
#warning TODO use GOFont
- struct {
+ struct _GnmStyleFontDetails {
GOString *name;
gboolean bold;
gboolean italic;
diff --git a/src/parse-util.h b/src/parse-util.h
index bdeb23e..08b913a 100644
--- a/src/parse-util.h
+++ b/src/parse-util.h
@@ -144,7 +144,7 @@ struct _GnmConventions {
gboolean exp_is_left_associative;
/* Import specific functions ------------------------------------- */
- struct {
+ struct _GnmConventionsImport {
/* Called a lot for anything that might be a reference. */
char const *(*range_ref) (GnmRangeRef *res, char const *in,
GnmParsePos const *pp,
@@ -164,7 +164,7 @@ struct _GnmConventions {
/* Must return non-NULL, and absorb the args, including the list. */
GnmExpr const *(*func) (GnmConventions const *convs,
- /* make scope more useful, eg a
+ /* make scope more useful, eg a
* ParsePos * to allow for
* sheet/object specific functions
* */
@@ -177,7 +177,7 @@ struct _GnmConventions {
} input;
/* Export specific functions ----------------------------------- */
- struct {
+ struct _GnmConventionsExport {
int decimal_digits;
gboolean translated;
diff --git a/src/print-info.h b/src/print-info.h
index 6ecda8a..eddb9e3 100644
--- a/src/print-info.h
+++ b/src/print-info.h
@@ -58,8 +58,8 @@ typedef struct {
} GnmPageBreaks;
struct _PrintInformation {
- struct {
- enum {
+ struct _PrintInfoScaling {
+ enum _PrintScaleType {
PRINT_SCALE_PERCENTAGE,
PRINT_SCALE_FIT_PAGES
} type;
@@ -69,12 +69,12 @@ struct _PrintInformation {
* When the user is doing the simple scaling, both these values
* will be equal.
*/
- struct {
+ struct _PrintScalePercent {
double x;
double y;
} percentage;
- struct { /* zero == use as many as required */
+ struct _PrintScaleDim { /* zero == use as many as required */
int cols;
int rows;
} dim;
@@ -98,7 +98,7 @@ struct _PrintInformation {
GnmPrintCommentPlacementType comment_placement;
GnmPrintErrorsType error_display;
- struct {
+ struct _PrintInfoPageBreaks {
GnmPageBreaks *h, /* between rows */
*v; /* between columns */
} page_breaks;
diff --git a/src/sheet.c b/src/sheet.c
index e095a68..ea99e30 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -2758,6 +2758,9 @@ sheet_cell_get_value (Sheet *sheet, int const col, int const row)
/**
* sheet_cell_set_text:
+ * @cell A cell.
+ * @text, the text to set.
+ * @markup: (allow-none): an optional PangoAttrList.
*
* Marks the sheet as dirty
* Clears old spans.
diff --git a/src/stf-parse.h b/src/stf-parse.h
index c48cd9d..b460fb2 100644
--- a/src/stf-parse.h
+++ b/src/stf-parse.h
@@ -27,12 +27,12 @@ typedef struct {
GSList * terminator; /* Line terminators */
char * locale;
- struct {
+ struct _StfCompiledTerminator {
guchar min, max;
} compiled_terminator;
/* CSV related */
- struct {
+ struct _StfSeparator {
GSList *str;
char *chr;
gboolean duplicates; /* See two text separators as one? */
diff --git a/src/style-font.h b/src/style-font.h
index 4ef7638..41f749c 100644
--- a/src/style-font.h
+++ b/src/style-font.h
@@ -12,7 +12,7 @@ struct _GnmFont {
int ref_count;
char *font_name;
double size_pts;
- struct {
+ struct _GnmGOFont {
GOFont const *font;
GOFontMetrics *metrics;
} go;
diff --git a/src/workbook-control-priv.h b/src/workbook-control-priv.h
index a529292..f6f0d7a 100644
--- a/src/workbook-control-priv.h
+++ b/src/workbook-control-priv.h
@@ -28,13 +28,13 @@ typedef struct {
void (*edit_finish) (WorkbookControl *wbc, gboolean accept);
void (*selection_descr_set) (WorkbookControl *wbc, char const *text);
void (*update_action_sensitivity) (WorkbookControl *wbc);
- struct {
+ struct _WbcSheetManager {
void (*add) (WorkbookControl *wbc, SheetView *sv);
void (*remove) (WorkbookControl *wbc, Sheet *sheet);
void (*focus) (WorkbookControl *wbc, Sheet *sheet);
void (*remove_all) (WorkbookControl *wbc);
} sheet;
- struct {
+ struct _WbcUndoRedo {
void (*truncate)(WorkbookControl *wbc, int n, gboolean is_undo);
void (*pop) (WorkbookControl *wbc, gboolean is_undo);
void (*push) (WorkbookControl *wbc, gboolean is_undo,
@@ -42,7 +42,7 @@ typedef struct {
void (*labels) (WorkbookControl *wbc,
char const *undo, char const *redo);
} undo_redo;
- struct {
+ struct _WbcMenuState {
void (*update) (WorkbookControl *wbc, int flags);
} menu_state;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]