pub struct MenuItem {
pub id: i32,
pub label: String,
pub enabled: bool,
pub visible: bool,
pub kind: ItemKind,
pub toggle: Option<bool>,
pub action: Option<String>,
pub children: Vec<MenuItem>,
}Expand description
One row of a menu.
id must be stable for as long as the row means the same thing. A
host asks for properties by id after the layout is sent, and reuses an
id it already knows: renumbering rows between revisions makes a click
land on whatever row inherited the number. Ids are assigned from the
content, not from position — see assign_ids.
Fields§
§id: i32§label: String§enabled: bool§visible: bool§kind: ItemKind§toggle: Option<bool>Some only for ItemKind::Checkmark.
action: Option<String>What clicking this row should do. Serialised for this crate’s own
popup, the only thing that ever reads it (see crate::launch): it
hands the string straight back on its own stdout rather than an id
needing a second lookup. A dbusmenu host never sees it — it sends
back an id, which Menu::action_for resolves.
children: Vec<MenuItem>Implementations§
Source§impl MenuItem
impl MenuItem
pub fn standard(label: impl Into<String>, action: impl Into<String>) -> Self
pub fn checkmark( label: impl Into<String>, on: bool, action: impl Into<String>, ) -> Self
pub fn separator() -> Self
Sourcepub fn disabled(label: impl Into<String>) -> Self
pub fn disabled(label: impl Into<String>) -> Self
A row that is shown but cannot be clicked — “Wi-Fi is off”, or a network this app cannot join yet.
Sourcepub fn disabled_checkmark(label: impl Into<String>, on: bool) -> Self
pub fn disabled_checkmark(label: impl Into<String>, on: bool) -> Self
A checkmark that cannot be clicked — a radio blocked by a
hardware kill switch, say, where on/off is still true but no
D-Bus call flips it back. Shown rather than hidden, and shown as
a checkmark rather than an ordinary disabled row, so the state it
reports is not lost along with the ability to change it.