panel_settings.rs

 1use anyhow;
 2use gpui::Pixels;
 3use schemars::JsonSchema;
 4use serde_derive::{Deserialize, Serialize};
 5use settings::Settings;
 6use workspace::dock::DockPosition;
 7
 8#[derive(Deserialize, Debug)]
 9pub struct CollaborationPanelSettings {
10    pub button: bool,
11    pub dock: DockPosition,
12    pub default_width: Pixels,
13}
14
15#[derive(Deserialize, Debug)]
16pub struct ChatPanelSettings {
17    pub button: bool,
18    pub dock: DockPosition,
19    pub default_width: Pixels,
20}
21
22#[derive(Deserialize, Debug)]
23pub struct NotificationPanelSettings {
24    pub button: bool,
25    pub dock: DockPosition,
26    pub default_width: Pixels,
27}
28
29#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
30pub struct PanelSettingsContent {
31    /// Whether to show the panel button in the status bar.
32    ///
33    /// Default: true
34    pub button: Option<bool>,
35    /// Where to dock the panel.
36    ///
37    /// Default: left
38    pub dock: Option<DockPosition>,
39    /// Default width of the panel in pixels.
40    ///
41    /// Default: 240
42    pub default_width: Option<f32>,
43}
44
45impl Settings for CollaborationPanelSettings {
46    const KEY: Option<&'static str> = Some("collaboration_panel");
47    type FileContent = PanelSettingsContent;
48    fn load(
49        default_value: &Self::FileContent,
50        user_values: &[&Self::FileContent],
51        _: &mut gpui::AppContext,
52    ) -> anyhow::Result<Self> {
53        Self::load_via_json_merge(default_value, user_values)
54    }
55}
56
57impl Settings for ChatPanelSettings {
58    const KEY: Option<&'static str> = Some("chat_panel");
59    type FileContent = PanelSettingsContent;
60    fn load(
61        default_value: &Self::FileContent,
62        user_values: &[&Self::FileContent],
63        _: &mut gpui::AppContext,
64    ) -> anyhow::Result<Self> {
65        Self::load_via_json_merge(default_value, user_values)
66    }
67}
68
69impl Settings for NotificationPanelSettings {
70    const KEY: Option<&'static str> = Some("notification_panel");
71    type FileContent = PanelSettingsContent;
72    fn load(
73        default_value: &Self::FileContent,
74        user_values: &[&Self::FileContent],
75        _: &mut gpui::AppContext,
76    ) -> anyhow::Result<Self> {
77        Self::load_via_json_merge(default_value, user_values)
78    }
79}