dev-doc/Shortcuts.md
The shortcut system in darktable is built upon a unified Action System. Actions abstract user interactions (like pressing a key, clicking a button, or scrolling) and map them to specific functions in modules or views.
dt_action_def_t)Every shortcut-able action is defined by a dt_action_def_t structure. This structure links a human-readable name to a processing function.
dt_action_t: The runtime representation of an action. It forms a hierarchical tree (e.g., iop/exposure/exposure).dt_action_def_t: The static definition.
typedef struct dt_action_def_t
{
const gchar *name; // Internal name
// Function to execute when action is triggered
float (*process)(gpointer target, dt_action_element_t, dt_action_effect_t, float size);
const dt_action_element_def_t *elements; // Sub-elements (optional)
const dt_shortcut_fallback_t *fallbacks; // Default shortcuts
const gboolean no_widget; // True if not associated with a specific widget
} dt_action_def_t;
For most IOP modules, you don't need to manually define actions. The dt_bauhaus widget library handles this automatically.
When you create a widget using introspection (e.g., dt_bauhaus_slider_from_params), the system automatically registers an action for it. The action ID is derived from the parameter name.
If you are creating custom widgets or non-widget actions, you can register them manually.
In your module code (often in gui_init or a helper), define the action structure.
dt_action_registerdt_action_register(parent_action, "action_name", callback_function, default_key, modifiers);
To create a button that has a shortcut, use dt_action_button_new:
GtkWidget *btn = dt_action_button_new(module, _("button label"),
callback, user_data,
_("tooltip"),
GDK_KEY_e, GDK_CONTROL_MASK); // Default shortcut Ctrl+E
If an existing module control lacks a shortcut:
dt_bauhaus widget. If so, it should already have one. Check shortcuts tab in preferences.Users can customize shortcuts in Preferences > Shortcuts. The system scans all registered actions and presents them in a hierarchical list.