mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 12:01:31 +11:00
add title
& enabled
getters
This commit is contained in:
parent
0fbc8cf4f4
commit
bac4dbd1ab
16
src/lib.rs
16
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<str>) {
|
||||
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<str>) {
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -105,6 +105,10 @@ fn add_entries_to_menu<M: IsA<gtk::MenuShell>>(gtk_menu: &M, entries: &Vec<Arc<M
|
|||
pub struct Submenu(Arc<Mutex<MenuEntry>>);
|
||||
|
||||
impl Submenu {
|
||||
pub fn label(&self) -> String {
|
||||
self.0.lock().label.clone()
|
||||
}
|
||||
|
||||
pub fn set_label(&mut self, label: impl AsRef<str>) {
|
||||
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<Mutex<MenuEntry>>);
|
||||
|
||||
impl TextMenuItem {
|
||||
pub fn label(&self) -> String {
|
||||
self.0.lock().label.clone()
|
||||
}
|
||||
|
||||
pub fn set_label(&mut self, label: impl AsRef<str>) {
|
||||
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() {
|
||||
|
|
Loading…
Reference in a new issue