Skip to content

Commit

Permalink
fix!: acccelerator typo -> accelerator (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir authored Sep 23, 2024
1 parent 5c8971a commit 40d06c5
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 42 deletions.
5 changes: 5 additions & 0 deletions .changes/acccelerator-typo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"muda": "patch"
---

**Breaking change** Renamed the `acccelerator` method (which has an extra `c`) on `MenuItemBuilder`, `CheckMenuItemBuilder`, and `IconMenuItemBuilder` to `accelerator`.
12 changes: 6 additions & 6 deletions src/builders/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct CheckMenuItemBuilder {
text: String,
enabled: bool,
checked: bool,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
id: Option<MenuId>,
}

Expand Down Expand Up @@ -46,23 +46,23 @@ impl CheckMenuItemBuilder {
}

/// Set this check menu item accelerator.
pub fn acccelerator<A: TryInto<Accelerator>>(
pub fn accelerator<A: TryInto<Accelerator>>(
mut self,
acccelerator: Option<A>,
accelerator: Option<A>,
) -> crate::Result<Self>
where
crate::Error: From<<A as TryInto<Accelerator>>::Error>,
{
self.acccelerator = acccelerator.map(|a| a.try_into()).transpose()?;
self.accelerator = accelerator.map(|a| a.try_into()).transpose()?;
Ok(self)
}

/// Build this check menu item.
pub fn build(self) -> CheckMenuItem {
if let Some(id) = self.id {
CheckMenuItem::with_id(id, self.text, self.enabled, self.checked, self.acccelerator)
CheckMenuItem::with_id(id, self.text, self.enabled, self.checked, self.accelerator)
} else {
CheckMenuItem::new(self.text, self.enabled, self.checked, self.acccelerator)
CheckMenuItem::new(self.text, self.enabled, self.checked, self.accelerator)
}
}
}
16 changes: 8 additions & 8 deletions src/builders/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct IconMenuItemBuilder {
text: String,
enabled: bool,
id: Option<MenuId>,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
icon: Option<Icon>,
native_icon: Option<NativeIcon>,
}
Expand Down Expand Up @@ -59,39 +59,39 @@ impl IconMenuItemBuilder {
}

/// Set this icon menu item accelerator.
pub fn acccelerator<A: TryInto<Accelerator>>(
pub fn accelerator<A: TryInto<Accelerator>>(
mut self,
acccelerator: Option<A>,
accelerator: Option<A>,
) -> crate::Result<Self>
where
crate::Error: From<<A as TryInto<Accelerator>>::Error>,
{
self.acccelerator = acccelerator.map(|a| a.try_into()).transpose()?;
self.accelerator = accelerator.map(|a| a.try_into()).transpose()?;
Ok(self)
}

/// Build this icon menu item.
pub fn build(self) -> IconMenuItem {
if let Some(id) = self.id {
if self.icon.is_some() {
IconMenuItem::with_id(id, self.text, self.enabled, self.icon, self.acccelerator)
IconMenuItem::with_id(id, self.text, self.enabled, self.icon, self.accelerator)
} else {
IconMenuItem::with_id_and_native_icon(
id,
self.text,
self.enabled,
self.native_icon,
self.acccelerator,
self.accelerator,
)
}
} else if self.icon.is_some() {
IconMenuItem::new(self.text, self.enabled, self.icon, self.acccelerator)
IconMenuItem::new(self.text, self.enabled, self.icon, self.accelerator)
} else {
IconMenuItem::with_native_icon(
self.text,
self.enabled,
self.native_icon,
self.acccelerator,
self.accelerator,
)
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/builders/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct MenuItemBuilder {
text: String,
enabled: bool,
id: Option<MenuId>,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
}

impl MenuItemBuilder {
Expand Down Expand Up @@ -39,23 +39,23 @@ impl MenuItemBuilder {
}

/// Set this menu item accelerator.
pub fn acccelerator<A: TryInto<Accelerator>>(
pub fn accelerator<A: TryInto<Accelerator>>(
mut self,
acccelerator: Option<A>,
accelerator: Option<A>,
) -> crate::Result<Self>
where
crate::Error: From<<A as TryInto<Accelerator>>::Error>,
{
self.acccelerator = acccelerator.map(|a| a.try_into()).transpose()?;
self.accelerator = accelerator.map(|a| a.try_into()).transpose()?;
Ok(self)
}

/// Build this menu item.
pub fn build(self) -> MenuItem {
if let Some(id) = self.id {
MenuItem::with_id(id, self.text, self.enabled, self.acccelerator)
MenuItem::with_id(id, self.text, self.enabled, self.accelerator)
} else {
MenuItem::new(self.text, self.enabled, self.acccelerator)
MenuItem::new(self.text, self.enabled, self.accelerator)
}
}
}
12 changes: 6 additions & 6 deletions src/items/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ impl CheckMenuItem {
text: S,
enabled: bool,
checked: bool,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
) -> Self {
let item = crate::platform_impl::MenuChild::new_check(
text.as_ref(),
enabled,
checked,
acccelerator,
accelerator,
None,
);
Self {
Expand All @@ -66,7 +66,7 @@ impl CheckMenuItem {
text: S,
enabled: bool,
checked: bool,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
) -> Self {
let id = id.into();
Self {
Expand All @@ -75,7 +75,7 @@ impl CheckMenuItem {
text.as_ref(),
enabled,
checked,
acccelerator,
accelerator,
Some(id),
))),
}
Expand Down Expand Up @@ -109,8 +109,8 @@ impl CheckMenuItem {
}

/// Set this check menu item accelerator.
pub fn set_accelerator(&self, acccelerator: Option<Accelerator>) -> crate::Result<()> {
self.inner.borrow_mut().set_accelerator(acccelerator)
pub fn set_accelerator(&self, accelerator: Option<Accelerator>) -> crate::Result<()> {
self.inner.borrow_mut().set_accelerator(accelerator)
}

/// Get whether this check menu item is checked or not.
Expand Down
20 changes: 10 additions & 10 deletions src/items/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ impl IconMenuItem {
text: S,
enabled: bool,
icon: Option<Icon>,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
) -> Self {
let item = crate::platform_impl::MenuChild::new_icon(
text.as_ref(),
enabled,
icon,
acccelerator,
accelerator,
None,
);
Self {
Expand All @@ -70,7 +70,7 @@ impl IconMenuItem {
text: S,
enabled: bool,
icon: Option<Icon>,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
) -> Self {
let id = id.into();
Self {
Expand All @@ -79,7 +79,7 @@ impl IconMenuItem {
text.as_ref(),
enabled,
icon,
acccelerator,
accelerator,
Some(id),
))),
}
Expand All @@ -96,13 +96,13 @@ impl IconMenuItem {
text: S,
enabled: bool,
native_icon: Option<NativeIcon>,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
) -> Self {
let item = crate::platform_impl::MenuChild::new_native_icon(
text.as_ref(),
enabled,
native_icon,
acccelerator,
accelerator,
None,
);
Self {
Expand All @@ -123,7 +123,7 @@ impl IconMenuItem {
text: S,
enabled: bool,
native_icon: Option<NativeIcon>,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
) -> Self {
let id = id.into();
Self {
Expand All @@ -133,7 +133,7 @@ impl IconMenuItem {
text.as_ref(),
enabled,
native_icon,
acccelerator,
accelerator,
Some(id),
),
)),
Expand Down Expand Up @@ -168,8 +168,8 @@ impl IconMenuItem {
}

/// Set this icon menu item accelerator.
pub fn set_accelerator(&self, acccelerator: Option<Accelerator>) -> crate::Result<()> {
self.inner.borrow_mut().set_accelerator(acccelerator)
pub fn set_accelerator(&self, accelerator: Option<Accelerator>) -> crate::Result<()> {
self.inner.borrow_mut().set_accelerator(accelerator)
}

/// Change this menu item icon or remove it.
Expand Down
12 changes: 6 additions & 6 deletions src/items/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ impl MenuItem {
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn new<S: AsRef<str>>(text: S, enabled: bool, acccelerator: Option<Accelerator>) -> Self {
let item = crate::platform_impl::MenuChild::new(text.as_ref(), enabled, acccelerator, None);
pub fn new<S: AsRef<str>>(text: S, enabled: bool, accelerator: Option<Accelerator>) -> Self {
let item = crate::platform_impl::MenuChild::new(text.as_ref(), enabled, accelerator, None);
Self {
id: Rc::new(item.id().clone()),
inner: Rc::new(RefCell::new(item)),
Expand All @@ -48,15 +48,15 @@ impl MenuItem {
id: I,
text: S,
enabled: bool,
acccelerator: Option<Accelerator>,
accelerator: Option<Accelerator>,
) -> Self {
let id = id.into();
Self {
id: Rc::new(id.clone()),
inner: Rc::new(RefCell::new(crate::platform_impl::MenuChild::new(
text.as_ref(),
enabled,
acccelerator,
accelerator,
Some(id),
))),
}
Expand Down Expand Up @@ -90,8 +90,8 @@ impl MenuItem {
}

/// Set this menu item accelerator.
pub fn set_accelerator(&self, acccelerator: Option<Accelerator>) -> crate::Result<()> {
self.inner.borrow_mut().set_accelerator(acccelerator)
pub fn set_accelerator(&self, accelerator: Option<Accelerator>) -> crate::Result<()> {
self.inner.borrow_mut().set_accelerator(accelerator)
}

/// Convert this menu item into its menu ID.
Expand Down

0 comments on commit 40d06c5

Please sign in to comment.