Code architecture of LaTeXila
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.
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 LaTeXila 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 LaTeXila is inspired by gedit. See this page to know why, and how to improve the situation (how to re-use the code of gedit instead of re-inventing the wheel).
Certain features have been easy to implement thanks to GtkSourceView and GtkTextView:
- syntax highlighting
- search and replace
- change parameters like:
- show line numbers
- indentation style
- color scheme
Other features for the text editor part, implemented in LaTeXila:
- open several files in different tabs
- automatic save every X minutes
- reopen files on startup
- integrated file browser in the side panel
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.
The LatexilaApp class creates MainWindow objects. The main window has attributes to the components of the main window, 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 GtkNotebook, contains the document tabs. A document tab is represented by the DocumentTab class, a subclass of GtkGrid containing the GtkSourceView object plus possibly info bars (see the TabInfoBar class) displayed on the top of a document. An info bar is used for example when the file is externally modified, and show buttons to reload the file or cancel. Instead of using directly the GtkSourceView and GtkSourceBuffer classes, LaTeXila 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.
The SidePanel class contains currently three components:
- symbols: ls *symbols*.vala
- structure: ls *structure*.vala
- file browser: file_browser.vala
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.
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.