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]]
|
||||
name = "cosmic-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"atomicwrites",
|
||||
"calloop",
|
||||
|
|
@ -979,7 +979,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
|
|
@ -1130,7 +1130,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"almost",
|
||||
"cosmic-config",
|
||||
|
|
@ -2320,7 +2320,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"iced_accessibility",
|
||||
"iced_core",
|
||||
|
|
@ -2335,7 +2335,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_accessibility"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_unix",
|
||||
|
|
@ -2344,7 +2344,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_core"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"iced_accessibility",
|
||||
|
|
@ -2360,7 +2360,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_futures"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"iced_core",
|
||||
|
|
@ -2373,7 +2373,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_graphics"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bytemuck",
|
||||
|
|
@ -2391,7 +2391,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_renderer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_tiny_skia",
|
||||
|
|
@ -2404,7 +2404,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_runtime"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"iced_accessibility",
|
||||
"iced_core",
|
||||
|
|
@ -2416,7 +2416,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_sctk"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"enum-repr",
|
||||
"float-cmp",
|
||||
|
|
@ -2440,7 +2440,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_style"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"iced_core",
|
||||
"once_cell",
|
||||
|
|
@ -2450,7 +2450,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_tiny_skia"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cosmic-text",
|
||||
|
|
@ -2468,7 +2468,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_wgpu"
|
||||
version = "0.11.1"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bytemuck",
|
||||
|
|
@ -2490,7 +2490,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_widget"
|
||||
version = "0.1.3"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"iced_renderer",
|
||||
"iced_runtime",
|
||||
|
|
@ -2889,7 +2889,7 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
|||
[[package]]
|
||||
name = "libcosmic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#70d54d6f2071fbcd2ab29045a7945b2bb6bc2f22"
|
||||
source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
|
||||
dependencies = [
|
||||
"apply",
|
||||
"ashpd 0.5.0",
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ git = "https://github.com/pop-os/cosmic-panel"
|
|||
# libcosmic = { path = "../libcosmic" }
|
||||
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
||||
|
||||
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "single-instance" }
|
||||
# cosmic-config = { 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 = "refactor-single-instance"}
|
||||
|
||||
[patch."https://github.com/Smithay/client-toolkit"]
|
||||
sctk = { git = "https://github.com/smithay/client-toolkit//", package = "smithay-client-toolkit", rev = "e63ab5f"}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,23 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// 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::{
|
||||
app::{Command, Core},
|
||||
|
|
@ -17,25 +33,7 @@ use cosmic::{
|
|||
use cosmic_panel_config::CosmicPanelConfig;
|
||||
use cosmic_settings_page::{self as page, section};
|
||||
use page::Entity;
|
||||
|
||||
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;
|
||||
use std::{borrow::Cow, str::FromStr};
|
||||
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
|
|
@ -50,7 +48,7 @@ pub struct SettingsApp {
|
|||
}
|
||||
|
||||
impl SettingsApp {
|
||||
fn subcommand_to_page(&self, cmd: PageCommands) -> Option<Entity> {
|
||||
fn subcommand_to_page(&self, cmd: &PageCommands) -> Option<Entity> {
|
||||
match cmd {
|
||||
// PageCommands::Bluetooth => self.pages.page_id::<system::bluetooth::Page>(),
|
||||
// PageCommands::Network => self.pages.page_id::<system::network::Page>(),
|
||||
|
|
@ -75,13 +73,6 @@ pub enum Message {
|
|||
OpenContextDrawer(Cow<'static, str>),
|
||||
CloseContextDrawer,
|
||||
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 {
|
||||
|
|
@ -117,7 +108,7 @@ impl cosmic::Application for SettingsApp {
|
|||
app.insert_page::<input::Page>();
|
||||
|
||||
let active_id = match flags.subcommand {
|
||||
Some(p) => app.subcommand_to_page(p),
|
||||
Some(p) => app.subcommand_to_page(&p),
|
||||
None => app
|
||||
.pages
|
||||
.find_page_by_id(&app.config.active_page)
|
||||
|
|
@ -349,23 +340,25 @@ impl cosmic::Application for SettingsApp {
|
|||
Message::CloseContextDrawer => {
|
||||
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()
|
||||
}
|
||||
|
||||
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> {
|
||||
let page_view = if self.search.is_active() {
|
||||
self.search_view()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue