Update libcosmic

This commit is contained in:
Eduardo Flores 2023-09-18 00:24:21 -07:00 committed by Ashley Wulber
parent 3353dc95ac
commit c7b25daa71
22 changed files with 1049 additions and 715 deletions

View file

@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
libcosmic.workspace = true
cosmic-time.workspace = true
once_cell = "1"
i18n-embed = { version = "0.14.0", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.7.0"

View file

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07, custom)"
sodipodi:docname="pop-shell-auto-off-symbolic.svg"
width="16.031464"
version="1.1"
style="enable-background:new"
id="svg7384"
height="16">
<sodipodi:namedview
inkscape:current-layer="svg7384"
inkscape:window-maximized="0"
inkscape:window-y="23"
inkscape:window-x="26"
inkscape:cy="7.8736667"
inkscape:cx="5.4863836"
inkscape:zoom="47.743848"
showgrid="true"
id="namedview26"
inkscape:window-height="1032"
inkscape:window-width="1904"
inkscape:pageshadow="2"
inkscape:pageopacity="0"
guidetolerance="10"
gridtolerance="10"
objecttolerance="10"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffff"
inkscape:snap-intersection-paths="true"
inkscape:snap-smooth-nodes="true"
inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid834" />
</sodipodi:namedview>
<metadata
id="metadata90">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Pop Symbolic Icon Theme</dc:title>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<title
id="title8473">Pop Symbolic Icon Theme</title>
<defs
id="defs7386">
<linearGradient
osb:paint="solid"
id="linearGradient8297">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop8295" />
</linearGradient>
<linearGradient
osb:paint="solid"
id="linearGradient6882">
<stop
style="stop-color:#555555;stop-opacity:1;"
offset="0"
id="stop6884" />
</linearGradient>
<linearGradient
osb:paint="solid"
id="linearGradient5606">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop5608" />
</linearGradient>
<filter
style="color-interpolation-filters:sRGB"
id="filter7554">
<feBlend
mode="darken"
in2="BackgroundImage"
id="feBlend7556" />
</filter>
</defs>
<g
transform="translate(-1124.0002,555.55128)"
style="display:inline"
id="layer9" />
<g
transform="translate(-1124.0002,555.55128)"
style="display:inline;filter:url(#filter7554)"
id="layer10" />
<g
transform="translate(-883,-61.448718)"
style="display:inline"
id="layer1" />
<g
transform="translate(-1124.0002,555.55128)"
style="display:inline"
id="layer14" />
<g
transform="translate(-1124.0002,555.55128)"
style="display:inline"
id="layer15" />
<g
transform="translate(-1124.0002,555.55128)"
style="display:inline"
id="g71291" />
<g
transform="translate(-883,88.551282)"
style="display:inline"
id="layer2" />
<g
transform="translate(-1124.0002,555.55128)"
style="display:inline"
id="layer12" />
<path
style="fill:#4c5263;fill-opacity:0.988327;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 11,9.5512818 v 1.1992192 c 0,0.979903 -0.820878,1.800781 -1.800781,1.800781 H 4 v 1.199219 c 0,0.4432 0.3575812,0.800781 0.8007812,0.800781 H 13.199219 C 13.642419,14.551282 14,14.193701 14,13.750501 V 9.5512818 Z"
id="rect3162"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csscsssscc" />
<path
style="fill:#4c5263;fill-opacity:0.988327;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 6.8007812,1.5512818 C 6.3575812,1.5512818 6,1.908863 6,2.352063 v 1.1992188 h 3.199219 c 0.979903,0 1.777249,0.8211611 1.800781,1.8007812 v 3.1992188 h 4.199219 C 15.642419,8.5512818 16,8.1937006 16,7.7505006 V 2.352063 c 0,-0.4432 -0.357581,-0.8007812 -0.800781,-0.8007812 z"
id="rect3160"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sscsscsssss" />
<rect
height="7"
id="rect3158"
ry="0.80000001"
style="fill:#4c5263;fill-opacity:0.988327;stroke:none;stroke-width:113.386;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
width="10"
x="0"
y="4.5512819" />
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

View file

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07, custom)"
sodipodi:docname="pop-shell-auto-on-symbolic.svg"
width="16.031464"
version="1.1"
style="enable-background:new"
id="svg7384"
height="16">
<sodipodi:namedview
inkscape:current-layer="svg7384"
inkscape:window-maximized="1"
inkscape:window-y="0"
inkscape:window-x="0"
inkscape:cy="8.1513747"
inkscape:cx="5.7085514"
inkscape:zoom="51.17"
showgrid="false"
id="namedview26"
inkscape:window-height="1048"
inkscape:window-width="1920"
inkscape:pageshadow="2"
inkscape:pageopacity="0"
guidetolerance="10"
gridtolerance="10"
objecttolerance="10"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffff"
inkscape:document-rotation="0" />
<metadata
id="metadata90">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Pop Symbolic Icon Theme</dc:title>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<title
id="title8473">Pop Symbolic Icon Theme</title>
<defs
id="defs7386">
<linearGradient
osb:paint="solid"
id="linearGradient8297">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop8295" />
</linearGradient>
<linearGradient
osb:paint="solid"
id="linearGradient6882">
<stop
style="stop-color:#555555;stop-opacity:1;"
offset="0"
id="stop6884" />
</linearGradient>
<linearGradient
osb:paint="solid"
id="linearGradient5606">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop5608" />
</linearGradient>
<filter
style="color-interpolation-filters:sRGB"
id="filter7554">
<feBlend
mode="darken"
in2="BackgroundImage"
id="feBlend7556" />
</filter>
</defs>
<g
transform="translate(-1124.0002,555)"
style="display:inline"
id="layer9" />
<g
transform="translate(-1124.0002,555)"
style="display:inline;filter:url(#filter7554)"
id="layer10" />
<g
transform="translate(-883,-62)"
style="display:inline"
id="layer1" />
<g
transform="translate(-1124.0002,555)"
style="display:inline"
id="layer14" />
<g
transform="translate(-1124.0002,555)"
style="display:inline"
id="layer15" />
<g
transform="translate(-1124.0002,555)"
style="display:inline"
id="g71291" />
<g
transform="translate(-883,88)"
style="display:inline"
id="layer2" />
<rect
height="8.9525318"
id="rect3158"
ry="0.65109324"
style="fill:#4c5263;fill-opacity:0.988327;stroke:none;stroke-width:102.291;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
width="7"
x="0"
y="3.9999995" />
<rect
height="4.0693326"
id="rect3160"
ry="0.65109324"
style="fill:#4c5263;fill-opacity:0.988327;stroke:none;stroke-width:102.291;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
width="8"
x="8"
y="3.9999995" />
<rect
height="4.0693326"
id="rect3162"
ry="0.65109324"
style="fill:#4c5263;fill-opacity:0.988327;stroke:none;stroke-width:102.291;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
width="8"
x="8"
y="8.8831997" />
<g
transform="translate(-1124.0002,555)"
style="display:inline"
id="layer12" />
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -1,41 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="applet-graphics-mode">
<rect id="Rectangle 47" x="4" y="4" width="8" height="8" fill="#232323"/>
<g id="Rectangle 48">
<path d="M4 0.75C4 0.75 4 0 5 0C6 0 6 0.75 6 0.75V3H4V0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 54">
<path d="M0.75 6C0.75 6 0 6 0 5C0 4 0.75 4 0.75 4H3V6H0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 57">
<path d="M15.25 6C15.25 6 16 6 16 5C16 4 15.25 4 15.25 4H13V6H15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 51">
<path d="M4 15.25C4 15.25 4 16 5 16C6 16 6 15.25 6 15.25V13H4V15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 49">
<path d="M7 0.75C7 0.75 7 0 8 0C9 0 9 0.75 9 0.75V3H7V0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 55">
<path d="M0.75 9C0.75 9 0 9 0 8C0 7 0.75 7 0.75 7H3V9H0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 58">
<path d="M15.25 9C15.25 9 16 9 16 8C16 7 15.25 7 15.25 7H13V9H15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 52">
<path d="M7 15.25C7 15.25 7 16 8 16C9 16 9 15.25 9 15.25V13H7V15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 50">
<path d="M10 0.75C10 0.75 10 0 11 0C12 0 12 0.75 12 0.75V3H10V0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 56">
<path d="M0.75 12C0.75 12 0 12 0 11C0 10 0.75 10 0.75 10H3V12H0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 59">
<path d="M15.25 12C15.25 12 16 12 16 11C16 10 15.25 10 15.25 10H13V12H15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 53">
<path d="M10 15.25C10 15.25 10 16 11 16C12 16 12 15.25 12 15.25V13H10V15.25Z" fill="#232323"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -1,27 +1,32 @@
use crate::fl;
use cosmic::app::Core;
use cosmic::cosmic_theme::palette::rgb::Rgb;
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::window::Id;
use cosmic::iced::{Command, Limits};
use cosmic::iced::{Command, Length, Limits, Subscription};
use cosmic::iced_runtime::core::window;
use cosmic::iced_style::application;
use cosmic::theme::{Button, Svg};
use cosmic::widget::{button, list_column, settings, spin_button, text, toggler};
use cosmic::widget::{column, container, divider, spin_button, text};
use cosmic::{Element, Theme};
use cosmic_time::{anim, chain, id, Timeline};
use once_cell::sync::Lazy;
use std::time::Instant;
use cosmic::iced_widget::row;
const ID: &str = "com.system76.CosmicAppletTiling";
const ON: &str = "com.system76.CosmicAppletTiling.On";
const OFF: &str = "com.system76.CosmicAppletTiling.Off";
static TILE_WINDOWS: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
static SHOW_ACTIVE_HINTS: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
#[derive(Default)]
pub struct Window {
core: Core,
popup: Option<Id>,
timeline: Timeline,
id_ctr: u128,
tile_windows: bool,
show_window_titles: bool,
show_active_hint: bool,
active_border_radius: spin_button::Model<i32>,
active_hint_color: Rgb,
gaps: spin_button::Model<i32>,
}
@ -29,11 +34,9 @@ pub struct Window {
pub enum Message {
TogglePopup,
PopupClosed(Id),
ToggleTileWindows(bool),
ToggleShowWindowTitles(bool),
ToggleShowActiveHint(bool),
HandleActiveBorderRadius(spin_button::Message),
SetActiveHintColor(Rgb),
Frame(Instant),
ToggleTileWindows(chain::Toggler, bool),
ToggleShowActiveHint(chain::Toggler, bool),
HandleGaps(spin_button::Message),
}
@ -57,17 +60,24 @@ impl cosmic::Application for Window {
) -> (Self, Command<cosmic::app::Message<Self::Message>>) {
let window = Window {
core,
active_border_radius: spin_button::Model::default().max(99).min(0).step(1),
gaps: spin_button::Model::default().max(99).min(0).step(1),
..Default::default()
};
(window, Command::none())
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {
fn on_close_requested(&self, id: Id) -> Option<Message> {
Some(Message::PopupClosed(id))
}
fn subscription(&self) -> Subscription<Self::Message> {
let timeline = self
.timeline
.as_subscription()
.map(|(_, now)| Message::Frame(now));
Subscription::batch(vec![timeline])
}
fn update(&mut self, message: Self::Message) -> Command<cosmic::app::Message<Self::Message>> {
match message {
Message::TogglePopup => {
@ -94,18 +104,15 @@ impl cosmic::Application for Window {
self.popup = None;
}
}
Message::ToggleTileWindows(toggled) => self.tile_windows = toggled,
Message::ToggleShowWindowTitles(toggled) => self.show_window_titles = toggled,
Message::ToggleShowActiveHint(toggled) => self.show_active_hint = toggled,
Message::HandleActiveBorderRadius(msg) => match msg {
spin_button::Message::Increment => self
.active_border_radius
.update(spin_button::Message::Increment),
spin_button::Message::Decrement => self
.active_border_radius
.update(spin_button::Message::Decrement),
},
Message::SetActiveHintColor(_) => {}
Message::Frame(now) => self.timeline.now(now),
Message::ToggleTileWindows(chain, toggled) => {
self.timeline.set_chain(chain).start();
self.tile_windows = toggled
}
Message::ToggleShowActiveHint(chain, toggled) => {
self.timeline.set_chain(chain).start();
self.show_active_hint = toggled
}
Message::HandleGaps(msg) => match msg {
spin_button::Message::Increment => {
self.gaps.update(spin_button::Message::Increment)
@ -121,64 +128,66 @@ impl cosmic::Application for Window {
fn view(&self) -> Element<Self::Message> {
self.core
.applet_helper
.icon_button(ID)
.icon_button(OFF)
.on_press(Message::TogglePopup)
.style(Button::Text)
.into()
}
fn view_window(&self, _id: Id) -> Element<Self::Message> {
let content_list = list_column()
.add(settings::item(
fl!("tile-windows"),
toggler(None, self.tile_windows, |value| {
Message::ToggleTileWindows(value)
}),
))
.add(settings::item(
fl!("floating-window-exceptions"),
button(Button::Card).icon(Svg::Symbolic, "arrow-right", 16),
))
.add(
settings::view_section(fl!("shortcuts"))
.add(settings::item(
fl!("launcher"),
text(format!("{} + /", fl!("super"))),
))
.add(settings::item(
fl!("navigate-windows"),
text(format!("{} + {}", fl!("super"), fl!("arrow-keys"))),
))
.add(settings::item(
fl!("toggle-tiling"),
text(format!("{} + Y", fl!("super"))),
))
.add(settings::item(fl!("view-all"), text(""))),
let content_list = cosmic::widget::column()
.padding(20)
.spacing(10)
.push(
container(
anim!(
TILE_WINDOWS,
&self.timeline,
fl!("tile-windows"),
self.tile_windows,
|chain, enable| { Message::ToggleTileWindows(chain, enable) },
)
.text_size(14)
.width(Length::Fill),
)
.padding([0, 12]),
)
.add(settings::item(
fl!("show-window-titles"),
toggler(None, self.show_window_titles, |value| {
Message::ToggleShowWindowTitles(value)
}),
))
.add(settings::item(
fl!("show-active-hint"),
toggler(None, self.show_active_hint, |value| {
Message::ToggleShowActiveHint(value)
}),
))
.add(settings::item(
fl!("active-border-radius"),
spin_button(
self.active_border_radius.value.to_string(),
Message::HandleActiveBorderRadius,
),
))
.add(settings::item(fl!("active-hint-color"), text("TODO")))
.add(settings::item(
fl!("gaps"),
.push(divider::horizontal::light())
.push(
column()
.push(row!(
text(fl!("launcher")).size(14).width(Length::Fill),
text(format!("{} + /", fl!("super"))).size(14),
))
.push(row!(
text(fl!("navigate-windows")).size(14).width(Length::Fill),
text(format!("{} + {}", fl!("super"), fl!("arrow-keys"))).size(14),
))
.push(row!(
text(fl!("toggle-tiling")).size(14).width(Length::Fill),
text(format!("{} + Y", fl!("super"))).size(14),
))
.spacing(10)
.padding([0, 20, 0, 20]),
)
.push(divider::horizontal::light())
.push(
container(
anim!(
SHOW_ACTIVE_HINTS,
&self.timeline,
fl!("show-active-hint"),
self.show_active_hint,
|chain, enable| { Message::ToggleShowActiveHint(chain, enable) },
)
.text_size(14)
.width(Length::Fill),
)
.padding([0, 12]),
)
.push(row!(
text(fl!("gaps")).size(14).width(Length::Fill),
spin_button(self.gaps.value.to_string(), Message::HandleGaps),
));
).padding([0, 10, 0, 10]));
self.core.applet_helper.popup_container(content_list).into()
}