Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add builder and shortcut window #140

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

PhilippMDoerner
Copy link
Contributor

@PhilippMDoerner PhilippMDoerner commented Nov 16, 2023

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.

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.

@can-lehmann can-lehmann added this to the Owlkettle 4.0.0 milestone Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants