![]() |
Deluge Firmware 1.3.0
Build date: 2025.04.16
|
Directories | |
dmenus | |
dmui | |
gendoc | |
Files | |
g_menus.inc | |
This directory contains 2 python modules:
dmui
is a DSL (Domain Specific Language) for specifying the Deluge menu hierarchies.dmenu
is the actual menu specification itself.Unless you're adding new capabilities to the menu compiler, you should only need to add or change files in the dmenu
module.
To add a new menu item, we recommend the "monkey see, monkey do" approach - find a menu item that behaves similar to the one you want to add, and copy-paste code until it works. For those who prefer a more principled approach, the dmui
module can be processed by the Sphinx documentation generator via the config and makefile in src/deluge/gui/menu_item/generate/gendoc
. What follows is a quick-reference version of that documentation.
The Python DSL does not map 1:1 to C++ menus – instead, each Python class encompasses the broad-strokes behavior of the menu item. To select the appropriate Python class for your new menu item, consider the following factors:
Submenu
child on the C++ side (i.e. it contains a list of other menus), use a Submenu
on the Python side.MultiContextMenu
to specify the menu and instantiate it using with_context
in the child lists.MultiModeMenu
.Menu
on the Python side.The DSL is composed of Python objects that do some amount of sanity checking to ensure the generated menu hierarchy and documentation is well-formed. To actually generate the various output types (C++ and documentation), we apply the visitor pattern with visitor implementations for each supported output type.