Skip to content

Commit f072ff9

Browse files
committed
Fix bug add icon
1 parent 8acf3b0 commit f072ff9

5 files changed

Lines changed: 41 additions & 30 deletions

File tree

assets/dock_icon.png

323 KB
Loading

media/icon.png

145 KB
Loading

src/main.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ mod ui;
88

99
use std::env::args;
1010

11-
use crate::ui::App;
1211
use anyhow::Result;
1312
use context::Context as ContextType;
1413
use mcp::run_server;
@@ -17,7 +16,7 @@ use tracing::{error, info};
1716
use tracing_subscriber::{
1817
EnvFilter, Layer, fmt::format::PrettyFields, layer::SubscriberExt, util::SubscriberInitExt,
1918
};
20-
use ui::apply_theme;
19+
use ui::run_ui;
2120

2221
#[tokio::main]
2322
async fn main() -> Result<()> {
@@ -104,29 +103,3 @@ async fn main() -> Result<()> {
104103

105104
Ok(())
106105
}
107-
108-
fn run_ui(
109-
context: context::Context,
110-
receiver: flume::Receiver<context::ContextNotification>,
111-
project_descriptions: Vec<ui::ProjectDescription>,
112-
) -> Result<()> {
113-
// Configure eframe options (window title, size, etc.)
114-
let options = eframe::NativeOptions {
115-
viewport: egui::ViewportBuilder::default()
116-
.with_inner_size([1100.0, 800.0]) // Default window size
117-
.with_min_inner_size([400.0, 300.0]), // Minimum window size
118-
..Default::default()
119-
};
120-
121-
let app = App::new(context, receiver, project_descriptions);
122-
123-
eframe::run_native(
124-
"Cursor Rust Tools",
125-
options,
126-
Box::new(|cc| {
127-
apply_theme(&cc.egui_ctx);
128-
Ok(Box::new(app))
129-
}),
130-
)
131-
.map_err(|e| anyhow::anyhow!("Failed to run eframe: {}", e))
132-
}

src/ui/app.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ impl App {
7979

8080
// If its a lsp, ignore because there's a lot of them
8181
if matches!(notification, ContextNotification::Lsp(_)) {
82+
has_new_events = true;
8283
continue;
8384
}
8485
// Otherwise, we have a new event

src/ui/mod.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,43 @@ mod app;
22
mod log;
33
mod theme;
44

5-
pub use app::App;
5+
use std::sync::Arc;
6+
7+
use anyhow::Result;
8+
use app::App;
9+
use flume::Receiver;
10+
use theme::apply_theme;
11+
12+
use crate::context::Context;
13+
use crate::context::ContextNotification;
14+
615
pub use app::ProjectDescription;
7-
pub use theme::apply_theme;
16+
17+
pub fn run_ui(
18+
context: Context,
19+
receiver: Receiver<ContextNotification>,
20+
project_descriptions: Vec<ProjectDescription>,
21+
) -> Result<()> {
22+
let d = eframe::icon_data::from_png_bytes(include_bytes!("../../assets/dock_icon.png"))
23+
.expect("The icon data must be valid");
24+
// Configure eframe options (window title, size, etc.)
25+
let mut options = eframe::NativeOptions {
26+
viewport: egui::ViewportBuilder::default()
27+
.with_inner_size([1100.0, 800.0]) // Default window size
28+
.with_min_inner_size([400.0, 300.0]), // Minimum window size
29+
..Default::default()
30+
};
31+
options.viewport.icon = Some(Arc::new(d));
32+
33+
let app = App::new(context, receiver, project_descriptions);
34+
35+
eframe::run_native(
36+
"Cursor Rust Tools",
37+
options,
38+
Box::new(|cc| {
39+
apply_theme(&cc.egui_ctx);
40+
Ok(Box::new(app))
41+
}),
42+
)
43+
.map_err(|e| anyhow::anyhow!("Failed to run eframe: {}", e))
44+
}

0 commit comments

Comments
 (0)