Open history and settings pages

This commit is contained in:
2026-05-07 21:00:51 -04:00
parent 4d50946072
commit 3fe737adad
6 changed files with 90 additions and 14 deletions
+25 -11
View File
@@ -6,8 +6,9 @@ use gpui::{App, AppContext, Context, Entity, FocusHandle, Focusable, Subscriptio
use gpui_component::input::{InputEvent, InputState, SelectAll};
use crate::{
CloseCurrentTab, FocusAddressBar, FocusCommandMode, OpenDownloads, OpenNewTab,
RestoreClosedTab, SelectNextTab, SelectPreviousTab, ToggleFavoriteTab, TogglePinnedTab,
CloseCurrentTab, FocusAddressBar, FocusCommandMode, OpenDownloads, OpenHistory, OpenNewTab,
OpenSettings, RestoreClosedTab, SelectNextTab, SelectPreviousTab, ToggleFavoriteTab,
TogglePinnedTab,
};
enum ShellState {
@@ -80,19 +81,24 @@ impl ElyShell {
}
fn open_new_tab(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if let ShellState::Ready(core) = &mut self.state
&& let Ok(url) = UrlText::parse("ely://new-tab")
{
core.open_tab(url);
self.sync_address_input(window, cx);
self.focus_address_bar(window, cx);
cx.notify();
}
self.open_internal_tab("ely://new-tab", window, cx);
}
fn open_downloads(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.open_internal_tab("ely://downloads", window, cx);
}
fn open_history(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.open_internal_tab("ely://history", window, cx);
}
fn open_settings(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.open_internal_tab("ely://settings", window, cx);
}
fn open_internal_tab(&mut self, url_text: &str, window: &mut Window, cx: &mut Context<Self>) {
if let ShellState::Ready(core) = &mut self.state
&& let Ok(url) = UrlText::parse("ely://downloads")
&& let Ok(url) = UrlText::parse(url_text)
{
core.open_tab(url);
self.sync_address_input(window, cx);
@@ -244,6 +250,14 @@ impl ElyShell {
self.open_downloads(window, cx);
}
fn on_open_history(&mut self, _: &OpenHistory, window: &mut Window, cx: &mut Context<Self>) {
self.open_history(window, cx);
}
fn on_open_settings(&mut self, _: &OpenSettings, window: &mut Window, cx: &mut Context<Self>) {
self.open_settings(window, cx);
}
fn on_restore_closed_tab(
&mut self,
_: &RestoreClosedTab,
+2
View File
@@ -39,7 +39,9 @@ impl ElyShell {
.on_action(cx.listener(Self::on_focus_address_bar))
.on_action(cx.listener(Self::on_focus_command_mode))
.on_action(cx.listener(Self::on_open_downloads))
.on_action(cx.listener(Self::on_open_history))
.on_action(cx.listener(Self::on_open_new_tab))
.on_action(cx.listener(Self::on_open_settings))
.on_action(cx.listener(Self::on_restore_closed_tab))
.on_action(cx.listener(Self::on_select_next_tab))
.on_action(cx.listener(Self::on_select_previous_tab))