Detailed changes
@@ -2026,9 +2026,8 @@ impl Panel for Sidebar {
self.set_width(size, cx);
}
- fn icon(&self, _window: &Window, cx: &App) -> Option<IconName> {
- let settings = AgentSettings::get_global(cx);
- (settings.enabled(cx) && settings.button).then_some(IconName::ThreadsSidebarLeftClosed)
+ fn icon(&self, _window: &Window, _cx: &App) -> IconName {
+ IconName::ThreadsSidebarLeftClosed
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {
@@ -2044,7 +2043,8 @@ impl Panel for Sidebar {
}
fn enabled(&self, cx: &App) -> bool {
- AgentSettings::get_global(cx).enabled(cx)
+ let settings = AgentSettings::get_global(cx);
+ settings.enabled(cx) && settings.button
}
fn starts_open(&self, _window: &Window, _cx: &App) -> bool {
@@ -3191,16 +3191,18 @@ impl Panel for CollabPanel {
});
}
- fn icon(&self, _window: &Window, cx: &App) -> Option<ui::IconName> {
- CollaborationPanelSettings::get_global(cx)
- .button
- .then_some(ui::IconName::UserGroup)
+ fn icon(&self, _window: &Window, _cx: &App) -> ui::IconName {
+ ui::IconName::UserGroup
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {
"Collab Panel"
}
+ fn enabled(&self, cx: &App) -> bool {
+ CollaborationPanelSettings::get_global(cx).button
+ }
+
fn toggle_action(&self) -> Box<dyn gpui::Action> {
Box::new(ToggleFocus)
}
@@ -659,23 +659,22 @@ impl Panel for NotificationPanel {
}
}
- fn icon(&self, _: &Window, cx: &App) -> Option<IconName> {
- let show_button = NotificationPanelSettings::get_global(cx).button;
- if !show_button {
- return None;
- }
-
+ fn icon(&self, _: &Window, _cx: &App) -> IconName {
if self.unseen_notifications.is_empty() {
- return Some(IconName::Bell);
+ IconName::Bell
+ } else {
+ IconName::BellDot
}
-
- Some(IconName::BellDot)
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {
"Notification Panel"
}
+ fn enabled(&self, cx: &App) -> bool {
+ NotificationPanelSettings::get_global(cx).button
+ }
+
fn toggle_action(&self) -> Box<dyn gpui::Action> {
Box::new(ToggleFocus)
}
@@ -1579,16 +1579,18 @@ impl Panel for DebugPanel {
Some(proto::PanelId::DebugPanel)
}
- fn icon(&self, _window: &Window, cx: &App) -> Option<IconName> {
- DebuggerSettings::get_global(cx)
- .button
- .then_some(IconName::Debug)
+ fn icon(&self, _window: &Window, _cx: &App) -> IconName {
+ IconName::Debug
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {
"Debug Panel"
}
+ fn enabled(&self, cx: &App) -> bool {
+ DebuggerSettings::get_global(cx).button
+ }
+
fn toggle_action(&self) -> Box<dyn Action> {
Box::new(ToggleFocus)
}
@@ -5730,14 +5730,18 @@ impl Panel for GitPanel {
cx.notify();
}
- fn icon(&self, _: &Window, cx: &App) -> Option<ui::IconName> {
- Some(ui::IconName::GitBranchAlt).filter(|_| GitPanelSettings::get_global(cx).button)
+ fn icon(&self, _: &Window, _cx: &App) -> ui::IconName {
+ ui::IconName::GitBranchAlt
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {
"Git Panel"
}
+ fn enabled(&self, cx: &App) -> bool {
+ GitPanelSettings::get_global(cx).button
+ }
+
fn toggle_action(&self) -> Box<dyn Action> {
Box::new(ToggleFocus)
}
@@ -5017,16 +5017,18 @@ impl Panel for OutlinePanel {
});
}
- fn icon(&self, _: &Window, cx: &App) -> Option<IconName> {
- OutlinePanelSettings::get_global(cx)
- .button
- .then_some(IconName::ListTree)
+ fn icon(&self, _: &Window, _cx: &App) -> IconName {
+ IconName::ListTree
}
fn icon_tooltip(&self, _window: &Window, _: &App) -> &'static str {
"Outline Panel"
}
+ fn enabled(&self, cx: &App) -> bool {
+ OutlinePanelSettings::get_global(cx).button
+ }
+
fn toggle_action(&self) -> Box<dyn Action> {
Box::new(ToggleFocus)
}
@@ -7057,16 +7057,18 @@ impl Panel for ProjectPanel {
});
}
- fn icon(&self, _: &Window, cx: &App) -> Option<IconName> {
- ProjectPanelSettings::get_global(cx)
- .button
- .then_some(IconName::FileTree)
+ fn icon(&self, _: &Window, _cx: &App) -> IconName {
+ IconName::FileTree
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {
"Project Panel"
}
+ fn enabled(&self, cx: &App) -> bool {
+ ProjectPanelSettings::get_global(cx).button
+ }
+
fn toggle_action(&self) -> Box<dyn Action> {
Box::new(ToggleFocus)
}
@@ -1613,14 +1613,8 @@ impl Panel for TerminalPanel {
TERMINAL_PANEL_KEY
}
- fn icon(&self, _window: &Window, cx: &App) -> Option<IconName> {
- if (self.is_enabled(cx) || !self.has_no_terminals(cx))
- && TerminalSettings::get_global(cx).button
- {
- Some(IconName::TerminalAlt)
- } else {
- None
- }
+ fn icon(&self, _window: &Window, _cx: &App) -> IconName {
+ IconName::TerminalAlt
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {
@@ -1638,6 +1632,11 @@ impl Panel for TerminalPanel {
fn activation_priority(&self) -> u32 {
1
}
+
+ fn enabled(&self, cx: &App) -> bool {
+ (self.is_enabled(cx) || !self.has_no_terminals(cx))
+ && TerminalSettings::get_global(cx).button
+ }
}
struct TerminalProvider(Entity<TerminalPanel>);
@@ -34,7 +34,7 @@ pub trait Panel: Focusable + EventEmitter<PanelEvent> + Render + Sized {
fn set_position(&mut self, position: DockPosition, window: &mut Window, cx: &mut Context<Self>);
fn size(&self, window: &Window, cx: &App) -> Pixels;
fn set_size(&mut self, size: Option<Pixels>, window: &mut Window, cx: &mut Context<Self>);
- fn icon(&self, window: &Window, cx: &App) -> Option<ui::IconName>;
+ fn icon(&self, window: &Window, cx: &App) -> ui::IconName;
fn icon_tooltip(&self, window: &Window, cx: &App) -> &'static str;
fn toggle_action(&self) -> Box<dyn Action>;
fn is_zoomed(&self, _window: &Window, _cx: &App) -> bool {
@@ -71,7 +71,7 @@ pub trait PanelHandle: Send + Sync {
fn pane(&self, cx: &App) -> Option<Entity<Pane>>;
fn size(&self, window: &Window, cx: &App) -> Pixels;
fn set_size(&self, size: Option<Pixels>, window: &mut Window, cx: &mut App);
- fn icon(&self, window: &Window, cx: &App) -> Option<ui::IconName>;
+ fn icon(&self, window: &Window, cx: &App) -> ui::IconName;
fn icon_tooltip(&self, window: &Window, cx: &App) -> &'static str;
fn toggle_action(&self, window: &Window, cx: &App) -> Box<dyn Action>;
fn panel_focus_handle(&self, cx: &App) -> FocusHandle;
@@ -151,7 +151,7 @@ where
self.update(cx, |this, cx| this.set_size(size, window, cx))
}
- fn icon(&self, window: &Window, cx: &App) -> Option<ui::IconName> {
+ fn icon(&self, window: &Window, cx: &App) -> ui::IconName {
self.read(cx).icon(window, cx)
}
@@ -905,7 +905,10 @@ impl Render for PanelButtons {
.iter()
.enumerate()
.filter_map(|(i, entry)| {
- let icon = entry.panel.icon(window, cx)?;
+ if !entry.panel.enabled(cx) {
+ return None;
+ }
+ let icon = entry.panel.icon(window, cx);
let icon_tooltip = entry.panel.icon_tooltip(window, cx);
let name = entry.panel.persistent_name();
let panel = entry.panel.clone();
@@ -1070,8 +1073,8 @@ pub mod test {
self.size = size.unwrap_or(px(300.));
}
- fn icon(&self, _window: &Window, _: &App) -> Option<ui::IconName> {
- None
+ fn icon(&self, _window: &Window, _: &App) -> ui::IconName {
+ ui::IconName::Cog
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {