Rename app_state to global in gpui

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-03-17 14:33:01 +01:00
parent 84bacc556f
commit 44d997c00c
24 changed files with 91 additions and 89 deletions

View file

@ -116,7 +116,7 @@ impl View for LspStatus {
}
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
let theme = &cx.app_state::<Settings>().theme;
let theme = &cx.global::<Settings>().theme;
let mut pending_work = self.pending_language_server_work(cx);
if let Some((lang_server_name, progress_token, progress)) = pending_work.next() {
@ -166,7 +166,7 @@ impl View for LspStatus {
} else if !self.failed.is_empty() {
drop(pending_work);
MouseEventHandler::new::<Self, _, _>(0, cx, |_, cx| {
let theme = &cx.app_state::<Settings>().theme;
let theme = &cx.global::<Settings>().theme;
Label::new(
format!(
"Failed to download {} language server{}. Click to dismiss.",

View file

@ -513,7 +513,7 @@ impl Pane {
}
fn render_tabs(&self, cx: &mut RenderContext<Self>) -> ElementBox {
let theme = cx.app_state::<Settings>().theme.clone();
let theme = cx.global::<Settings>().theme.clone();
enum Tabs {}
let tabs = MouseEventHandler::new::<Tabs, _, _>(0, cx, |mouse_state, cx| {

View file

@ -38,7 +38,7 @@ impl View for StatusBar {
}
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
let theme = &cx.app_state::<Settings>().theme.workspace.status_bar;
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
Flex::row()
.with_children(self.left_items.iter().map(|i| {
ChildView::new(i.as_ref())

View file

@ -109,7 +109,7 @@ where
V: Item,
F: 'static + Fn(ModelHandle<Project>, ModelHandle<Buffer>, &mut ViewContext<V>) -> V,
{
cx.add_app_state::<BuildEditor>(Arc::new(move |window_id, project, model, cx| {
cx.set_global::<BuildEditor>(Arc::new(move |window_id, project, model, cx| {
Box::new(cx.add_view(window_id, |cx| build_editor(project, model, cx)))
}));
}
@ -371,7 +371,7 @@ impl WorkspaceParams {
#[cfg(any(test, feature = "test-support"))]
pub fn test(cx: &mut MutableAppContext) -> Self {
let settings = Settings::test(cx);
cx.add_app_state(settings);
cx.set_global(settings);
let fs = project::FakeFs::new(cx.background().clone());
let languages = Arc::new(LanguageRegistry::test());
@ -825,7 +825,7 @@ impl Workspace {
.ok_or_else(|| anyhow!("buffer has no entry"))
})?;
let (window_id, build_editor) = this.update(&mut cx, |_, cx| {
(cx.window_id(), cx.app_state::<BuildEditor>().clone())
(cx.window_id(), cx.global::<BuildEditor>().clone())
});
let build_editor =
move |cx: &mut MutableAppContext| build_editor(window_id, project, buffer, cx);
@ -948,7 +948,7 @@ impl Workspace {
}
fn render_connection_status(&self, cx: &mut RenderContext<Self>) -> Option<ElementBox> {
let theme = &cx.app_state::<Settings>().theme;
let theme = &cx.global::<Settings>().theme;
match &*self.client.status().borrow() {
client::Status::ConnectionError
| client::Status::ConnectionLost
@ -1134,7 +1134,7 @@ impl Workspace {
fn render_disconnected_overlay(&self, cx: &AppContext) -> Option<ElementBox> {
if self.project.read(cx).is_read_only() {
let theme = &cx.app_state::<Settings>().theme;
let theme = &cx.global::<Settings>().theme;
Some(
EventHandler::new(
Label::new(
@ -1165,7 +1165,7 @@ impl View for Workspace {
}
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
let theme = cx.app_state::<Settings>().theme.clone();
let theme = cx.global::<Settings>().theme.clone();
Stack::new()
.with_child(
Flex::column()