Development/Integrating LOKDocView and GNOME Documents
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
LOKDocView is the GTK3 widget that wraps the libreoffice functionality and exposes a simple API for applications to use this widget. This page mainly focuses on its integration with GNOME Documents.
GNOME Documents is written in javascript. LOKDocView is written in C++. Fortunately, LOKDocView is a GObject class which means we can make use of GObject Introspection to use this widget from not only javascript but any other bindings that gobject-introspection allows. To access this introspectable widget from language bindings like javascript, we need two files : .gir and .typelib file. You can generate these files manually using these tools - g-ir-scanner and g-ir-compiler.
To generate .gir file :
g-ir-scanner /opt/libreoffice/include/LibreOfficeKit/LibreOfficeKit.h \
/opt/libreoffice/include/LibreOfficeKit/LibreOfficeKitGtk.h \
/opt/libreoffice/libreofficekit/source/gtk/lokdocview.cxx \
--library=libreofficekitgtk `pkg-config --cflags gobject-introspection-1.0 gtk+-3.0` \
-I/opt/libreoffice/include/ --include=GLib-2.0 --include=GObject-2.0 --include=Gio-2.0 \
--include=Gdk-3.0 --include=GdkPixbuf-2.0 --include=Gtk-3.0 --namespace=LOKDocView --nsversion=0.1 \
--identifier-prefix=LOKDoc --symbol-prefix=lok_doc --output=/usr/share/gir-1.0/LOKDocView-0.1.gir \
--warn-all --no-libtool
To generate .typelib file :
g-ir-compiler /usr/share/gir-1.0/LOKDocView-0.1.gir --output=/usr/lib64/girepository-1.0/LOKDocView-0.1.typelib
The current plan is to generate these files in create_tree.sh which distributions have to invoke manually. The patch will get merged to master very soon.
GNOME Documents
To test this widget with gnome-documents, it is required that the .gir, .typelib and libreofficekitgtk.so are in their correct positions. The ideal position for these files : .gir in : /usr/share/gir-1.0 .typelib in : $libdir/girepository-1.0/
Also make sure that libreofficekitgtk.so is in $libdir. You need to symlink the newly generated libreofficekitgtk.so to your $libdir so that gnome-documents could find it.
To start building gnome-documents the easiest way, jhbuild is the recommended tool.
It is recommended that you install the latest jhbuild from master. This should be helpful for doing this. After that you need to make sure that all the prerequisites are present. You can do so via :
jhbuild sanitycheck
If not, install as directed by this sanity check. After the pre-requisites, you are ready to start building gnome-documents. We don't need to build the whole GNOME stack. Following command would automatically build dependencies recursively for g-d :
jhbuild build gnome-documents
It will automatically clone the repos recursively for you, and build them.
After the build
After the build finishes, you need to switch to the branch for LOKDocVIew integration (wip/pranavk/lokdocview). Build again but this time with a slightly different command because you don't want jhbuild to check all the dependencies again.
jhbuild buildone -n gnome-documents
'buildone' means 'just build this module and ignore dependencies' '-n' means don't update the repo from internet
To run gnome-documents you simply do :
jhbuild run gnome-documents
Alternatively, you can also jump to jhbuild env first, and then invoke g-d manually.
jhbuild shell
LOK_DEBUG=1 G_MESSAGES_DEBUG=all $prefix/bin/gnome-documents