
### TODO - [x] Make sure keybinding shows up in pane + menu - [x] Selection tool in the editor toolbar - [x] Application Menu - [x] Add more options to pane + menu - Go to File... - Go to Symbol in Project... - [x] Add go items to the selection tool in the editor: - Go to Symbol in Editor... - Go to Line/Column... - Next Problem - Previous Problem - [x] Fix a bug where modals opened from a context menu aren't focused correclty - [x] Determine if or what needs to be done with project actions: - Difficulty is that these are exposed in the UI via clicking the project name in the titlebar or by right clicking the root entry in the project panel. But they require reading and are two clicks away. Is that sufficient? - Add Folder to Project - Open a new project - Open recent - [x] Get a style pass - [x] Implement style pass - [x] Fix the wrong actions in the selection menu - [x] Show selection tool toggle in the 'editor settings' thing - [x] Put preferences section from the app menu onto the right hand user menu - [x] Add Project menu into app menu to replace 'preferences' section, and put the rest of the actions there - [ ] ~~Adopt `...` convention for opening a surface~~ uncertain what this convention is. - [x] Adopt link styling for webview actions - [x] Set lucide hamburger for menu icon - [x] Gate application menu to only show on Linux and Windows Release Notes: - Added a 'selection and movement' tool to the Editor's toolbar, as well as controls to toggle it and a setting to remove it (`"toolbar": {"selections_menu": true/false }`) - Changed the behavior of the `+` menu in the tab bar to use standard actions and keybindings. Replaced 'New Center Terminal' with 'New Terminal', and 'New Search', with the usual 'Deploy Search'. Also added item-creating actions to this menu. - Added an 'application' menu to the titlebar to Linux and Windows builds of Zed
135 lines
4.8 KiB
Rust
135 lines
4.8 KiB
Rust
use crate::notification_window_options;
|
|
use crate::notifications::collab_notification::CollabNotification;
|
|
use call::{ActiveCall, IncomingCall};
|
|
use futures::StreamExt;
|
|
use gpui::{prelude::*, AppContext, WindowHandle};
|
|
|
|
use std::sync::{Arc, Weak};
|
|
use ui::{prelude::*, Button, Label};
|
|
use util::ResultExt;
|
|
use workspace::AppState;
|
|
|
|
pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
|
let app_state = Arc::downgrade(app_state);
|
|
let mut incoming_call = ActiveCall::global(cx).read(cx).incoming();
|
|
cx.spawn(|mut cx| async move {
|
|
let mut notification_windows: Vec<WindowHandle<IncomingCallNotification>> = Vec::new();
|
|
while let Some(incoming_call) = incoming_call.next().await {
|
|
for window in notification_windows.drain(..) {
|
|
window
|
|
.update(&mut cx, |_, cx| {
|
|
cx.remove_window();
|
|
})
|
|
.log_err();
|
|
}
|
|
|
|
if let Some(incoming_call) = incoming_call {
|
|
let unique_screens = cx.update(|cx| cx.displays()).unwrap();
|
|
let window_size = gpui::Size {
|
|
width: px(400.),
|
|
height: px(72.),
|
|
};
|
|
|
|
for screen in unique_screens {
|
|
if let Some(options) = cx
|
|
.update(|cx| notification_window_options(screen, window_size, cx))
|
|
.log_err()
|
|
{
|
|
let window = cx
|
|
.open_window(options, |cx| {
|
|
cx.new_view(|_| {
|
|
IncomingCallNotification::new(
|
|
incoming_call.clone(),
|
|
app_state.clone(),
|
|
)
|
|
})
|
|
})
|
|
.unwrap();
|
|
notification_windows.push(window);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
.detach();
|
|
}
|
|
|
|
struct IncomingCallNotificationState {
|
|
call: IncomingCall,
|
|
app_state: Weak<AppState>,
|
|
}
|
|
|
|
pub struct IncomingCallNotification {
|
|
state: Arc<IncomingCallNotificationState>,
|
|
}
|
|
impl IncomingCallNotificationState {
|
|
pub fn new(call: IncomingCall, app_state: Weak<AppState>) -> Self {
|
|
Self { call, app_state }
|
|
}
|
|
|
|
fn respond(&self, accept: bool, cx: &mut AppContext) {
|
|
let active_call = ActiveCall::global(cx);
|
|
if accept {
|
|
let join = active_call.update(cx, |active_call, cx| active_call.accept_incoming(cx));
|
|
let caller_user_id = self.call.calling_user.id;
|
|
let initial_project_id = self.call.initial_project.as_ref().map(|project| project.id);
|
|
let app_state = self.app_state.clone();
|
|
let cx: &mut AppContext = cx;
|
|
cx.spawn(|cx| async move {
|
|
join.await?;
|
|
if let Some(project_id) = initial_project_id {
|
|
cx.update(|cx| {
|
|
if let Some(app_state) = app_state.upgrade() {
|
|
workspace::join_in_room_project(
|
|
project_id,
|
|
caller_user_id,
|
|
app_state,
|
|
cx,
|
|
)
|
|
.detach_and_log_err(cx);
|
|
}
|
|
})
|
|
.log_err();
|
|
}
|
|
anyhow::Ok(())
|
|
})
|
|
.detach_and_log_err(cx);
|
|
} else {
|
|
active_call.update(cx, |active_call, cx| {
|
|
active_call.decline_incoming(cx).log_err();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
impl IncomingCallNotification {
|
|
pub fn new(call: IncomingCall, app_state: Weak<AppState>) -> Self {
|
|
Self {
|
|
state: Arc::new(IncomingCallNotificationState::new(call, app_state)),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Render for IncomingCallNotification {
|
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
|
let ui_font = theme::setup_ui_font(cx);
|
|
|
|
div().size_full().font(ui_font).child(
|
|
CollabNotification::new(
|
|
self.state.call.calling_user.avatar_uri.clone(),
|
|
Button::new("accept", "Accept").on_click({
|
|
let state = self.state.clone();
|
|
move |_, cx| state.respond(true, cx)
|
|
}),
|
|
Button::new("decline", "Decline").on_click({
|
|
let state = self.state.clone();
|
|
move |_, cx| state.respond(false, cx)
|
|
}),
|
|
)
|
|
.child(v_flex().overflow_hidden().child(Label::new(format!(
|
|
"{} is sharing a project in Zed",
|
|
self.state.call.calling_user.github_login
|
|
)))),
|
|
)
|
|
}
|
|
}
|