1use editor::EditorSettings;
2use settings::Settings as _;
3use ui::{ButtonCommon, Clickable, Context, Render, Tooltip, Window, prelude::*};
4use workspace::{ItemHandle, StatusItemView};
5
6pub struct SearchButton;
7
8impl SearchButton {
9 pub fn new() -> Self {
10 Self {}
11 }
12}
13
14impl Render for SearchButton {
15 fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl ui::IntoElement {
16 let button = div();
17
18 if !EditorSettings::get_global(cx).search.button {
19 return button.w_0().invisible();
20 }
21
22 button.child(
23 IconButton::new("project-search-indicator", IconName::MagnifyingGlass)
24 .icon_size(IconSize::Small)
25 .tooltip(|window, cx| {
26 Tooltip::for_action(
27 "Project Search",
28 &workspace::DeploySearch::default(),
29 window,
30 cx,
31 )
32 })
33 .on_click(cx.listener(|_this, _, window, cx| {
34 window.dispatch_action(Box::new(workspace::DeploySearch::default()), cx);
35 })),
36 )
37 }
38}
39
40impl StatusItemView for SearchButton {
41 fn set_active_pane_item(
42 &mut self,
43 _active_pane_item: Option<&dyn ItemHandle>,
44 _window: &mut Window,
45 _cx: &mut Context<Self>,
46 ) {
47 }
48}