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
+8
View File
@@ -14,7 +14,9 @@ actions!(
FocusAddressBar,
FocusCommandMode,
OpenDownloads,
OpenHistory,
OpenNewTab,
OpenSettings,
Quit,
RestoreClosedTab,
SelectNextTab,
@@ -33,6 +35,10 @@ fn main() {
KeyBinding::new("ctrl-t", OpenNewTab, None),
KeyBinding::new("cmd-shift-j", OpenDownloads, None),
KeyBinding::new("ctrl-shift-j", OpenDownloads, None),
KeyBinding::new("cmd-y", OpenHistory, None),
KeyBinding::new("ctrl-h", OpenHistory, None),
KeyBinding::new("cmd-,", OpenSettings, None),
KeyBinding::new("ctrl-,", OpenSettings, None),
KeyBinding::new("cmd-l", FocusAddressBar, None),
KeyBinding::new("ctrl-l", FocusAddressBar, None),
KeyBinding::new("cmd-w", CloseCurrentTab, None),
@@ -70,6 +76,8 @@ fn main() {
MenuItem::action("Restore Closed Tab", RestoreClosedTab),
MenuItem::separator(),
MenuItem::action("Open Downloads", OpenDownloads),
MenuItem::action("Open History", OpenHistory),
MenuItem::action("Open Settings", OpenSettings),
MenuItem::separator(),
MenuItem::action("Toggle Pin", TogglePinnedTab),
],
+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))