1use gpui::{prelude::*, Action};
2
3use ui::prelude::*;
4
5use crate::window_controls::{WindowControl, WindowControlType};
6
7#[derive(IntoElement)]
8pub struct LinuxWindowControls {
9 close_window_action: Box<dyn Action>,
10}
11
12impl LinuxWindowControls {
13 pub fn new(close_window_action: Box<dyn Action>) -> Self {
14 Self {
15 close_window_action,
16 }
17 }
18}
19
20impl RenderOnce for LinuxWindowControls {
21 fn render(self, cx: &mut WindowContext) -> impl IntoElement {
22 h_flex()
23 .id("generic-window-controls")
24 .px_3()
25 .gap_3()
26 .child(WindowControl::new(
27 "minimize",
28 WindowControlType::Minimize,
29 cx,
30 ))
31 .child(WindowControl::new(
32 "maximize-or-restore",
33 if cx.is_maximized() {
34 WindowControlType::Restore
35 } else {
36 WindowControlType::Maximize
37 },
38 cx,
39 ))
40 .child(WindowControl::new_close(
41 "close",
42 WindowControlType::Close,
43 self.close_window_action,
44 cx,
45 ))
46 }
47}