Cambalache is a new RAD tool that enables the creation of user interfaces for Gtk and the GNOME desktop environment, it’s main focus is on the newly released Gtk 4 library but it has been designed from the ground up to support other versions.
It started as a proof of concept data model for Glade meant to try out all the crazy ideas I had during the years about how a clean model should be.
A few months later I had a pretty good data model that matched GObject type system quite well and did not depend on GtkBuilder nor GObject.
The model could:
- Import and export multiple UI at once
- Support plain (no custom tags) GtkBuilder features
- Packing/layout properties
- Undo / Redo stack
- History command compression and grouping
With that in mind one late night while holding my newborn daughter in one hand, I decided it was time to put it to test so I fired up Glade with the other hand and started a GUI prototype which quickly evolved into Cambalache, as my few dozen Twitter followers can assess. @XjuanAr
At this point the GUI supported most of the data model features.
One big difference with Glade is that Cambalache supports multiple UI in the same project so you need to ‘export all’ in order to create them as you can see at the end of the screencast bellow.
At this point I had a very specialized XML editor but… there is always a but, what about the workspace? the place where the UI is shown, rearranged, edited…
For the workspace my requirements are:
- It should look and feel as close to the real UI as possible
- Support multiple toolkits (Gtk 3, 4, 2 if really needed, libreoffice?)
- Out of process to avoid loosing data on an eventual crash
- It should look and feel as close to the real UI as possible, really!
Obviously adding the widgets directly like we did in Glade would not work if we want to support more than one version of Gtk since you can not mix them in the same process.
So we need a way to render widgets in a different process and show them somehow in the workspace… GtkPlug/GtkSocket would only work on X11.
Merengue enters the picture!
Fortunately this was not the first time I had to deal with such problem (See Maxwell) this reminded me of Alexander Larsson’s excellent project called Broadway a Gdk backend for the web. Ideally I would use an embedded Wayland compositor widget instead of a webview and broadway, but unfortunately there is only an old non working prototype called Wakefield and finishing it is a project on its own. In any case replacing the webview with a wayland compositor widget would be trivial.
Merengue is the name of the process Cambalache uses to render the UI while the user creates it, it is a regular Gtk 3 or Gtk 4 application depending on the version your project is targeting that just connects to Broadway and talks to the main application in JSON trough stdout/stdin pipes.
I will be talking more about Cambalache and the rationale behind starting a new project instead of porting Glade at GUADEC
See you there!
UPDATE: Cambalache source code released under the LGPL 2.1, get it here!