Remove AppState from workspace actions
This allows those actions to be bound to keystrokes in the keymap. Also, remove the WorkspaceParams struct, simplify how Workspaces are constructed.
This commit is contained in:
parent
7445197f4d
commit
ef0b584532
21 changed files with 335 additions and 486 deletions
|
@ -7,7 +7,7 @@ use picker::{Picker, PickerDelegate};
|
|||
use settings::Settings;
|
||||
use std::sync::Arc;
|
||||
use theme::{Theme, ThemeRegistry};
|
||||
use workspace::Workspace;
|
||||
use workspace::{AppState, Workspace};
|
||||
|
||||
pub struct ThemeSelector {
|
||||
registry: Arc<ThemeRegistry>,
|
||||
|
@ -21,9 +21,14 @@ pub struct ThemeSelector {
|
|||
|
||||
actions!(theme_selector, [Toggle, Reload]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
cx.add_action(ThemeSelector::toggle);
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||
Picker::<ThemeSelector>::init(cx);
|
||||
cx.add_action({
|
||||
let theme_registry = app_state.themes.clone();
|
||||
move |workspace, _: &Toggle, cx| {
|
||||
ThemeSelector::toggle(workspace, theme_registry.clone(), cx)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub enum Event {
|
||||
|
@ -63,8 +68,11 @@ impl ThemeSelector {
|
|||
this
|
||||
}
|
||||
|
||||
fn toggle(workspace: &mut Workspace, _: &Toggle, cx: &mut ViewContext<Workspace>) {
|
||||
let themes = workspace.themes();
|
||||
fn toggle(
|
||||
workspace: &mut Workspace,
|
||||
themes: Arc<ThemeRegistry>,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
workspace.toggle_modal(cx, |_, cx| {
|
||||
let this = cx.add_view(|cx| Self::new(themes, cx));
|
||||
cx.subscribe(&this, Self::on_event).detach();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue