Merge pull request #213 from pop-os/fix-theme

fix: update libcosmic and load configured theme instead of defaults
This commit is contained in:
Jeremy Soller 2024-05-30 12:13:36 -06:00 • committed by GitHub
commit 15a4740634
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 35 deletions

33
Cargo.lock generated
View file

@ -1104,7 +1104,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.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"atomicwrites", "atomicwrites",
"cosmic-config-derive", "cosmic-config-derive",
@ -1123,7 +1123,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.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -1217,7 +1217,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.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"almost", "almost",
"cosmic-config", "cosmic-config",
@ -2487,7 +2487,7 @@ dependencies = [
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_accessibility", "iced_accessibility",
@ -2505,7 +2505,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.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"accesskit_winit", "accesskit_winit",
@ -2514,7 +2514,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"dnd", "dnd",
@ -2534,7 +2534,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"futures", "futures",
"iced_core", "iced_core",
@ -2547,7 +2547,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"bytemuck", "bytemuck",
@ -2571,7 +2571,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_renderer" name = "iced_renderer"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_tiny_skia", "iced_tiny_skia",
@ -2583,7 +2583,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_runtime" name = "iced_runtime"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_core", "iced_core",
@ -2595,7 +2595,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_style" name = "iced_style"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"once_cell", "once_cell",
@ -2605,7 +2605,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_tiny_skia" name = "iced_tiny_skia"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cosmic-text", "cosmic-text",
@ -2622,7 +2622,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_wgpu" name = "iced_wgpu"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"bytemuck", "bytemuck",
@ -2648,7 +2648,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_widget" name = "iced_widget"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_renderer", "iced_renderer",
@ -2664,7 +2664,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_winit" name = "iced_winit"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_graphics", "iced_graphics",
@ -3006,7 +3006,7 @@ source = "git+https://gitlab.redox-os.org/redox-os/liblibc.git?branch=redox-epol
[[package]] [[package]]
name = "libcosmic" name = "libcosmic"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic.git#8ecf1a8eddebaff0d562819d6f227e39d0e7b5a7" source = "git+https://github.com/pop-os/libcosmic.git#b937a30050a3012dc774478e344130df16db800b"
dependencies = [ dependencies = [
"apply", "apply",
"ashpd", "ashpd",
@ -3030,6 +3030,7 @@ dependencies = [
"lazy_static", "lazy_static",
"palette", "palette",
"rfd", "rfd",
"serde",
"slotmap", "slotmap",
"taffy", "taffy",
"thiserror", "thiserror",

View file

@ -27,8 +27,16 @@ pub enum AppTheme {
impl AppTheme { impl AppTheme {
pub fn theme(&self) -> theme::Theme { pub fn theme(&self) -> theme::Theme {
match self { match self {
Self::Dark => theme::Theme::dark(), Self::Dark => {
Self::Light => theme::Theme::light(), let mut t = theme::system_dark();
t.theme_type.prefer_dark(Some(true));
t
}
Self::Light => {
let mut t = theme::system_light();
t.theme_type.prefer_dark(Some(false));
t
}
Self::System => theme::system_preference(), Self::System => theme::system_preference(),
} }
} }

View file

@ -1,14 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
use cosmic::widget::menu::key_bind::KeyBind; use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::widget::menu::{items as menu_items, root as menu_root, Item as MenuItem}; use cosmic::widget::menu::{items as menu_items, menu_button, root as menu_root, Item as MenuItem};
use cosmic::{ use cosmic::{
iced::{ iced::{
widget::{column, horizontal_rule, horizontal_space}, widget::{column, horizontal_rule, horizontal_space},
Alignment, Background, Length, Background, Length,
}, },
iced_core::Border, iced_core::Border,
menu_button, theme, theme,
widget::{ widget::{
self, self,
menu::{ItemHeight, ItemWidth, MenuBar, Tree as MenuTree}, menu::{ItemHeight, ItemWidth, MenuBar, Tree as MenuTree},
@ -36,23 +36,24 @@ pub fn context_menu<'a>(
let menu_item = |label, action| { let menu_item = |label, action| {
let key = find_key(&action); let key = find_key(&action);
menu_button!( menu_button(vec![
widget::text(label), widget::text(label).into(),
horizontal_space(Length::Fill), horizontal_space(Length::Fill).into(),
widget::text(key) widget::text(key).into(),
) ])
.on_press(Message::TabContextAction(entity, action)) .on_press(Message::TabContextAction(entity, action))
}; };
let menu_checkbox = |label, value, action| { let menu_checkbox = |label, value, action| {
menu_button!( menu_button(vec![
widget::text(label), widget::text(label).into(),
widget::horizontal_space(Length::Fill), widget::horizontal_space(Length::Fill).into(),
widget::toggler(None, value, move |_| Message::TabContextAction( widget::toggler(None, value, move |_| {
entity, action Message::TabContextAction(entity, action)
)) })
.size(16.0), .size(16.0)
) .into(),
])
.on_press(Message::TabContextAction(entity, action)) .on_press(Message::TabContextAction(entity, action))
}; };
@ -99,7 +100,8 @@ pub fn color_scheme_menu<'a>(
id: ColorSchemeId, id: ColorSchemeId,
name: &str, name: &str,
) -> Element<'a, Message> { ) -> Element<'a, Message> {
let menu_item = |label, message| menu_button!(widget::text(label)).on_press(message); let menu_item =
|label, message| menu_button(vec![widget::text(label).into()]).on_press(message);
widget::container(column!( widget::container(column!(
menu_item( menu_item(