Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 enable / disable plugins #74

Merged
merged 8 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 83 additions & 19 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct Centerpiece {
query: String,
active_entry_index: usize,
plugins: Vec<model::Plugin>,
settings: settings::Settings,
}

pub const SCROLLABLE_ID: &str = "scrollable";
Expand All @@ -52,6 +53,7 @@ impl Application for Centerpiece {
query: String::from(""),
active_entry_index: 0,
plugins: vec![],
settings: settings::Settings::new(),
},
iced::Command::perform(async {}, move |()| Message::Loaded),
)
Expand Down Expand Up @@ -108,8 +110,8 @@ impl Application for Centerpiece {
}

fn subscription(&self) -> iced::Subscription<Self::Message> {
iced::subscription::Subscription::batch(vec![
iced::subscription::events_with(|event, _status| match event {
let mut subscriptions = vec![iced::subscription::events_with(
|event, _status| match event {
iced::Event::Keyboard(iced::keyboard::Event::KeyPressed {
modifiers: _,
key_code: _,
Expand All @@ -122,24 +124,86 @@ impl Application for Centerpiece {
Some(Message::Event(event))
}
_ => None,
}),
crate::plugin::utils::spawn::<crate::plugin::windows::WindowsPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::applications::ApplicationsPlugin>(),
crate::plugin::utils::spawn::<
},
)];

if self.settings.plugin.applications.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::applications::ApplicationsPlugin,
>());
}

if self.settings.plugin.brave_bookmarks.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::brave::bookmarks::BookmarksPlugin,
>());
}

if self.settings.plugin.brave_progressive_web_apps.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::brave::progressive_web_apps::ProgressiveWebAppsPlugin,
>(),
crate::plugin::utils::spawn::<crate::plugin::git_repositories::GitRepositoriesPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::brave::bookmarks::BookmarksPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::system::SystemPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::wifi::WifiPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::resource_monitor::battery::BatteryPlugin>(
),
crate::plugin::utils::spawn::<crate::plugin::resource_monitor::cpu::CpuPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::resource_monitor::memory::MemoryPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::resource_monitor::disks::DisksPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::clock::ClockPlugin>(),
crate::plugin::utils::spawn::<crate::plugin::brave::history::HistoryPlugin>(),
])
>());
}

if self.settings.plugin.brave_history.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::brave::history::HistoryPlugin,
>());
}

if self.settings.plugin.clock.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::clock::ClockPlugin,
>());
}

if self.settings.plugin.git_repositories.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::git_repositories::GitRepositoriesPlugin,
>());
}

if self.settings.plugin.resource_monitor_battery.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::resource_monitor::battery::BatteryPlugin,
>());
}

if self.settings.plugin.resource_monitor_cpu.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::resource_monitor::cpu::CpuPlugin,
>());
}

if self.settings.plugin.resource_monitor_disks.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::resource_monitor::disks::DisksPlugin,
>());
}

if self.settings.plugin.resource_monitor_memory.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::resource_monitor::memory::MemoryPlugin,
>());
}

if self.settings.plugin.system.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::system::SystemPlugin,
>());
}

if self.settings.plugin.wifi.enable {
subscriptions.push(crate::plugin::utils::spawn::<crate::plugin::wifi::WifiPlugin>());
}

if self.settings.plugin.windows.enable {
subscriptions.push(crate::plugin::utils::spawn::<
crate::plugin::windows::WindowsPlugin,
>());
}

iced::subscription::Subscription::batch(subscriptions)
}

fn view(&self) -> iced::Element<Message> {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/brave/bookmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct BookmarksPlugin {

impl Plugin for BookmarksPlugin {
fn id() -> &'static str {
"brave-bookmarks"
"brave_bookmarks"
}

fn priority() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/brave/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct HistoryPlugin {

impl Plugin for HistoryPlugin {
fn id() -> &'static str {
"brave-history"
"brave_history"
}

fn priority() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/brave/progressive_web_apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct ProgressiveWebAppsPlugin {

impl Plugin for ProgressiveWebAppsPlugin {
fn id() -> &'static str {
"brave-progressive-web-apps"
"brave_progressive_web_apps"
}

fn priority() -> u32 {
Expand Down
6 changes: 3 additions & 3 deletions client/src/plugin/git_repositories.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{plugin::utils::Plugin, settings::Settings};
use crate::plugin::utils::Plugin;
use anyhow::Context;

pub struct GitRepositoriesPlugin {
entries: Vec<crate::model::Entry>,
settings: Settings,
settings: crate::settings::Settings,
}

impl Plugin for GitRepositoriesPlugin {
Expand All @@ -26,7 +26,7 @@ impl Plugin for GitRepositoriesPlugin {
fn new() -> Self {
Self {
entries: vec![],
settings: Settings::new(),
settings: crate::settings::Settings::new(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/resource_monitor/battery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct BatteryPlugin {

impl Plugin for BatteryPlugin {
fn id() -> &'static str {
"battery"
"resource_monitor_battery"
}

fn priority() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/resource_monitor/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct CpuPlugin {

impl Plugin for CpuPlugin {
fn id() -> &'static str {
"cpu"
"resource_monitor_cpu"
}

fn priority() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/resource_monitor/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct DisksPlugin {

impl Plugin for DisksPlugin {
fn id() -> &'static str {
"disks"
"resource_monitor_disks"
}

fn priority() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/resource_monitor/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct MemoryPlugin {

impl Plugin for MemoryPlugin {
fn id() -> &'static str {
"memory"
"resource_monitor_memory"
}

fn priority() -> u32 {
Expand Down
Loading
Loading