Add ids for subscriptions
This commit is contained in:
parent
78714e81aa
commit
518e791593
2 changed files with 84 additions and 72 deletions
34
Cargo.lock
generated
34
Cargo.lock
generated
|
|
@ -956,7 +956,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config"
|
name = "cosmic-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomicwrites",
|
"atomicwrites",
|
||||||
"cosmic-config-derive",
|
"cosmic-config-derive",
|
||||||
|
|
@ -970,7 +970,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config-derive"
|
name = "cosmic-config-derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
|
|
@ -1043,7 +1043,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-theme"
|
name = "cosmic-theme"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"almost",
|
"almost",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -2399,7 +2399,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2414,7 +2414,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_accessibility"
|
name = "iced_accessibility"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_winit",
|
"accesskit_winit",
|
||||||
|
|
@ -2423,7 +2423,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"instant",
|
"instant",
|
||||||
|
|
@ -2437,7 +2437,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2450,7 +2450,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2468,7 +2468,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_renderer"
|
name = "iced_renderer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
|
@ -2481,7 +2481,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_runtime"
|
name = "iced_runtime"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
|
|
@ -2491,7 +2491,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_style"
|
name = "iced_style"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -2501,7 +2501,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_tiny_skia"
|
name = "iced_tiny_skia"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text 0.9.0",
|
"cosmic-text 0.9.0",
|
||||||
|
|
@ -2519,7 +2519,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2541,7 +2541,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_widget"
|
name = "iced_widget"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_renderer",
|
"iced_renderer",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2555,7 +2555,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_winit"
|
name = "iced_winit"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2853,7 +2853,7 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#001fd744c5f80c9ce058eb0e22ae92f19d12c844"
|
source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"ashpd",
|
"ashpd",
|
||||||
|
|
@ -5044,7 +5044,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "taffy"
|
name = "taffy"
|
||||||
version = "0.3.11"
|
version = "0.3.11"
|
||||||
source = "git+https://github.com/DioxusLabs/taffy#1876f72bee5e376023eaa518aa7b8a34c769bd1b"
|
source = "git+https://github.com/DioxusLabs/taffy?rev=7781c70#7781c70241f7f572130c13106f2a869a9cf80885"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.7.4",
|
"arrayvec 0.7.4",
|
||||||
"grid",
|
"grid",
|
||||||
|
|
|
||||||
122
src/main.rs
122
src/main.rs
|
|
@ -17,6 +17,7 @@ use cosmic::{
|
||||||
};
|
};
|
||||||
use cosmic_text::{Cursor, Edit, Family, FontSystem, SwashCache, SyntaxSystem, ViMode};
|
use cosmic_text::{Cursor, Edit, Family, FontSystem, SwashCache, SyntaxSystem, ViMode};
|
||||||
use std::{
|
use std::{
|
||||||
|
any::TypeId,
|
||||||
env, fs,
|
env, fs,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process,
|
process,
|
||||||
|
|
@ -1180,6 +1181,10 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscription(&self) -> subscription::Subscription<Message> {
|
fn subscription(&self) -> subscription::Subscription<Message> {
|
||||||
|
struct WatcherSubscription;
|
||||||
|
struct ConfigSubscription;
|
||||||
|
struct ThemeSubscription;
|
||||||
|
|
||||||
subscription::Subscription::batch([
|
subscription::Subscription::batch([
|
||||||
subscription::events_with(|event, _status| match event {
|
subscription::events_with(|event, _status| match event {
|
||||||
event::Event::Keyboard(keyboard::Event::KeyPressed {
|
event::Event::Keyboard(keyboard::Event::KeyPressed {
|
||||||
|
|
@ -1188,74 +1193,81 @@ impl Application for App {
|
||||||
}) => Some(Message::Key(modifiers, key_code)),
|
}) => Some(Message::Key(modifiers, key_code)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}),
|
}),
|
||||||
subscription::channel(0, 100, |mut output| async move {
|
subscription::channel(
|
||||||
let watcher_res = {
|
TypeId::of::<WatcherSubscription>(),
|
||||||
let mut output = output.clone();
|
100,
|
||||||
notify::recommended_watcher(
|
|mut output| async move {
|
||||||
move |event_res: Result<notify::Event, notify::Error>| match event_res {
|
let watcher_res = {
|
||||||
Ok(event) => {
|
let mut output = output.clone();
|
||||||
match &event.kind {
|
notify::recommended_watcher(
|
||||||
notify::EventKind::Access(_)
|
move |event_res: Result<notify::Event, notify::Error>| match event_res {
|
||||||
| notify::EventKind::Modify(
|
Ok(event) => {
|
||||||
notify::event::ModifyKind::Metadata(_),
|
match &event.kind {
|
||||||
) => {
|
notify::EventKind::Access(_)
|
||||||
// Data not mutated
|
| notify::EventKind::Modify(
|
||||||
return;
|
notify::event::ModifyKind::Metadata(_),
|
||||||
|
) => {
|
||||||
|
// Data not mutated
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
match futures::executor::block_on(async {
|
match futures::executor::block_on(async {
|
||||||
output.send(Message::NotifyEvent(event)).await
|
output.send(Message::NotifyEvent(event)).await
|
||||||
}) {
|
}) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::warn!("failed to send notify event: {:?}", err);
|
log::warn!("failed to send notify event: {:?}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
Err(err) => {
|
||||||
Err(err) => {
|
log::warn!("failed to watch files: {:?}", err);
|
||||||
log::warn!("failed to watch files: {:?}", err);
|
}
|
||||||
}
|
},
|
||||||
},
|
)
|
||||||
)
|
};
|
||||||
};
|
|
||||||
|
|
||||||
match watcher_res {
|
match watcher_res {
|
||||||
Ok(watcher) => {
|
Ok(watcher) => {
|
||||||
match output
|
match output
|
||||||
.send(Message::NotifyWatcher(WatcherWrapper {
|
.send(Message::NotifyWatcher(WatcherWrapper {
|
||||||
watcher_opt: Some(watcher),
|
watcher_opt: Some(watcher),
|
||||||
}))
|
}))
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::warn!("failed to send notify watcher: {:?}", err);
|
log::warn!("failed to send notify watcher: {:?}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::warn!("failed to create file watcher: {:?}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
|
||||||
log::warn!("failed to create file watcher: {:?}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: how to properly kill this task?
|
//TODO: how to properly kill this task?
|
||||||
loop {
|
loop {
|
||||||
time::sleep(time::Duration::new(1, 0)).await;
|
time::sleep(time::Duration::new(1, 0)).await;
|
||||||
}
|
|
||||||
}),
|
|
||||||
cosmic_config::config_subscription(0, Self::APP_ID.into(), CONFIG_VERSION).map(
|
|
||||||
|(_, res)| match res {
|
|
||||||
Ok(config) => Message::Config(config),
|
|
||||||
Err((errs, config)) => {
|
|
||||||
log::warn!("errors loading config: {:#?}", errs);
|
|
||||||
Message::Config(config)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
cosmic_config::config_subscription(
|
||||||
|
TypeId::of::<ConfigSubscription>(),
|
||||||
|
Self::APP_ID.into(),
|
||||||
|
CONFIG_VERSION,
|
||||||
|
)
|
||||||
|
.map(|(_, res)| match res {
|
||||||
|
Ok(config) => Message::Config(config),
|
||||||
|
Err((errs, config)) => {
|
||||||
|
log::warn!("errors loading config: {:#?}", errs);
|
||||||
|
Message::Config(config)
|
||||||
|
}
|
||||||
|
}),
|
||||||
cosmic_config::config_subscription::<_, cosmic_theme::ThemeMode>(
|
cosmic_config::config_subscription::<_, cosmic_theme::ThemeMode>(
|
||||||
0,
|
TypeId::of::<ThemeSubscription>(),
|
||||||
cosmic_theme::THEME_MODE_ID.into(),
|
cosmic_theme::THEME_MODE_ID.into(),
|
||||||
cosmic_theme::ThemeMode::version(),
|
cosmic_theme::ThemeMode::version(),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue