diff --git a/src/lib.rs b/src/lib.rs index b720e18..731b02d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,10 +40,18 @@ impl Menu { pub struct Submenu(platform_impl::Submenu); impl Submenu { + pub fn label(&self) -> String { + self.0.label() + } + pub fn set_label(&mut self, label: impl AsRef) { self.0.set_label(label) } + pub fn enabled(&self) -> bool { + self.0.enabled() + } + pub fn set_enabled(&mut self, enabled: bool) { self.0.set_enabled(enabled) } @@ -60,10 +68,18 @@ impl Submenu { pub struct TextMenuItem(platform_impl::TextMenuItem); impl TextMenuItem { + pub fn label(&self) -> String { + self.0.label() + } + pub fn set_label(&mut self, label: impl AsRef) { self.0.set_label(label) } + pub fn enabled(&self) -> bool { + self.0.enabled() + } + pub fn set_enabled(&mut self, enabled: bool) { self.0.set_enabled(enabled) } diff --git a/src/platform_impl/linux.rs b/src/platform_impl/linux.rs index 442f7e6..760766a 100644 --- a/src/platform_impl/linux.rs +++ b/src/platform_impl/linux.rs @@ -105,6 +105,10 @@ fn add_entries_to_menu>(gtk_menu: &M, entries: &Vec>); impl Submenu { + pub fn label(&self) -> String { + self.0.lock().label.clone() + } + pub fn set_label(&mut self, label: impl AsRef) { let label = label.as_ref().to_string(); let mut entry = self.0.lock(); @@ -114,6 +118,10 @@ impl Submenu { entry.label = label; } + pub fn enabled(&self) -> bool { + self.0.lock().enabled + } + pub fn set_enabled(&mut self, enabled: bool) { let mut entry = self.0.lock(); entry.enabled = true; @@ -155,6 +163,10 @@ impl Submenu { pub struct TextMenuItem(Arc>); impl TextMenuItem { + pub fn label(&self) -> String { + self.0.lock().label.clone() + } + pub fn set_label(&mut self, label: impl AsRef) { let label = label.as_ref().to_string(); let mut entry = self.0.lock(); @@ -164,6 +176,10 @@ impl TextMenuItem { entry.label = label; } + pub fn enabled(&self) -> bool { + self.0.lock().enabled + } + pub fn set_enabled(&mut self, enabled: bool) { let mut entry = self.0.lock(); for item in entry.item_gtk_items.as_ref().unwrap().lock().iter() {