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:
ShortcutsWindow
ShortcutsSection
ShortcutsGroup
ShortcutsShortcut
Further functionality that was added and may be useful:
General Builder utilities to create GtkWidgets from ui strings or xml files
XML-utilites specific to the XML in ui-files to generate the necessary tags more easily
Provided a general setProperty proc and refactored some parts of owlkettle to make use of it instead of the same 3+ lines of code to do so
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:
ShortcutsShortcut comes with a setter to provide more type-safety when specifying the shortcut
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:
For some unknown reason "accelerator" refers to basically the shortcut itself. I asked what the heck it means and got no final reply in the GTK matrix channel.
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.
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:
setProperty
proc and refactored some parts of owlkettle to make use of it instead of the same 3+ lines of code to do soHow 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 turnShortcutsSection
into XMLNodes, which usestoNode
procs to turnShortcutsGroup
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.