This is an experimental parser and runtime for a QML like markup language for Gtk+/Clutter. It is inspired by Qt's QML.
It's intended to complement the GtkBuilder format included in Gtk+.
The current implementation is written using Python, it will be ported to C when it's a bit more mature and better tested.
GML is licensed under GNU LGPL version 2 or later.
GtkWindow {
title: "GML example"
GtkVBox {
GtkLabel {
label: "Hello world"
packing { expand: False }
}
GtkButton {
label: "Click me"
packing { expand: False }
}
}
}
For more examples, see the examples folder.
Creating a new toplevel object you just use the type name:
GtkWindow
You can also specify a new type without any properties:
GtkWindow {}
Properties are similar to JavaScript properties:
GtkWindow { title: "Window Title" }
You can insert newlines anywhere you like:
GtkWindow {
title: "Window Title"
}
There's a special property called id
which can is used to identify the object:
GtkWindow {
id: window1
}
You can reference properties with an id, for instance:
GtkListStore {
id: liststore
}
GtkTreeView {
model: liststore
}
You can also reference objects by using a dot notation:
GtkButton {
id: button1
label: "Label"
}
GtkButton {
id: button2
label: button1.label
}
GML has a child concept implemented by a few types:
- GtkContainer
To add an child to an object, you just create it:
GtkWindow {
GtkVBox
}
It can of course be nested:
GtkWindow {
GtkVBox {
GtkButton
GtkLabel
}
}
GtkContainers supports the concept of child properties, they are in a separate object tag called packing, eg:
GtkWindow {
GtkVBox {
GtkButton {
packing { expand: true }
}
}
}
- Strings:
"string"
or'string'
- Integers:
123
- Floating point:
0.1
- Boolean:
true
orfalse
- Identifiers / References:
button1
Things to do, ordered by category
- Build system
- Add license headers
- Gtk+3/Introspection port
- Glade output
- Clutter
- C rewrite
- Lists
- New tokenizer
- Check token types better in parser
- Add error messages to parser
- Add a type for property referencs
- GtkListStore columns & rows
- Split into commands: run, validate, tokenize, parse, convert
- Add a validator
- Output: C
- Output: GtkBuilder
- Input: GtkBuilder
- Input: Existing widget tree via a GtkModule
- 100% coverage (might be redundant for Python impl)