can-lehmann / owlkettle

A declarative user interface framework based on GTK 4
https://can-lehmann.github.io/owlkettle/README
MIT License
375 stars 13 forks source link

Add builder and shortcut window #140

Open PhilippMDoerner opened 10 months ago

PhilippMDoerner commented 10 months ago

This provides a first draft on how we might add support for the ShortcutsWindow widget via the Builder interface.

Overall it adds support for these Widgets:

Further functionality that was added and may be useful:

How it works: When initially building it provides "Pseudo-Widgets" for ShortcutsSection/Group/Shortcut that can be put into ShortcutsWindow and thus be kind-of their own XML representation, but with better support by nim's type system.

Note: This does not enable updating the values after the fact.

ShortcutsWindow uses toNode procs to turn ShortcutsSection into XMLNodes, which uses toNode procs to turn ShortcutsGroup into XmlNodes etc.. This goes on until one gigantic XMLNode has been created, which gets stringified and used as "uiString" to create a builder, from which the ShortcutsWindow can be extracted.

In order to be able to extract the widget from the builder, an "id"-property must be set in the uiString of the ShortcutsWindow tag, which I just set to "widget". It's a technical detail so it can't be customized by anybody.

Small niceties:

This also provides an example! I reimplemented this ui file for the example in shortcuts_window.nim, in large parts in order to triple check if I didn't miss some part of their spec. Works nicely!

Word explanation:

Example video:

Screencast from 2023-11-16 23-07-54.webm

This is a draft because I believe we'll have a fair amount to talk about this as this does a fair amount of stuff. Particularly: ... how to we run this as a modal when clicking on a popup menu entry? I honestly have no clue.