Skip to content

jdahlin/gml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

G Markup Language for Gtk+/Clutter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages