Files
oak-gpui/crates/search/src/search_status_button.rs
T
Kirill Bulatov a3105c92a4 Allow to hide more buttons with the settings (#30565)
* project search button in the status bar
```jsonc
"search": {
  "button": false
},
```

* project diagnostics button in the status bar
```jsonc
"diagnostics": {
  "button": false
}
```

* project name and host buttons in the title bar
```jsonc
"title_bar": {
    "show_project_items": false
}
```

* git branch button in the title bar
```jsonc
"title_bar": {
    "show_branch_name": false
}
```

Before:
<img width="1728" alt="before"
src="https://github.com/user-attachments/assets/4b13b431-3ac1-43b3-8ac7-469e5a9ccf7e"
/>

After:
<img width="1728" alt="after"
src="https://github.com/user-attachments/assets/baf2765a-e27b-47a3-8897-89152b7a7c95"
/>


Release Notes:

- Added more settings to hide buttons from Zed UI
2025-05-12 13:34:52 +00:00

55 lines
1.6 KiB
Rust

use editor::EditorSettings;
use settings::Settings as _;
use ui::{
ButtonCommon, ButtonLike, Clickable, Color, Context, Icon, IconName, IconSize, ParentElement,
Render, Styled, Tooltip, Window, h_flex,
};
use workspace::{ItemHandle, StatusItemView};
pub struct SearchButton;
impl SearchButton {
pub fn new() -> Self {
Self {}
}
}
impl Render for SearchButton {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl ui::IntoElement {
let button = h_flex().gap_2();
if !EditorSettings::get_global(cx).search.button {
return button;
}
button.child(
ButtonLike::new("project-search-indicator")
.child(
Icon::new(IconName::MagnifyingGlass)
.size(IconSize::Small)
.color(Color::Default),
)
.tooltip(|window, cx| {
Tooltip::for_action(
"Project Search",
&workspace::DeploySearch::default(),
window,
cx,
)
})
.on_click(cx.listener(|_this, _, window, cx| {
window.dispatch_action(Box::new(workspace::DeploySearch::default()), cx);
})),
)
}
}
impl StatusItemView for SearchButton {
fn set_active_pane_item(
&mut self,
_active_pane_item: Option<&dyn ItemHandle>,
_window: &mut Window,
_cx: &mut Context<Self>,
) {
}
}