Skip to content

Build an App

A Singularity app is a GTK4 application that builds against libsingularity, uses its UI primitives, authors its interface in vetro, and follows the desktop conventions.

The fastest way in is singularity-demo, the template app. It is small, it puts the primitives on screen, and it shows the exact wiring of vetro, Vala, meson, resources, and the .desktop file. Read it and copy from it:

The rest of this page is a complete hello world that mirrors how the demo is put together.

A minimal app is a handful of files. The interface is described in ui/main.vetro, the behavior lives in Vala, and meson runs the vetro transpiler and bundles the result. The .vetro file is optional, you could hand-write the GTK .ui, but it is the recommended way to author UI.

hello/
meson.build
resources/hello.gresource.xml
ui/main.vetro
src/main.vala
src/app.vala
src/window.vala
Template(class: "HelloWindow", parent: "SingularityWidgetsWindow") {
VBox(id: "content", hexpand: true, vexpand: true,
halign: "center", valign: "center", spacing: 12) {
Label(id: "greeting", label: "Hello, Singularity").cssClass("title-1")
}
}

The meson.build depends on singularity-1.0 with a subproject fallback for in-tree builds. The --vapidir line points valac at libsingularity’s API when it is built in-tree, and the resource’s source_dir includes the build directory because main.ui is generated there. When building standalone, libsingularity must be installed and visible to pkg-config. Its installed singularity-1.0.pc pulls in the C dependencies, and the shipped singularity-1.0.deps tells valac which Vala packages to add transitively (including gtksourceview-5), so you do not have to list them by hand. If pkg-config --exists singularity-1.0 fails, add the install prefix:

Terminal window
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH

The demo’s meson.build shows the full picture, including the .desktop file, the icon, and translations.

libsingularity provides the building blocks every app should reuse: rows and groups, the search entry, context menus, the source view wrapper, cards, chips, and the accent-aware style system. App-specific classes are for genuinely unique widgets only. The full set is in the primitives reference.

Read shared preferences from the dev.sinty.desktop schema, but never assume it is installed. Construct settings through the safe helper so a missing schema degrades to defaults instead of aborting:

var settings = Singularity.Core.safe_settings ("dev.sinty.desktop");
if (settings != null) {
// read keys
}

To let users change your app’s own settings from the desktop’s Apps page, see Exposing app settings.