Code architecture of GNOME LaTeX

Note that the application was previously named LaTeXila, that name is still present in the code, especially for the namespace in the liblatexila (it would be nice to rename the namespace to Glatex).

The Autotools are used for the build system, so the top files and directories layout is quite standard. The code is written in Vala and C, in the src/ directory.

For the translations, GNU gettext is used.

Libraries used

As every application for GNOME, GLib, GObject, GIO and GTK+ are used. The Libgee is also used, because its data structures are more convenient to use in Vala.

The GtkSourceView and Tepl libraries are used for displaying the LaTeX documents. The gspell library is used for the spell checking.


The main part of the code is written in Vala, but in src/liblatexila/ the code is written in C, with GTK-Doc comments. The GTK-Doc comments contain GObject Introspection annotations, to generate automatically a *.vapi file so the liblatexila can be used in the Vala code.

liblatexila is not a real library, it's an internal library statically linked to the binary. The Vala code can use the liblatexila, but the reverse should be avoided. Although it is possible in C to call Vala code, it's better to keep the liblatexila self-contained, to not have a tightly-coupled code.

By building gnome-latex with the --enable-gtk-doc option, you can have the liblatexila documentation directly in Devhelp.

The long-term goal is to get rid of the Vala code, slowly but surely. Vala is a good language to learn how to write a GTK+ application, the syntax is easier, but Vala has many problems that simply don't exist in C. Vala is a young language, without many developers, so the toolchain is quite rudimentary. See also the discussion about the C language in this document.

Text editor part

Every IDE has a text editor part, which is the basis of the application. The text editor part of gnome-latex follows the Tepl framework.

Certain features have been easy to implement thanks to GtkTextView, GtkSourceView and Tepl:

  • syntax highlighting
  • undo/redo
  • cut/copy/paste
  • search and replace (backend in GtkSourceView, GUI in gnome-latex)

  • change parameters like:
    • show line numbers
    • indentation style
    • color scheme

Other features for the text editor part, implemented in gnome-latex:

  • open several files in different tabs
  • automatic save every X minutes
  • reopen files on startup
  • integrated file browser in the side panel

Class diagram

Class diagram (the sources: class-diagram.dia). A bit outdated (now the Tepl framework is used).

LatexilaApp (GtkApplication)

The main() is in main.vala. It creates the application instance (or talk to an existing application instance), see the LatexilaApp class, a subclass of GtkApplication.

MainWindow (GtkApplicationWindow)

The LatexilaApp class creates MainWindow objects (subclass of GtkApplicationWindow). The main window has instance variables for its components, like the side panel, the bottom panel, the notebook (the tabs) containing the files, etc.

The MainWindow was before a big class, with all the menu items. Now the MainWindow is split in several classes, for example main_window_file.vala contains the actions in the File submenu.


The DocumentsPanel, a subclass of TeplNotebook, contains the document tabs. A document tab is represented by the DocumentTab class, a subclass of TeplTab. Instead of using directly the TeplView and TeplBuffer classes, gnome-latex has subclasses: DocumentView and Document.

Search and replace

The main window contains also the search and replace, and the goto line (see search.vala). They are added below the DocumentsPanel, not in the DocumentsPanel.

Side panel

The SidePanel class contains currently three components:

  • symbols: ls *symbols*.vala
  • structure: ls *structure*.vala
  • file browser: file_browser.vala

Build tools

Read the user documentation to know how build tools work.

The build tools engine is implemented in the liblatexila. Some of the UI is written in Vala.

A post-processor for Rubber was available, but has been removed. Rubber has some bugs and is less well maintained than Latexmk. Latexmk has also more features.

Utility functions

See the utils functions in the liblatexila and also utils.vala. If a function is useful in several different files, it can be added to latexila-utils.c.

Apps/GNOME-LaTeX/CodeArchitecture (last edited 2018-02-18 10:43:49 by SébastienWilmet)