G Markup Language for Gtk+/Clutter
Python
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
gml
.gitignore
COPYING
README.md
gmltool
test_gmlparser.py

README.md

GML

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.

Example

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.

Syntax

Creating objects

Creating a new toplevel object you just use the type name:

GtkWindow

You can also specify a new type without any properties:

GtkWindow {}

Properties

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
}

References

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
}

Children

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 }
    }
  }
}

Supported types

  • Strings: "string" or 'string'
  • Integers: 123
  • Floating point: 0.1
  • Boolean: true or false
  • Identifiers / References: button1

TODO

Things to do, ordered by category

General

  • Build system
  • Add license headers
  • Gtk+3/Introspection port
  • Glade output
  • Clutter
  • C rewrite

Parser

  • Lists
  • New tokenizer
  • Check token types better in parser
  • Add error messages to parser
  • Add a type for property referencs

Builder

  • GtkListStore columns & rows

Tool

  • Split into commands: run, validate, tokenize, parse, convert
  • Add a validator
  • Output: C
  • Output: GtkBuilder
  • Input: GtkBuilder
  • Input: Existing widget tree via a GtkModule

Tests

  • 100% coverage (might be redundant for Python impl)