Document Root & Imports - Blueprint documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# Document Root & Imports

## Document Root

Root = GtkDecl (Using)* (TranslationDomain)? ( Template | Menu | Object )* EOF

A blueprint document consists of a GTK declaration, one or more imports, and a list of objects and/or a template.

### Example

    // Gtk Declaration
    using Gtk 4.0;

    // Import Statement
    using Adw 1;

    // Object
    Window my_window {}

## GTK Declaration

GtkDecl = ‘using’ ‘Gtk’ ‘4.0’ ‘;’

Every blueprint file begins with the line `using Gtk 4.0;`, which declares the target GTK version for the file. Tools that read blueprint files should verify that they support the declared version.

### Example

    using Gtk 4.0;

## GObject Introspection Imports

Using = ‘using’ <namespace:IDENT> <version:NUMBER> ‘;’

To use classes and types from namespaces other than GTK itself, those namespaces must be imported at the top of the file. This tells the compiler what version of the namespace to import.

You’ll need the GIR name and version, not the package name and not the exact version number. These are listed at the top of each library’s documentation homepage:

The compiler requires typelib files for these libraries to be installed. They are usually installed with the library, but on some distros, you may need to install the package that provides `{namespace}-{version}.typelib` (e.g. `Adw-1.typelib`).

### Example

    // Import libadwaita
    using Adw 1;

## Translation Domain

TranslationDomain = ‘translation-domain’ <domain:QUOTED> ‘;’

The translation domain is used to look up translations for translatable strings in the blueprint file. If no translation domain is specified, strings will be looked up in the program’s global domain.

See Gtk.Builder:translation-domain for more information.