fix clippy warnings
This commit is contained in:
1 parent
7b88083020
commit
bdc3ba435f
39 files changed
+825
-688
No files matched your search
@@ -37,7 +37,6 @@ pub(crate) struct WorkspaceSnapshot {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct WindowSnapshot {
|
||||
pub(crate) id: u64,
|
||||
pub(crate) workspace: u64,
|
||||
pub(crate) app_id: String,
|
||||
pub(crate) title: String,
|
||||
@@ -138,12 +137,6 @@ impl ShellControl {
|
||||
let _ = self.connection.flush();
|
||||
}
|
||||
|
||||
pub(crate) fn activate_window(&self, id: u64) {
|
||||
let (hi, lo) = split_id(id);
|
||||
self.shell.activate_window(hi, lo);
|
||||
let _ = self.connection.flush();
|
||||
}
|
||||
|
||||
pub(crate) fn confirm_logout(&self, serial: u32, revision: u32, token: u32, force: bool) {
|
||||
self.shell
|
||||
.confirm_logout_with_inhibitors(serial, revision, token, u32::from(force));
|
||||
@@ -268,8 +261,8 @@ impl Dispatch<FereseShellV1, ()> for ControlState {
|
||||
});
|
||||
}
|
||||
ferese_shell_v1::Event::Window {
|
||||
window_hi,
|
||||
window_lo,
|
||||
window_hi: _,
|
||||
window_lo: _,
|
||||
workspace_hi,
|
||||
workspace_lo,
|
||||
app_id,
|
||||
@@ -285,7 +278,6 @@ impl Dispatch<FereseShellV1, ()> for ControlState {
|
||||
};
|
||||
|
||||
state.pending.windows.push(WindowSnapshot {
|
||||
id: join_id(window_hi, window_lo),
|
||||
workspace: join_id(workspace_hi, workspace_lo),
|
||||
app_id,
|
||||
title,
|
||||
|
||||
@@ -221,7 +221,7 @@ struct OutputSurfaces {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum Message {
|
||||
ThemeChanged(ferese_config::theme::Snapshot),
|
||||
ThemeChanged(Box<ferese_config::theme::Snapshot>),
|
||||
ThemeMode(ferese_config::theme::Mode),
|
||||
ThemeModeSet(Result<(), String>),
|
||||
BeginNoteEdit(String),
|
||||
@@ -340,7 +340,7 @@ impl cosmic::Application for FereseShell {
|
||||
|
||||
fn subscription(&self) -> Subscription<Self::Message> {
|
||||
Subscription::batch([
|
||||
ferese_theme::service::subscription().map(Message::ThemeChanged),
|
||||
ferese_theme::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
|
||||
if self
|
||||
.system_modal
|
||||
.as_ref()
|
||||
@@ -1208,7 +1208,6 @@ mod tests {
|
||||
}],
|
||||
workspaces: Vec::new(),
|
||||
windows: vec![WindowSnapshot {
|
||||
id: 1,
|
||||
workspace,
|
||||
app_id: "dev.ferese.Test".to_owned(),
|
||||
title: "Test".to_owned(),
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::bar::status_icon;
|
||||
use super::controls::status_summary;
|
||||
use super::{Menu, MenuRows, MenuStyle};
|
||||
use crate::status::Action;
|
||||
use crate::{FereseShell, Message, color_with_opacity, text};
|
||||
use crate::{FereseShell, Message, text};
|
||||
|
||||
const DEVICE_LIST_HEIGHT: f32 = 180.0;
|
||||
|
||||
@@ -15,12 +15,7 @@ fn device_list_height(count: usize) -> Option<f32> {
|
||||
}
|
||||
|
||||
pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: MenuStyle) -> MenuRows<'a> {
|
||||
let MenuStyle {
|
||||
theme,
|
||||
primary,
|
||||
muted,
|
||||
opacity: p,
|
||||
} = style;
|
||||
let MenuStyle { muted, .. } = style;
|
||||
if let Some(b) = &shell.status.bluetooth {
|
||||
rows = rows.push(status_summary(
|
||||
status_icon(Menu::Bluetooth, &shell.status).0,
|
||||
@@ -36,10 +31,7 @@ pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: Me
|
||||
} else {
|
||||
"Your connected devices"
|
||||
},
|
||||
primary,
|
||||
muted,
|
||||
color_with_opacity(theme.accent, p),
|
||||
p,
|
||||
style,
|
||||
b.enabled,
|
||||
Some((b.enabled, Action::Bluetooth(!b.enabled))),
|
||||
));
|
||||
|
||||
@@ -3,19 +3,23 @@ use cosmic::widget::{button, column, container, row, slider};
|
||||
use cosmic::{Element, theme};
|
||||
|
||||
use crate::status::Action;
|
||||
use crate::{Message, ShellTheme, accented_icon, color, motion, shell_font, text};
|
||||
use crate::{Message, ShellTheme, accented_icon, color, color_with_opacity, motion, shell_font, text};
|
||||
|
||||
pub(super) fn status_summary<'a>(
|
||||
source: &'static [u8],
|
||||
title: &'a str,
|
||||
subtitle: &'a str,
|
||||
primary: Color,
|
||||
muted: Color,
|
||||
accent: Color,
|
||||
opacity: f32,
|
||||
style: super::MenuStyle,
|
||||
enabled: bool,
|
||||
toggle: Option<(bool, Action)>,
|
||||
) -> Element<'a, cosmic::Action<Message>> {
|
||||
let super::MenuStyle {
|
||||
theme,
|
||||
primary,
|
||||
muted,
|
||||
opacity,
|
||||
} = style;
|
||||
let accent = color_with_opacity(theme.accent, opacity);
|
||||
let badge_color = if enabled { accent } else { primary };
|
||||
let badge = container(accented_icon(source, 22, primary, accent))
|
||||
.width(32)
|
||||
|
||||
@@ -5,14 +5,11 @@ use super::bar::status_icon;
|
||||
use super::controls::{level_meter, shell_switch, status_summary};
|
||||
use super::{Menu, MenuRows, MenuStyle};
|
||||
use crate::status::Action;
|
||||
use crate::{FereseShell, color_with_opacity, text};
|
||||
use crate::{FereseShell, text};
|
||||
|
||||
pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: MenuStyle) -> MenuRows<'a> {
|
||||
let MenuStyle {
|
||||
theme,
|
||||
primary,
|
||||
muted,
|
||||
opacity: p,
|
||||
primary, opacity: p, ..
|
||||
} = style;
|
||||
if let Some(n) = &shell.status.network {
|
||||
let connected = n.enabled && n.connection.is_some();
|
||||
@@ -30,10 +27,7 @@ pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: Me
|
||||
} else {
|
||||
"Wireless connections are paused"
|
||||
},
|
||||
primary,
|
||||
muted,
|
||||
color_with_opacity(theme.accent, p),
|
||||
p,
|
||||
style,
|
||||
n.enabled,
|
||||
None,
|
||||
));
|
||||
|
||||
@@ -178,21 +178,6 @@ fn connection_control<'a>(
|
||||
container(tile).width(Length::FillPortion(1)).into()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn connection_captions_fit_one_short_line() {
|
||||
assert_eq!(super::connection_caption("88%"), "88%");
|
||||
assert_eq!(super::connection_caption("Flow84@Lofree"), "Flow84@Lofr…");
|
||||
assert_eq!(super::connection_caption("123456789012"), "123456789012");
|
||||
assert_eq!(super::connection_caption("My very long headphones"), "My very lon…");
|
||||
assert_eq!(super::connection_caption(" Device\n name "), "Device name");
|
||||
let caption = super::connection_caption("耳機耳機耳機耳機耳機耳機耳機");
|
||||
assert_eq!(caption.chars().count(), 12);
|
||||
assert!(caption.ends_with('…'));
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn heading<'a>(
|
||||
shell: &'a FereseShell,
|
||||
mut heading: super::MenuHeading<'a>,
|
||||
@@ -229,3 +214,18 @@ pub(super) fn heading<'a>(
|
||||
}
|
||||
heading
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn connection_captions_fit_one_short_line() {
|
||||
assert_eq!(super::connection_caption("88%"), "88%");
|
||||
assert_eq!(super::connection_caption("Flow84@Lofree"), "Flow84@Lofr…");
|
||||
assert_eq!(super::connection_caption("123456789012"), "123456789012");
|
||||
assert_eq!(super::connection_caption("My very long headphones"), "My very lon…");
|
||||
assert_eq!(super::connection_caption(" Device\n name "), "Device name");
|
||||
let caption = super::connection_caption("耳機耳機耳機耳機耳機耳機耳機");
|
||||
assert_eq!(caption.chars().count(), 12);
|
||||
assert!(caption.ends_with('…'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user