How to Install the Gnome Blueprint Markup Language
Blueprint is a markup language for creating graphical user interfaces using the GTK toolkit.
It is developed and maintained by James Westman.
Its main goal is to be an easy-to-learn markup language that enables building graphical interfaces quickly and declaratively.
It’s important to note that the Blueprint markup language does not replace the current standard for building GTK graphical interfaces, since Blueprint code is compiled/transpiled into XML.
As with other GUI frameworks and toolkits, GTK uses the XML format to define the visual part of applications.
This format is widely used and generally well accepted; however, it tends to be hard to read and modify manually.
That difficulty often leads to a steep learning curve, and in many cases, there’s a need for tools that allow visual interface design.
Some examples of such tools are:
- Cambalache
- Drafting
- Glade — Not recommended for GTK 4 development.
- Workbench — A tool for learning and prototyping.
The idea behind the Blueprint markup language emerged to make this process easier.
To better understand it, let’s compare the code for the same graphical interface in both markup languages.
To describe a GTK interface in XML (*.ui), you can use the following code:
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="ExampleWindow" parent="GtkApplicationWindow">
<property name="title">Python (PyGObject) GTK 4.</property>
<property name="default-width">683</property>
<property name="default-height">384</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header_bar">
<child type="end">
<object class="GtkMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="menu-model">primary_menu</property>
</object>
</child>
</object>
</child>
</template>
<menu id="primary_menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
</section>
</menu>
</interface>
The same graphical interface in Blueprint markup language (*.blp) looks like this:
using Gtk 4.0;
template $ExampleWindow: Gtk.ApplicationWindow {
title: 'Python and GTK: PyGObject Gtk.ApplicationWindow.';
default-width: 683;
default-height: 384;
[titlebar]
Gtk.HeaderBar header_bar {
[end]
Gtk.MenuButton {
icon-name: 'open-menu-symbolic';
menu-model: primary_menu;
}
}
}
menu primary_menu {
section {
item {
label: _('Preferences');
action: 'app.preferences';
}
}
}
As we can see, the interface code becomes much more readable and simpler with Blueprint markup.
Installation via Repositories
Linux
Arch Linux
Official distribution website: Arch Linux
Fedora
Official distribution website: Fedora
openSUSE Tumbleweed
Official distribution website: openSUSE Tumbleweed
Ubuntu
Official distribution website: Ubuntu
Microsoft Windows
⚠️ To install
blueprint-compileron Microsoft Windows, MSYS2 must be installed and configured.
Open the MSYS2 terminal and run the following command:
Installation from Source
To get the latest version of blueprint-compiler, you can install it from its source code.
Dependencies
macOS
Arch Linux
Fedora
openSUSE Tumbleweed
Ubuntu
Microsoft Windows
⚠️ To install
blueprint-compileron Microsoft Windows, MSYS2 must be installed and configured.
Open the MSYS2 terminal and install the following dependencies:
Installation
Once the dependencies are installed, open a terminal and clone the blueprint-compiler repository:
⚠️ On Windows, use the
MINGW64terminal from MSYS2.
Next, navigate to the cloned folder:
Run the following command:
Once the build process finishes, run:
After installation is complete, blueprint-compiler will be available on your system 🚀.
To verify the installation, close the terminal, open it again, and run:
Main Commands
To start an interactive setup wizard for a project:
To convert a *.blp file to *.ui:
To see all available options:
Extras
Extensions
Some text editors support the Blueprint markup language.
Here are the main ones: