Add Hello Plugin with settings pane and metadata
This commit is contained in:
commit
ec1456fe72
4 changed files with 115 additions and 0 deletions
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["plugins/ohn-plugin-hello"]
|
||||
|
||||
[workspace.dependencies]
|
||||
hotplug-meta = { path = "/Users/sam.storer/repos/hotplug/crates/hotplug-meta" }
|
||||
hotplug-macros = { path = "/Users/sam.storer/repos/hotplug/crates/hotplug-macros" }
|
||||
hotplug-build = { path = "/Users/sam.storer/repos/hotplug/crates/hotplug-build" }
|
||||
inventory = "0.3"
|
||||
gpui = "0.2"
|
||||
ohn-ui-plugin = { path = "/Users/sam.storer/repos/devism/crates/ohn-ui-plugin" }
|
||||
17
index.json
Normal file
17
index.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
{
|
||||
"id": "org.devism.hello-plugin",
|
||||
"name": "Hello Plugin",
|
||||
"description": "A greeting demo plugin for ohn — shows how to contribute a settings pane.",
|
||||
"versions": [
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"dependency_name": "ohn-plugin-hello",
|
||||
"api_versions": {
|
||||
"OhnUiPlugin": "1.0"
|
||||
},
|
||||
"download_url": "https://github.com/stoorps/ohn-plugins/archive/refs/heads/main.tar.gz"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
13
plugins/ohn-plugin-hello/Cargo.toml
Normal file
13
plugins/ohn-plugin-hello/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "ohn-plugin-hello"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[package.metadata.hotplug.api_versions]
|
||||
OhnUiPlugin = "1.0"
|
||||
|
||||
[dependencies]
|
||||
ohn-ui-plugin = { workspace = true }
|
||||
hotplug-meta = { workspace = true }
|
||||
inventory = { workspace = true }
|
||||
gpui = { workspace = true }
|
||||
74
plugins/ohn-plugin-hello/src/lib.rs
Normal file
74
plugins/ohn-plugin-hello/src/lib.rs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
use gpui::prelude::*;
|
||||
use gpui::*;
|
||||
use ohn_ui_plugin::{OhnUiPlugin, PluginSettingsPane, PluginSidePanel};
|
||||
|
||||
/// Hello Plugin — a minimal demo of contributing a settings pane via OhnUiPlugin.
|
||||
#[derive(Default)]
|
||||
pub struct HelloPlugin;
|
||||
|
||||
impl hotplug_meta::PluginMeta for HelloPlugin {
|
||||
fn id() -> &'static str {
|
||||
"org.devism.hello-plugin"
|
||||
}
|
||||
fn name() -> &'static str {
|
||||
"Hello Plugin"
|
||||
}
|
||||
fn version() -> &'static str {
|
||||
env!("CARGO_PKG_VERSION")
|
||||
}
|
||||
}
|
||||
|
||||
impl OhnUiPlugin for HelloPlugin {
|
||||
fn settings_pane(&self) -> Option<PluginSettingsPane> {
|
||||
Some(PluginSettingsPane {
|
||||
label: "Hello",
|
||||
icon_name: "star",
|
||||
build: std::sync::Arc::new(|_window, cx| cx.new(|_cx| HelloView).into()),
|
||||
})
|
||||
}
|
||||
|
||||
fn side_panel(&self) -> Option<PluginSidePanel> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
ohn_ui_plugin::register_ohn_ui_plugin!(HelloPlugin);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Settings pane view
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
struct HelloView;
|
||||
|
||||
impl Render for HelloView {
|
||||
fn render(
|
||||
&mut self,
|
||||
_window: &mut Window,
|
||||
_cx: &mut Context<Self>,
|
||||
) -> impl IntoElement {
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.gap(px(16.0))
|
||||
.p(px(40.0))
|
||||
.child(
|
||||
div()
|
||||
.text_size(px(28.0))
|
||||
.child("👋"),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.text_size(px(18.0))
|
||||
.font_weight(FontWeight::SEMIBOLD)
|
||||
.child("Hello from the Hello Plugin!"),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.text_size(px(13.0))
|
||||
.text_color(gpui::rgb(0x888888))
|
||||
.child("This demo plugin was installed via the hotplug registry."),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue