refactor: single-instance impl
This commit is contained in:
parent
8b1a0c95f0
commit
ec8661065c
3 changed files with 52 additions and 59 deletions
32
Cargo.lock
generated
32
Cargo.lock
generated
|
|
@ -964,7 +964,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomicwrites",
|
"atomicwrites",
|
||||||
"calloop",
|
"calloop",
|
||||||
|
|
@ -979,7 +979,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
|
|
@ -1130,7 +1130,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"almost",
|
"almost",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -2320,7 +2320,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2335,7 +2335,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_unix",
|
"accesskit_unix",
|
||||||
|
|
@ -2344,7 +2344,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
|
|
@ -2360,7 +2360,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2373,7 +2373,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2391,7 +2391,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
|
@ -2404,7 +2404,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2416,7 +2416,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_sctk"
|
name = "iced_sctk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"enum-repr",
|
"enum-repr",
|
||||||
"float-cmp",
|
"float-cmp",
|
||||||
|
|
@ -2440,7 +2440,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -2450,7 +2450,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
|
|
@ -2468,7 +2468,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2490,7 +2490,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_renderer",
|
"iced_renderer",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2889,7 +2889,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#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"ashpd 0.5.0",
|
"ashpd 0.5.0",
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ git = "https://github.com/pop-os/cosmic-panel"
|
||||||
# libcosmic = { path = "../libcosmic" }
|
# libcosmic = { path = "../libcosmic" }
|
||||||
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
||||||
|
|
||||||
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "single-instance" }
|
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "refactor-single-instance" }
|
||||||
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "single-instance"}
|
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "refactor-single-instance"}
|
||||||
|
|
||||||
[patch."https://github.com/Smithay/client-toolkit"]
|
[patch."https://github.com/Smithay/client-toolkit"]
|
||||||
sctk = { git = "https://github.com/smithay/client-toolkit//", package = "smithay-client-toolkit", rev = "e63ab5f"}
|
sctk = { git = "https://github.com/smithay/client-toolkit//", package = "smithay-client-toolkit", rev = "e63ab5f"}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,23 @@
|
||||||
// Copyright 2023 System76 <info@system76.com>
|
// Copyright 2023 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use cosmic::app::DbusActivationDetails;
|
use crate::config::Config;
|
||||||
|
use crate::pages::desktop::appearance::COLOR_PICKER_DIALOG_ID;
|
||||||
|
use crate::pages::desktop::{
|
||||||
|
self, appearance,
|
||||||
|
dock::{self, applets::ADD_DOCK_APPLET_DIALOGUE_ID},
|
||||||
|
panel::{
|
||||||
|
self,
|
||||||
|
applets_inner::{self, AppletsPage, APPLET_DND_ICON_ID},
|
||||||
|
inner as _panel,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use crate::pages::input::{self, keyboard};
|
||||||
|
use crate::pages::{sound, system, time};
|
||||||
|
use crate::subscription::desktop_files;
|
||||||
|
use crate::widget::{page_title, search_header};
|
||||||
|
use crate::PageCommands;
|
||||||
|
use cosmic::app::DbusActivationMessage;
|
||||||
use cosmic::iced::Subscription;
|
use cosmic::iced::Subscription;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
app::{Command, Core},
|
app::{Command, Core},
|
||||||
|
|
@ -17,25 +33,7 @@ use cosmic::{
|
||||||
use cosmic_panel_config::CosmicPanelConfig;
|
use cosmic_panel_config::CosmicPanelConfig;
|
||||||
use cosmic_settings_page::{self as page, section};
|
use cosmic_settings_page::{self as page, section};
|
||||||
use page::Entity;
|
use page::Entity;
|
||||||
|
use std::{borrow::Cow, str::FromStr};
|
||||||
use crate::config::Config;
|
|
||||||
use crate::PageCommands;
|
|
||||||
|
|
||||||
use crate::pages::desktop::appearance::COLOR_PICKER_DIALOG_ID;
|
|
||||||
use crate::pages::desktop::{
|
|
||||||
self, appearance,
|
|
||||||
dock::{self, applets::ADD_DOCK_APPLET_DIALOGUE_ID},
|
|
||||||
panel::{
|
|
||||||
self,
|
|
||||||
applets_inner::{self, AppletsPage, APPLET_DND_ICON_ID},
|
|
||||||
inner as _panel,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use crate::pages::input::{self, keyboard};
|
|
||||||
use crate::pages::{sound, system, time};
|
|
||||||
use crate::subscription::desktop_files;
|
|
||||||
use crate::widget::{page_title, search_header};
|
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
#[allow(clippy::module_name_repetitions)]
|
#[allow(clippy::module_name_repetitions)]
|
||||||
|
|
@ -50,7 +48,7 @@ pub struct SettingsApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SettingsApp {
|
impl SettingsApp {
|
||||||
fn subcommand_to_page(&self, cmd: PageCommands) -> Option<Entity> {
|
fn subcommand_to_page(&self, cmd: &PageCommands) -> Option<Entity> {
|
||||||
match cmd {
|
match cmd {
|
||||||
// PageCommands::Bluetooth => self.pages.page_id::<system::bluetooth::Page>(),
|
// PageCommands::Bluetooth => self.pages.page_id::<system::bluetooth::Page>(),
|
||||||
// PageCommands::Network => self.pages.page_id::<system::network::Page>(),
|
// PageCommands::Network => self.pages.page_id::<system::network::Page>(),
|
||||||
|
|
@ -75,13 +73,6 @@ pub enum Message {
|
||||||
OpenContextDrawer(Cow<'static, str>),
|
OpenContextDrawer(Cow<'static, str>),
|
||||||
CloseContextDrawer,
|
CloseContextDrawer,
|
||||||
SetTheme(cosmic::theme::Theme),
|
SetTheme(cosmic::theme::Theme),
|
||||||
DbusActivation(DbusActivationDetails<PageCommands, Vec<String>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DbusActivationDetails<PageCommands, Vec<String>>> for Message {
|
|
||||||
fn from(msg: DbusActivationDetails<PageCommands, Vec<String>>) -> Self {
|
|
||||||
Message::DbusActivation(msg)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cosmic::Application for SettingsApp {
|
impl cosmic::Application for SettingsApp {
|
||||||
|
|
@ -117,7 +108,7 @@ impl cosmic::Application for SettingsApp {
|
||||||
app.insert_page::<input::Page>();
|
app.insert_page::<input::Page>();
|
||||||
|
|
||||||
let active_id = match flags.subcommand {
|
let active_id = match flags.subcommand {
|
||||||
Some(p) => app.subcommand_to_page(p),
|
Some(p) => app.subcommand_to_page(&p),
|
||||||
None => app
|
None => app
|
||||||
.pages
|
.pages
|
||||||
.find_page_by_id(&app.config.active_page)
|
.find_page_by_id(&app.config.active_page)
|
||||||
|
|
@ -349,23 +340,25 @@ impl cosmic::Application for SettingsApp {
|
||||||
Message::CloseContextDrawer => {
|
Message::CloseContextDrawer => {
|
||||||
self.core.window.show_context = false;
|
self.core.window.show_context = false;
|
||||||
}
|
}
|
||||||
Message::DbusActivation(msg) => {
|
|
||||||
let mut cmds = Vec::with_capacity(1);
|
|
||||||
|
|
||||||
// if action was passed, use it to change the page
|
|
||||||
if let DbusActivationDetails::ActivateAction { action, .. } = msg {
|
|
||||||
if let Some(p) = self.subcommand_to_page(action) {
|
|
||||||
cmds.push(self.activate_page(p));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Command::batch(cmds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dbus_activation(&mut self, msg: DbusActivationMessage) -> Command<Self::Message> {
|
||||||
|
match msg.msg {
|
||||||
|
cosmic::app::DbusActivationDetails::Activate
|
||||||
|
| cosmic::app::DbusActivationDetails::Open { .. } => None,
|
||||||
|
cosmic::app::DbusActivationDetails::ActivateAction { action, .. } => {
|
||||||
|
PageCommands::from_str(&action)
|
||||||
|
.ok()
|
||||||
|
.and_then(|action| self.subcommand_to_page(&action))
|
||||||
|
.map(|e| self.activate_page(e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.unwrap_or_else(Command::none)
|
||||||
|
}
|
||||||
|
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&self) -> Element<Message> {
|
||||||
let page_view = if self.search.is_active() {
|
let page_view = if self.search.is_active() {
|
||||||
self.search_view()
|
self.search_view()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue