Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export more internals so muda can be used in combination with ksni #239

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

dfaust
Copy link

@dfaust dfaust commented Nov 1, 2024

I had to expose a few internals and add some image conversion functions to make muda work with my ksni patch for the tray-icon crate.

Companion PR for tray-icon:
Replace libappindicator with ksni: tauri-apps/tray-icon#201

Tauri issue:
[feat] Use ksni crate for tray icons on Linux: tauri-apps/tauri#11293

src/icon.rs Outdated Show resolved Hide resolved
src/items/icon.rs Outdated Show resolved Hide resolved
src/items/icon.rs Outdated Show resolved Hide resolved
src/items/icon.rs Outdated Show resolved Hide resolved
src/items/icon.rs Outdated Show resolved Hide resolved
src/items/icon.rs Outdated Show resolved Hide resolved
src/items/icon.rs Outdated Show resolved Hide resolved
src/items/predefined.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the long delay

}
}

pub fn strip_accelerator(text: impl AsRef<str>) -> String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this meant to remove mnemonic? if so, we need to keep &&

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to keep &&, or turn it into &?

Btw. the .replace("[~~]", "&") in to_gtk_mnemonic is redundant.

Copy link
Member

@amrbashir amrbashir Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to keep &&, or turn it into &?

it should turn into &

Btw. the .replace("[~~]", "&") in to_gtk_mnemonic is redundant.

actually that one is correct, .replace("[~~]", "&&") is the redundant one

src/items/icon.rs Outdated Show resolved Hide resolved
if let Some(handler) = MENU_EVENT_HANDLER.get_or_init(|| None) {
handler(event);
} else {
let _ = MENU_CHANNEL.0.send(event);
}
}
}

#[cfg(feature = "ksni")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should also be cfg'd behind linux-only target and same for all related logic

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that. But it feels a bit redundant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should result in faster compile times on other platforms, no?

src/items/compat.rs Outdated Show resolved Hide resolved
Comment on lines +260 to +263
#[cfg(target_os = "macos")]
pub fn set_native_icon(&self, icon: Option<NativeIcon>) {
let mut item = self.inner.borrow_mut();
item.set_native_icon(icon);
Copy link
Member

@amrbashir amrbashir Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use a single function so documentation is not duplicated

Suggested change
#[cfg(target_os = "macos")]
pub fn set_native_icon(&self, icon: Option<NativeIcon>) {
let mut item = self.inner.borrow_mut();
item.set_native_icon(icon);
pub fn set_native_icon(&self, _icon: Option<NativeIcon>) {
#[cfg(target_os = "macos")]
self.inner.borrow_mut().set_native_icon(_icon)

Comment on lines +266 to +273
/// Change this menu item icon to a native image or remove it.
///
/// ## Platform-specific:
///
/// - **Windows / Linux**: Unsupported.
#[cfg(not(target_os = "macos"))]
pub fn set_native_icon(&self, _icon: Option<NativeIcon>) {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then let's remove this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants