Open downloads from command bar
This commit is contained in:
@@ -6,7 +6,7 @@ use gpui::{App, AppContext, Context, Entity, FocusHandle, Focusable, Subscriptio
|
||||
use gpui_component::input::{InputEvent, InputState, SelectAll};
|
||||
|
||||
use crate::{
|
||||
CloseCurrentTab, FocusAddressBar, OpenNewTab, RestoreClosedTab, SelectNextTab,
|
||||
CloseCurrentTab, FocusAddressBar, OpenDownloads, OpenNewTab, RestoreClosedTab, SelectNextTab,
|
||||
SelectPreviousTab, ToggleFavoriteTab, TogglePinnedTab,
|
||||
};
|
||||
|
||||
@@ -90,6 +90,17 @@ impl ElyShell {
|
||||
}
|
||||
}
|
||||
|
||||
fn open_downloads(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if let ShellState::Ready(core) = &mut self.state
|
||||
&& let Ok(url) = UrlText::parse("ely://downloads")
|
||||
{
|
||||
core.open_tab(url);
|
||||
self.sync_address_input(window, cx);
|
||||
self.focus_address_bar(window, cx);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
fn focus_address_bar(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.command_input.update(cx, |input, cx| {
|
||||
input.focus(window, cx);
|
||||
@@ -203,6 +214,15 @@ impl ElyShell {
|
||||
self.open_new_tab(window, cx);
|
||||
}
|
||||
|
||||
fn on_open_downloads(
|
||||
&mut self,
|
||||
_: &OpenDownloads,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.open_downloads(window, cx);
|
||||
}
|
||||
|
||||
fn on_restore_closed_tab(
|
||||
&mut self,
|
||||
_: &RestoreClosedTab,
|
||||
|
||||
Reference in New Issue
Block a user