Add welcome crate and associated types

Mikayla Maki created

Change summary

Cargo.lock                    | 15 ++++++++++
Cargo.toml                    |  1 
crates/welcome/Cargo.toml     | 21 +++++++++++++++
crates/welcome/src/welcome.rs | 51 +++++++++++++++++++++++++++++++++++++
crates/zed/Cargo.toml         |  1 
crates/zed/src/main.rs        |  1 
6 files changed, 90 insertions(+)

Detailed changes

Cargo.lock 🔗

@@ -8013,6 +8013,20 @@ version = "0.1.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
 
+[[package]]
+name = "welcome"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "gpui",
+ "log",
+ "project",
+ "settings",
+ "theme",
+ "util",
+ "workspace",
+]
+
 [[package]]
 name = "wepoll-ffi"
 version = "0.1.2"
@@ -8459,6 +8473,7 @@ dependencies = [
  "util",
  "uuid 1.2.2",
  "vim",
+ "welcome",
  "workspace",
 ]
 

Cargo.toml 🔗

@@ -58,6 +58,7 @@ members = [
     "crates/util",
     "crates/vim",
     "crates/workspace",
+    "crates/welcome",
     "crates/zed",
 ]
 default-members = ["crates/zed"]

crates/welcome/Cargo.toml 🔗

@@ -0,0 +1,21 @@
+[package]
+name = "welcome"
+version = "0.1.0"
+edition = "2021"
+publish = false
+
+[lib]
+path = "src/welcome.rs"
+
+[features]
+test-support = []
+
+[dependencies]
+anyhow = "1.0.38"
+log = "0.4"
+gpui = { path = "../gpui" }
+project = { path = "../project" }
+settings = { path = "../settings" }
+theme = { path = "../theme" }
+util = { path = "../util" }
+workspace = { path = "../workspace" }

crates/welcome/src/welcome.rs 🔗

@@ -0,0 +1,51 @@
+use gpui::{
+    actions,
+    elements::{Flex, Label, ParentElement},
+    Element, Entity, MutableAppContext, View,
+};
+use settings::Settings;
+use workspace::{item::Item, Workspace};
+
+actions!(welcome, [ShowWelcome]);
+
+pub fn init(cx: &mut MutableAppContext) {
+    cx.add_action(|workspace: &mut Workspace, _: &ShowWelcome, cx| {
+        let welcome_page = cx.add_view(|_cx| WelcomePage);
+        workspace.add_item(Box::new(welcome_page), cx)
+    })
+}
+
+struct WelcomePage;
+
+impl Entity for WelcomePage {
+    type Event = ();
+}
+
+impl View for WelcomePage {
+    fn ui_name() -> &'static str {
+        "WelcomePage"
+    }
+
+    fn render(&mut self, cx: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
+        let theme = &cx.global::<Settings>().theme;
+        Label::new("Welcome page", theme.editor.hover_popover.prose.clone()).boxed()
+    }
+}
+
+impl Item for WelcomePage {
+    fn tab_content(
+        &self,
+        _detail: Option<usize>,
+        style: &theme::Tab,
+        _cx: &gpui::AppContext,
+    ) -> gpui::ElementBox {
+        Flex::row()
+            .with_child(
+                Label::new("Welcome to Zed!", style.label.clone())
+                    .aligned()
+                    .contained()
+                    .boxed(),
+            )
+            .boxed()
+    }
+}

crates/zed/Cargo.toml 🔗

@@ -58,6 +58,7 @@ theme_testbench = { path = "../theme_testbench" }
 util = { path = "../util" }
 vim = { path = "../vim" }
 workspace = { path = "../workspace" }
+welcome = { path = "../welcome" }
 anyhow = "1.0.38"
 async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
 async-tar = "0.4.2"

crates/zed/src/main.rs 🔗

@@ -189,6 +189,7 @@ fn main() {
         zed::init(&app_state, cx);
         collab_ui::init(app_state.clone(), cx);
         feedback::init(app_state.clone(), cx);
+        welcome::init(cx);
 
         cx.set_menus(menus::menus());