mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-24 01:51:57 +03:00
fix devtools on release builds
This commit is contained in:
parent
ed7fd43874
commit
fa06586cdf
1
.github/workflows/push.yaml
vendored
1
.github/workflows/push.yaml
vendored
@ -115,6 +115,7 @@ jobs:
|
||||
- check-tests
|
||||
features:
|
||||
- ''
|
||||
- [devtools]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/check-crate
|
||||
|
@ -31,26 +31,30 @@ pub async fn menu_item_set_enabled(
|
||||
}
|
||||
|
||||
pub fn build(package_info: &PackageInfo) -> Menu {
|
||||
#[allow(unused_mut)]
|
||||
let mut menu = Menu::os_default(&package_info.name).add_submenu(Submenu::new(
|
||||
"Project",
|
||||
Menu::with_items([disabled_menu_item("project/settings", "Project Settings")]),
|
||||
));
|
||||
|
||||
// Try to find the View menu and attach the dev tools item
|
||||
let view_menu = menu.items.iter_mut().find(|item| match item {
|
||||
MenuEntry::CustomItem(_) => false,
|
||||
MenuEntry::Submenu(submenu) => submenu.title == "View",
|
||||
MenuEntry::NativeItem(_) => false,
|
||||
});
|
||||
#[cfg(any(debug_assertions, feature = "devtools"))]
|
||||
{
|
||||
// Try to find the View menu and attach the dev tools item
|
||||
let view_menu = menu.items.iter_mut().find(|item| match item {
|
||||
MenuEntry::CustomItem(_) => false,
|
||||
MenuEntry::Submenu(submenu) => submenu.title == "View",
|
||||
MenuEntry::NativeItem(_) => false,
|
||||
});
|
||||
|
||||
let devtools = CustomMenuItem::new("view/devtools", "Developer Tools");
|
||||
if let Some(MenuEntry::Submenu(view_menu)) = view_menu {
|
||||
view_menu.inner.items.push(devtools.into());
|
||||
} else {
|
||||
menu = menu.add_submenu(Submenu::new(
|
||||
"Developer",
|
||||
Menu::with_items([devtools.into()]),
|
||||
));
|
||||
let devtools = CustomMenuItem::new("view/devtools", "Developer Tools");
|
||||
if let Some(MenuEntry::Submenu(view_menu)) = view_menu {
|
||||
view_menu.inner.items.push(devtools.into());
|
||||
} else {
|
||||
menu = menu.add_submenu(Submenu::new(
|
||||
"Developer",
|
||||
Menu::with_items([devtools.into()]),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
menu
|
||||
@ -63,8 +67,11 @@ fn disabled_menu_item(id: &str, title: &str) -> MenuEntry {
|
||||
}
|
||||
|
||||
pub fn handle_event<R: Runtime>(event: &WindowMenuEvent<R>) {
|
||||
if event.menu_item_id() == "view/devtools" {
|
||||
event.window().open_devtools();
|
||||
#[cfg(any(debug_assertions, feature = "devtools"))]
|
||||
{
|
||||
if event.menu_item_id() == "view/devtools" {
|
||||
event.window().open_devtools();
|
||||
}
|
||||
}
|
||||
emit(
|
||||
event.window(),
|
||||
|
Loading…
Reference in New Issue
Block a user