chore: clippy
This commit is contained in:
parent
75256dac19
commit
2d6d507a48
41 changed files with 139 additions and 172 deletions
|
|
@ -996,7 +996,7 @@ impl SettingsApp {
|
||||||
if section
|
if section
|
||||||
.show_while
|
.show_while
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |func| func(model.as_ref()))
|
.is_none_or(|func| func(model.as_ref()))
|
||||||
{
|
{
|
||||||
sections_column.push(
|
sections_column.push(
|
||||||
(section.view_fn)(&self.pages, model.as_ref(), section)
|
(section.view_fn)(&self.pages, model.as_ref(), section)
|
||||||
|
|
@ -1108,7 +1108,7 @@ impl SettingsApp {
|
||||||
if section
|
if section
|
||||||
.show_while
|
.show_while
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |func| func(model.as_ref()))
|
.is_none_or(|func| func(model.as_ref()))
|
||||||
{
|
{
|
||||||
let section = (section.view_fn)(&self.pages, model.as_ref(), section)
|
let section = (section.view_fn)(&self.pages, model.as_ref(), section)
|
||||||
.map(Message::PageMessage)
|
.map(Message::PageMessage)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,12 @@ pub struct Config {
|
||||||
state: cosmic_config::Config,
|
state: cosmic_config::Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let config = match cosmic_config::Config::new(NAME, 1) {
|
let config = match cosmic_config::Config::new(NAME, 1) {
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@ pub fn vision() -> section::Section<crate::pages::Message> {
|
||||||
text::body(status_text).wrapping(Wrapping::Word),
|
text::body(status_text).wrapping(Wrapping::Word),
|
||||||
page.wayland_available
|
page.wayland_available
|
||||||
.is_some()
|
.is_some()
|
||||||
.then_some(crate::pages::Message::Page(magnifier_entity).into()),
|
.then_some(crate::pages::Message::Page(magnifier_entity)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.add(
|
.add(
|
||||||
|
|
@ -270,7 +270,7 @@ pub fn vision() -> section::Section<crate::pages::Message> {
|
||||||
Some(page.screen_filter_selection as usize),
|
Some(page.screen_filter_selection as usize),
|
||||||
move |idx| {
|
move |idx| {
|
||||||
let filter = ColorFilter::from_usize(idx).unwrap_or_default();
|
let filter = ColorFilter::from_usize(idx).unwrap_or_default();
|
||||||
Message::SetScreenFilterSelection(filter).into()
|
Message::SetScreenFilterSelection(filter)
|
||||||
},
|
},
|
||||||
cosmic::iced::window::Id::RESERVED,
|
cosmic::iced::window::Id::RESERVED,
|
||||||
Message::Surface,
|
Message::Surface,
|
||||||
|
|
|
||||||
|
|
@ -187,16 +187,13 @@ impl Page {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|m| m.essence_str())
|
.map(|m| m.essence_str())
|
||||||
.filter(|m| m.starts_with("audio"))
|
.filter(|m| m.starts_with("audio"))
|
||||||
.chain(
|
.chain([
|
||||||
[
|
"application/ogg",
|
||||||
"application/ogg",
|
"application/x-cue",
|
||||||
"application/x-cue",
|
"application/x-ogg",
|
||||||
"application/x-ogg",
|
"audio/mp3",
|
||||||
"audio/mp3",
|
"x-content/audio-cdda",
|
||||||
"x-content/audio-cdda",
|
])
|
||||||
]
|
|
||||||
.into_iter(),
|
|
||||||
)
|
|
||||||
.collect();
|
.collect();
|
||||||
&mime_types
|
&mime_types
|
||||||
}),
|
}),
|
||||||
|
|
@ -528,7 +525,7 @@ async fn load_defaults(assocs: &BTreeMap<Arc<str>, Arc<App>>, for_mimes: &[&str]
|
||||||
|
|
||||||
async fn xdg_mime_query_default(mime_type: &str) -> Option<String> {
|
async fn xdg_mime_query_default(mime_type: &str) -> Option<String> {
|
||||||
let output = tokio::process::Command::new("xdg-mime")
|
let output = tokio::process::Command::new("xdg-mime")
|
||||||
.args(&["query", "default", mime_type])
|
.args(["query", "default", mime_type])
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,9 @@ enum Context {
|
||||||
AddApplication(DirectoryType),
|
AddApplication(DirectoryType),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Vec<PathBuf>> for DirectoryType {
|
impl From<DirectoryType> for Vec<PathBuf> {
|
||||||
fn into(self) -> Vec<PathBuf> {
|
fn from(val: DirectoryType) -> Self {
|
||||||
match self {
|
match val {
|
||||||
DirectoryType::User => vec![
|
DirectoryType::User => vec![
|
||||||
dirs::config_dir()
|
dirs::config_dir()
|
||||||
.expect("config dir not found")
|
.expect("config dir not found")
|
||||||
|
|
@ -121,7 +121,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
Some(
|
Some(
|
||||||
cosmic::app::context_drawer(
|
cosmic::app::context_drawer(
|
||||||
self.add_application_context_view(directory_type.clone()),
|
self.add_application_context_view(directory_type.clone()),
|
||||||
crate::pages::Message::CloseContextDrawer.into(),
|
crate::pages::Message::CloseContextDrawer,
|
||||||
)
|
)
|
||||||
.title(fl!("startup-apps", "search-for-application"))
|
.title(fl!("startup-apps", "search-for-application"))
|
||||||
.header(search),
|
.header(search),
|
||||||
|
|
@ -224,7 +224,7 @@ impl Page {
|
||||||
let directories: Vec<PathBuf> = directory_type.clone().into();
|
let directories: Vec<PathBuf> = directory_type.clone().into();
|
||||||
|
|
||||||
let directory_to_target =
|
let directory_to_target =
|
||||||
directories.get(0).expect("Always at least one directory");
|
directories.first().expect("Always at least one directory");
|
||||||
|
|
||||||
_ = std::fs::create_dir_all(directory_to_target.as_path());
|
_ = std::fs::create_dir_all(directory_to_target.as_path());
|
||||||
|
|
||||||
|
|
@ -271,7 +271,7 @@ impl Page {
|
||||||
let directories: Vec<PathBuf> = directory_type.clone().into();
|
let directories: Vec<PathBuf> = directory_type.clone().into();
|
||||||
|
|
||||||
let directory_to_target =
|
let directory_to_target =
|
||||||
directories.get(0).expect("Always at least one directory");
|
directories.first().expect("Always at least one directory");
|
||||||
if let Ok(exists) = std::fs::exists(directory_to_target.join(file_name.clone()))
|
if let Ok(exists) = std::fs::exists(directory_to_target.join(file_name.clone()))
|
||||||
{
|
{
|
||||||
if exists {
|
if exists {
|
||||||
|
|
|
||||||
|
|
@ -830,7 +830,7 @@ fn connected_devices() -> Section<crate::pages::Message> {
|
||||||
.model
|
.model
|
||||||
.popup_device
|
.popup_device
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map_or(false, |p| path.as_str() == p.as_str())
|
.is_some_and(|p| path.as_str() == p.as_str())
|
||||||
{
|
{
|
||||||
widget::popover(
|
widget::popover(
|
||||||
widget::button::icon(widget::icon::from_name("view-more-symbolic"))
|
widget::button::icon(widget::icon::from_name("view-more-symbolic"))
|
||||||
|
|
@ -1012,21 +1012,21 @@ mod systemd {
|
||||||
|
|
||||||
pub fn activate_bluetooth() -> impl Future<Output = ()> + Send {
|
pub fn activate_bluetooth() -> impl Future<Output = ()> + Send {
|
||||||
tokio::process::Command::new("pkexec")
|
tokio::process::Command::new("pkexec")
|
||||||
.args(&["systemctl", "start", "bluetooth"])
|
.args(["systemctl", "start", "bluetooth"])
|
||||||
.status()
|
.status()
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enable_bluetooth() -> impl Future<Output = ()> + Send {
|
pub fn enable_bluetooth() -> impl Future<Output = ()> + Send {
|
||||||
tokio::process::Command::new("pkexec")
|
tokio::process::Command::new("pkexec")
|
||||||
.args(&["systemctl", "enable", "--now", "bluetooth"])
|
.args(["systemctl", "enable", "--now", "bluetooth"])
|
||||||
.status()
|
.status()
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_bluetooth_enabled() -> bool {
|
pub fn is_bluetooth_enabled() -> bool {
|
||||||
std::process::Command::new("systemctl")
|
std::process::Command::new("systemctl")
|
||||||
.args(&["is-enabled", "bluetooth"])
|
.args(["is-enabled", "bluetooth"])
|
||||||
.status()
|
.status()
|
||||||
.map(|status| status.success())
|
.map(|status| status.success())
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
|
|
@ -1034,7 +1034,7 @@ mod systemd {
|
||||||
|
|
||||||
pub fn is_bluetooth_active() -> bool {
|
pub fn is_bluetooth_active() -> bool {
|
||||||
std::process::Command::new("systemctl")
|
std::process::Command::new("systemctl")
|
||||||
.args(&["is-active", "bluetooth"])
|
.args(["is-active", "bluetooth"])
|
||||||
.status()
|
.status()
|
||||||
.map(|status| status.success())
|
.map(|status| status.success())
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ impl Content {
|
||||||
) -> Task<app::Message> {
|
) -> Task<app::Message> {
|
||||||
match message {
|
match message {
|
||||||
FontMessage::FontLoaded(interface, mono) => {
|
FontMessage::FontLoaded(interface, mono) => {
|
||||||
return self.font_config.font_loaded(mono, interface);
|
self.font_config.font_loaded(mono, interface)
|
||||||
}
|
}
|
||||||
FontMessage::Search(input) => match context_view {
|
FontMessage::Search(input) => match context_view {
|
||||||
None => Task::none(),
|
None => Task::none(),
|
||||||
|
|
@ -141,7 +141,7 @@ impl Content {
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Task::none();
|
Task::none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,12 @@ pub fn load_font_families() -> (Vec<Arc<str>>, Vec<Arc<str>>) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if face.monospaced {
|
if face.monospaced {
|
||||||
if mono
|
if mono.last().is_none_or(|name| &**name != font_name.as_str()) {
|
||||||
.last()
|
|
||||||
.map_or(true, |name| &**name != font_name.as_str())
|
|
||||||
{
|
|
||||||
mono.push(Arc::from(font_name.as_str()));
|
mono.push(Arc::from(font_name.as_str()));
|
||||||
}
|
}
|
||||||
} else if interface
|
} else if interface
|
||||||
.last()
|
.last()
|
||||||
.map_or(true, |name| &**name != font_name.as_str())
|
.is_none_or(|name| &**name != font_name.as_str())
|
||||||
{
|
{
|
||||||
interface.push(Arc::from(font_name.as_str()));
|
interface.push(Arc::from(font_name.as_str()));
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +72,12 @@ pub struct Model {
|
||||||
pub monospace_font: FontConfig,
|
pub monospace_font: FontConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Model {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Model {
|
impl Model {
|
||||||
pub fn new() -> Model {
|
pub fn new() -> Model {
|
||||||
Model {
|
Model {
|
||||||
|
|
@ -118,7 +121,7 @@ impl Model {
|
||||||
};
|
};
|
||||||
|
|
||||||
update_config(MONOSPACE_FONT, self.monospace_font.clone());
|
update_config(MONOSPACE_FONT, self.monospace_font.clone());
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
ContextView::SystemFont => {
|
ContextView::SystemFont => {
|
||||||
self.interface_font = FontConfig {
|
self.interface_font = FontConfig {
|
||||||
|
|
@ -131,9 +134,9 @@ impl Model {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
set_gnome_font_name(font.as_ref()).await;
|
set_gnome_font_name(font.as_ref()).await;
|
||||||
});
|
});
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
_ => return None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,7 +151,7 @@ impl Model {
|
||||||
fonts
|
fonts
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| f.to_lowercase().contains(&self.font_search))
|
.filter(|f| f.to_lowercase().contains(&self.font_search))
|
||||||
.map(|f| f.clone())
|
.cloned()
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ impl Page {
|
||||||
theme_staged = self
|
theme_staged = self
|
||||||
.theme_manager
|
.theme_manager
|
||||||
.selected_customizer_mut()
|
.selected_customizer_mut()
|
||||||
.set_accent(Some(c).map(Srgb::from));
|
.set_accent(Some(Srgb::from(c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::Reset => {
|
Message::Reset => {
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ pub fn section() -> Section<crate::pages::Message> {
|
||||||
|
|
||||||
let mut section = settings::section()
|
let mut section = settings::section()
|
||||||
.title(§ion.title)
|
.title(§ion.title)
|
||||||
.add(theme_mode(&page, section, &label_keys))
|
.add(theme_mode(page, section, &label_keys))
|
||||||
.add(auto_switch(&page, section, &label_keys))
|
.add(auto_switch(page, section, &label_keys))
|
||||||
.add(accent_color_palette(&page, section, &label_keys))
|
.add(accent_color_palette(page, section, &label_keys))
|
||||||
.add(application_background(&page, section, &label_keys))
|
.add(application_background(page, section, &label_keys))
|
||||||
.add(container_background(&page, section, &label_keys))
|
.add(container_background(page, section, &label_keys))
|
||||||
.add(interface_text(&page, section, &label_keys))
|
.add(interface_text(page, section, &label_keys))
|
||||||
.add(control_tint(&page, section, &label_keys))
|
.add(control_tint(page, section, &label_keys))
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[label_keys["window_hint_toggle"]])
|
settings::item::builder(&descriptions[label_keys["window_hint_toggle"]])
|
||||||
.toggler(
|
.toggler(
|
||||||
|
|
@ -196,16 +196,13 @@ fn accent_color_palette<'a>(
|
||||||
let mut accent_palette_row = Vec::with_capacity(accent.len());
|
let mut accent_palette_row = Vec::with_capacity(accent.len());
|
||||||
|
|
||||||
for &color in accent {
|
for &color in accent {
|
||||||
accent_palette_row.push(
|
accent_palette_row.push(color_button(
|
||||||
color_button(
|
Some(Message::PaletteAccent(color.into())),
|
||||||
Some(Message::PaletteAccent(color.into())),
|
color.into(),
|
||||||
color.into(),
|
cur_accent == color,
|
||||||
cur_accent == color,
|
48,
|
||||||
48,
|
48,
|
||||||
48,
|
));
|
||||||
)
|
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
accent_palette_row.push(
|
accent_palette_row.push(
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ impl From<(Option<Config>, Option<Config>, Option<Vec<Srgba>>)> for ThemeCustomi
|
||||||
custom_window_hint: None,
|
custom_window_hint: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let None = customizer.accent_palette {
|
if customizer.accent_palette.is_none() {
|
||||||
let palette = customizer.builder.0.palette.as_ref();
|
let palette = customizer.builder.0.palette.as_ref();
|
||||||
customizer.accent_palette = Some(vec![
|
customizer.accent_palette = Some(vec![
|
||||||
palette.accent_blue,
|
palette.accent_blue,
|
||||||
|
|
@ -159,7 +159,7 @@ impl Default for Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn build_theme<'a>(&mut self, stage: ThemeStaged) -> Task<app::Message> {
|
pub fn build_theme(&mut self, stage: ThemeStaged) -> Task<app::Message> {
|
||||||
macro_rules! theme_transaction {
|
macro_rules! theme_transaction {
|
||||||
($config:ident, $current_theme:ident, $new_theme:ident, { $($name:ident;)+ }) => {
|
($config:ident, $current_theme:ident, $new_theme:ident, { $($name:ident;)+ }) => {
|
||||||
let tx = $config.transaction();
|
let tx = $config.transaction();
|
||||||
|
|
@ -194,10 +194,10 @@ impl Manager {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut data = std::iter::once(current).chain(other.into_iter());
|
let mut data = std::iter::once(current).chain(other);
|
||||||
|
|
||||||
cosmic::task::future(async move {
|
cosmic::task::future(async move {
|
||||||
while let Some((builder, config)) = data.next() {
|
for (builder, config) in data.by_ref() {
|
||||||
if let Some(config) = config {
|
if let Some(config) = config {
|
||||||
let current_theme = match Theme::get_entry(&config) {
|
let current_theme = match Theme::get_entry(&config) {
|
||||||
Ok(theme) => theme,
|
Ok(theme) => theme,
|
||||||
|
|
@ -277,7 +277,7 @@ impl Manager {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn custom_window_hint(&self) -> &Option<Srgb> {
|
pub fn custom_window_hint(&self) -> &Option<Srgb> {
|
||||||
&self.selected_customizer().custom_window_hint()
|
self.selected_customizer().custom_window_hint()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
Message::Inner(inner) => {
|
Message::Inner(inner) => {
|
||||||
if let inner::Message::Surface(a) = inner {
|
if let inner::Message::Surface(a) = inner {
|
||||||
return cosmic::task::message(crate::app::Message::Surface(a));
|
cosmic::task::message(crate::app::Message::Surface(a))
|
||||||
} else {
|
} else {
|
||||||
self.inner
|
self.inner
|
||||||
.update(inner)
|
.update(inner)
|
||||||
|
|
|
||||||
|
|
@ -590,7 +590,7 @@ impl Applet<'static> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Applet<'a> {
|
impl Applet<'_> {
|
||||||
fn into_owned(self) -> Applet<'static> {
|
fn into_owned(self) -> Applet<'static> {
|
||||||
Applet {
|
Applet {
|
||||||
id: Cow::from(self.id.into_owned()),
|
id: Cow::from(self.id.into_owned()),
|
||||||
|
|
@ -641,7 +641,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|info| {
|
.map(|info| {
|
||||||
let id_clone = info.id.to_string();
|
let id_clone = info.id.to_string();
|
||||||
let is_dragged = active_dnd.as_ref().map_or(false, |dnd| dnd.id == info.id);
|
let is_dragged = active_dnd.as_ref().is_some_and(|dnd| dnd.id == info.id);
|
||||||
|
|
||||||
let content = if is_dragged {
|
let content = if is_dragged {
|
||||||
row::with_capacity(0).height(Length::Fixed(32.0))
|
row::with_capacity(0).height(Length::Fixed(32.0))
|
||||||
|
|
@ -859,8 +859,8 @@ pub fn dnd_icon(info: Applet<'static>, layout: &layout::Layout) -> AppletReorder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message: 'static> Widget<Message, cosmic::Theme, cosmic::Renderer>
|
impl<Message: 'static> Widget<Message, cosmic::Theme, cosmic::Renderer>
|
||||||
for AppletReorderList<'a, Message>
|
for AppletReorderList<'_, Message>
|
||||||
where
|
where
|
||||||
Message: Clone,
|
Message: Clone,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ pub struct Message(pub inner::Message);
|
||||||
impl Page {
|
impl Page {
|
||||||
pub fn update(&mut self, message: Message) -> Task<crate::app::Message> {
|
pub fn update(&mut self, message: Message) -> Task<crate::app::Message> {
|
||||||
if let inner::Message::Surface(a) = message.0 {
|
if let inner::Message::Surface(a) = message.0 {
|
||||||
return cosmic::task::message(crate::app::Message::Surface(a));
|
cosmic::task::message(crate::app::Message::Surface(a))
|
||||||
} else {
|
} else {
|
||||||
self.inner
|
self.inner
|
||||||
.update(message.0)
|
.update(message.0)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const CURRENT_FOLDER: &str = "current-folder";
|
||||||
const CUSTOM_COLORS: &str = "custom-colors";
|
const CUSTOM_COLORS: &str = "custom-colors";
|
||||||
const CUSTOM_IMAGES: &str = "custom-images";
|
const CUSTOM_IMAGES: &str = "custom-images";
|
||||||
const RECENT_FOLDERS: &str = "recent-folders";
|
const RECENT_FOLDERS: &str = "recent-folders";
|
||||||
const BACKGROUNDS_DIR: &'static str = "backgrounds";
|
const BACKGROUNDS_DIR: &str = "backgrounds";
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
|
|
||||||
|
|
@ -1213,7 +1213,7 @@ pub fn settings() -> Section<crate::pages::Message> {
|
||||||
let mut slideshow_enabled = page
|
let mut slideshow_enabled = page
|
||||||
.config_output()
|
.config_output()
|
||||||
.and_then(|output| page.wallpaper_service_config.entry(output))
|
.and_then(|output| page.wallpaper_service_config.entry(output))
|
||||||
.map_or(false, |entry| {
|
.is_some_and(|entry| {
|
||||||
if let Source::Path(path) = &entry.source {
|
if let Source::Path(path) = &entry.source {
|
||||||
path.is_dir()
|
path.is_dir()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -118,11 +118,7 @@ pub fn color_select_options(
|
||||||
})
|
})
|
||||||
.chain(wallpaper::DEFAULT_COLORS.iter().map(|color| (color, false)))
|
.chain(wallpaper::DEFAULT_COLORS.iter().map(|color| (color, false)))
|
||||||
.map(|(color, removable)| {
|
.map(|(color, removable)| {
|
||||||
color_button(
|
color_button(color.clone(), removable, selected == Some(color))
|
||||||
color.clone(),
|
|
||||||
removable,
|
|
||||||
selected.map_or(false, |selection| selection == color),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)
|
)
|
||||||
|
|
@ -146,7 +142,7 @@ pub fn wallpaper_select_options(
|
||||||
handle,
|
handle,
|
||||||
*id,
|
*id,
|
||||||
true,
|
true,
|
||||||
selected.map_or(false, |selection| id == &selection),
|
selected.is_some_and(|selection| id == &selection),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,12 +153,7 @@ pub fn wallpaper_select_options(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec.push(wallpaper_button(
|
vec.push(wallpaper_button(handle, id, false, selected == Some(id)));
|
||||||
handle,
|
|
||||||
id,
|
|
||||||
false,
|
|
||||||
selected.map_or(false, |selection| id == selection),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flex_select_row(vec)
|
flex_select_row(vec)
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ impl<'a, Message> Arrangement<'a, Message> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message: Clone> Widget<Message, cosmic::Theme, Renderer> for Arrangement<'a, Message> {
|
impl<Message: Clone> Widget<Message, cosmic::Theme, Renderer> for Arrangement<'_, Message> {
|
||||||
fn tag(&self) -> tree::Tag {
|
fn tag(&self) -> tree::Tag {
|
||||||
tree::Tag::of::<State>()
|
tree::Tag::of::<State>()
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ impl<'a, Message: Clone> Widget<Message, cosmic::Theme, Renderer> for Arrangemen
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let (mut width, mut height) = if output.transform.map_or(true, is_landscape) {
|
let (mut width, mut height) = if output.transform.is_none_or(is_landscape) {
|
||||||
(mode.size.0, mode.size.1)
|
(mode.size.0, mode.size.1)
|
||||||
} else {
|
} else {
|
||||||
(mode.size.1, mode.size.0)
|
(mode.size.1, mode.size.0)
|
||||||
|
|
@ -420,7 +420,7 @@ fn display_regions<'a>(
|
||||||
(mode.size.1 as f32 / output.scale as f32) / UNIT_PIXELS,
|
(mode.size.1 as f32 / output.scale as f32) / UNIT_PIXELS,
|
||||||
);
|
);
|
||||||
|
|
||||||
(width, height) = if output.transform.map_or(true, is_landscape) {
|
(width, height) = if output.transform.is_none_or(is_landscape) {
|
||||||
(width, height)
|
(width, height)
|
||||||
} else {
|
} else {
|
||||||
(height, width)
|
(height, width)
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,6 @@ fn popover_menu(id: DefaultKey) -> cosmic::Element<'static, Message> {
|
||||||
color: background.component.divider.into(),
|
color: background.component.divider.into(),
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
radius: cosmic.corner_radii.radius_s.into(),
|
radius: cosmic.corner_radii.radius_s.into(),
|
||||||
..Border::default()
|
|
||||||
},
|
},
|
||||||
shadow: Default::default(),
|
shadow: Default::default(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ impl Model {
|
||||||
self.shortcut_context = None;
|
self.shortcut_context = None;
|
||||||
self.editing = None;
|
self.editing = None;
|
||||||
|
|
||||||
return Task::none();
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn on_context_drawer_close(&mut self) {
|
pub(super) fn on_context_drawer_close(&mut self) {
|
||||||
|
|
@ -637,9 +637,7 @@ impl Model {
|
||||||
if matches!(
|
if matches!(
|
||||||
key,
|
key,
|
||||||
Key::Named(Named::Super | Named::Alt | Named::Control | Named::Shift)
|
Key::Named(Named::Super | Named::Alt | Named::Control | Named::Shift)
|
||||||
) {
|
) || matches!((&key, modifiers), (Key::Named(Named::Tab), modifiers) if modifiers.is_empty() || modifiers == Modifiers::SHIFT)
|
||||||
return None;
|
|
||||||
} else if matches!((&key, modifiers), (Key::Named(Named::Tab), modifiers) if modifiers.is_empty() || modifiers == Modifiers::SHIFT)
|
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ impl Page {
|
||||||
widget::text_input::focus(widget::Id::unique()),
|
widget::text_input::focus(widget::Id::unique()),
|
||||||
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard(),
|
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard(),
|
||||||
]);
|
]);
|
||||||
} else if (old.alt || old.ctrl || old.shift) {
|
} else if old.alt || old.ctrl || old.shift {
|
||||||
self.add_shortcut = Default::default();
|
self.add_shortcut = Default::default();
|
||||||
_ = self.model.on_enter();
|
_ = self.model.on_enter();
|
||||||
|
|
||||||
|
|
@ -564,7 +564,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
||||||
_ = self.model.on_clear();
|
self.model.on_clear();
|
||||||
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
@ -595,9 +595,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
if matches!(
|
if matches!(
|
||||||
key,
|
key,
|
||||||
Key::Named(Named::Super | Named::Alt | Named::Control | Named::Shift)
|
Key::Named(Named::Super | Named::Alt | Named::Control | Named::Shift)
|
||||||
) {
|
) || matches!((&key, modifiers), (Key::Named(Named::Tab), modifiers) if modifiers.is_empty() || modifiers == Modifiers::SHIFT)
|
||||||
return None;
|
|
||||||
} else if matches!((&key, modifiers), (Key::Named(Named::Tab), modifiers) if modifiers.is_empty() || modifiers == Modifiers::SHIFT)
|
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
||||||
_ = self.model.on_clear();
|
self.model.on_clear();
|
||||||
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
||||||
_ = self.model.on_clear();
|
self.model.on_clear();
|
||||||
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
||||||
_ = self.model.on_clear();
|
self.model.on_clear();
|
||||||
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
||||||
_ = self.model.on_clear();
|
self.model.on_clear();
|
||||||
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
||||||
_ = self.model.on_clear();
|
self.model.on_clear();
|
||||||
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
cosmic::iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,6 @@ fn system_has_touchpad() -> bool {
|
||||||
devices.any(|device| {
|
devices.any(|device| {
|
||||||
device
|
device
|
||||||
.property_value("ID_INPUT_TOUCHPAD")
|
.property_value("ID_INPUT_TOUCHPAD")
|
||||||
.map_or(false, |value| value == "1")
|
.is_some_and(|value| value == "1")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ fn mouse() -> Section<crate::pages::Message> {
|
||||||
.input_default
|
.input_default
|
||||||
.acceleration
|
.acceleration
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |x| x.profile == Some(AccelProfile::Adaptive)),
|
.is_none_or(|x| x.profile == Some(AccelProfile::Adaptive)),
|
||||||
|x| Message::SetAcceleration(x, false),
|
|x| Message::SetAcceleration(x, false),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ fn touchpad() -> Section<crate::pages::Message> {
|
||||||
.input_touchpad
|
.input_touchpad
|
||||||
.acceleration
|
.acceleration
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |x| x.profile == Some(AccelProfile::Adaptive)),
|
.is_none_or(|x| x.profile == Some(AccelProfile::Adaptive)),
|
||||||
|x| Message::SetAcceleration(x, true),
|
|x| Message::SetAcceleration(x, true),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -193,7 +193,7 @@ fn click_behavior() -> Section<crate::pages::Message> {
|
||||||
page.input_touchpad
|
page.input_touchpad
|
||||||
.tap_config
|
.tap_config
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |x| x.enabled),
|
.is_some_and(|x| x.enabled),
|
||||||
Message::TapToClick,
|
Message::TapToClick,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -288,7 +288,7 @@ fn scrolling() -> Section<crate::pages::Message> {
|
||||||
page.input_touchpad
|
page.input_touchpad
|
||||||
.scroll_config
|
.scroll_config
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |conf| conf.natural_scroll.unwrap_or(false)),
|
.is_some_and(|conf| conf.natural_scroll.unwrap_or(false)),
|
||||||
|enabled| Message::SetNaturalScroll(enabled, true),
|
|enabled| Message::SetNaturalScroll(enabled, true),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
.context("failed to create system dbus connection")
|
.context("failed to create system dbus connection")
|
||||||
.map_or_else(
|
.map_or_else(
|
||||||
|why| Message::Error(why.to_string()),
|
|why| Message::Error(why.to_string()),
|
||||||
|conn| Message::NetworkManagerConnect(conn),
|
Message::NetworkManagerConnect,
|
||||||
)
|
)
|
||||||
.apply(crate::pages::Message::Networking)
|
.apply(crate::pages::Message::Networking)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ impl VpnConnectionSettings {
|
||||||
fn password_flag(&self) -> Option<PasswordFlag> {
|
fn password_flag(&self) -> Option<PasswordFlag> {
|
||||||
self.connection_type
|
self.connection_type
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |ct| match ct {
|
.is_some_and(|ct| match ct {
|
||||||
ConnectionType::Password => true,
|
ConnectionType::Password => true,
|
||||||
})
|
})
|
||||||
.then_some(self.password_flag)
|
.then_some(self.password_flag)
|
||||||
|
|
@ -878,7 +878,7 @@ fn devices_view() -> Section<crate::pages::Message> {
|
||||||
let view_more: Option<Element<_>> = if page
|
let view_more: Option<Element<_>> = if page
|
||||||
.view_more_popup
|
.view_more_popup
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map_or(false, |id| id == uuid.as_ref())
|
.is_some_and(|id| id == uuid.as_ref())
|
||||||
{
|
{
|
||||||
widget::popover(view_more_button.on_press(Message::ViewMore(None)))
|
widget::popover(view_more_button.on_press(Message::ViewMore(None)))
|
||||||
.position(widget::popover::Position::Bottom)
|
.position(widget::popover::Position::Bottom)
|
||||||
|
|
@ -1018,12 +1018,8 @@ fn add_network() -> Task<crate::app::Message> {
|
||||||
Err(why) => Message::Error(ErrorKind::Config, why.to_string()),
|
Err(why) => Message::Error(ErrorKind::Config, why.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(cosmic::dialog::file_chooser::Error::Cancelled) => {
|
Err(cosmic::dialog::file_chooser::Error::Cancelled) => Message::CancelDialog,
|
||||||
return Message::CancelDialog;
|
Err(why) => Message::Error(ErrorKind::Config, why.to_string()),
|
||||||
}
|
|
||||||
Err(why) => {
|
|
||||||
return Message::Error(ErrorKind::Config, why.to_string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.apply(cosmic::task::future)
|
.apply(cosmic::task::future)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use std::process::Stdio;
|
||||||
|
|
||||||
pub async fn set_username(connection_name: &str, username: &str) -> Result<(), String> {
|
pub async fn set_username(connection_name: &str, username: &str) -> Result<(), String> {
|
||||||
tokio::process::Command::new("nmcli")
|
tokio::process::Command::new("nmcli")
|
||||||
.args(&["con", "mod", connection_name, "vpn.user-name", username])
|
.args(["con", "mod", connection_name, "vpn.user-name", username])
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
|
|
@ -60,7 +60,7 @@ pub async fn set_password(connection_name: &str, password: &str) -> Result<(), S
|
||||||
|
|
||||||
pub async fn connect(connection_name: &str) -> Result<(), String> {
|
pub async fn connect(connection_name: &str) -> Result<(), String> {
|
||||||
tokio::process::Command::new("nmcli")
|
tokio::process::Command::new("nmcli")
|
||||||
.args(&["con", "up", &connection_name])
|
.args(["con", "up", connection_name])
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
|
|
|
||||||
|
|
@ -726,7 +726,7 @@ fn devices_view() -> Section<crate::pages::Message> {
|
||||||
let view_more: Option<Element<_>> = if page
|
let view_more: Option<Element<_>> = if page
|
||||||
.view_more_popup
|
.view_more_popup
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map_or(false, |id| id == network.ssid.as_ref())
|
.is_some_and(|id| id == network.ssid.as_ref())
|
||||||
{
|
{
|
||||||
widget::popover(view_more_button.on_press(Message::ViewMore(None)))
|
widget::popover(view_more_button.on_press(Message::ViewMore(None)))
|
||||||
.position(widget::popover::Position::Bottom)
|
.position(widget::popover::Position::Bottom)
|
||||||
|
|
|
||||||
|
|
@ -504,7 +504,7 @@ impl Page {
|
||||||
let view_more: Option<Element<_>> = if self
|
let view_more: Option<Element<_>> = if self
|
||||||
.view_more_popup
|
.view_more_popup
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map_or(false, |id| id == connection.uuid.as_ref())
|
.is_some_and(|id| id == connection.uuid.as_ref())
|
||||||
{
|
{
|
||||||
widget::popover(view_more_button.on_press(Message::ViewMore(None)))
|
widget::popover(view_more_button.on_press(Message::ViewMore(None)))
|
||||||
.position(widget::popover::Position::Bottom)
|
.position(widget::popover::Position::Bottom)
|
||||||
|
|
|
||||||
|
|
@ -516,15 +516,11 @@ impl ConnectedDevice {
|
||||||
let proxy = enumerate_devices().await;
|
let proxy = enumerate_devices().await;
|
||||||
|
|
||||||
if let Ok(devices) = proxy {
|
if let Ok(devices) = proxy {
|
||||||
return join_all(
|
return join_all(devices.into_iter().map(Self::from_device_maybe))
|
||||||
devices
|
.await
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|device| Self::from_device_maybe(device)),
|
.flatten()
|
||||||
)
|
.collect();
|
||||||
.await
|
|
||||||
.into_iter()
|
|
||||||
.flatten()
|
|
||||||
.collect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec![]
|
vec![]
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ static SUSPEND_TIMES: &[Duration] = &[
|
||||||
Duration::from_secs(25 * 60),
|
Duration::from_secs(25 * 60),
|
||||||
Duration::from_secs(30 * 60),
|
Duration::from_secs(30 * 60),
|
||||||
Duration::from_secs(45 * 60),
|
Duration::from_secs(45 * 60),
|
||||||
Duration::from_secs(1 * 60 * 60),
|
Duration::from_secs(60 * 60),
|
||||||
Duration::from_secs(80 * 60),
|
Duration::from_secs(80 * 60),
|
||||||
Duration::from_secs(90 * 60),
|
Duration::from_secs(90 * 60),
|
||||||
Duration::from_secs(100 * 60),
|
Duration::from_secs(100 * 60),
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,9 @@ impl From<Message> for crate::Message {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Message> for subscription::Message {
|
impl From<subscription::Message> for Message {
|
||||||
fn into(self) -> Message {
|
fn from(val: subscription::Message) -> Self {
|
||||||
Message::Subscription(self)
|
Message::Subscription(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
&self,
|
&self,
|
||||||
_core: &cosmic::Core,
|
_core: &cosmic::Core,
|
||||||
) -> cosmic::iced::Subscription<crate::pages::Message> {
|
) -> cosmic::iced::Subscription<crate::pages::Message> {
|
||||||
cosmic::iced::Subscription::run(|| subscription::watch())
|
cosmic::iced::Subscription::run(subscription::watch)
|
||||||
.map(|message| Message::Subscription(message).into())
|
.map(|message| Message::Subscription(message).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,7 +269,7 @@ fn input() -> Section<crate::pages::Message> {
|
||||||
Message::SourceChanged,
|
Message::SourceChanged,
|
||||||
window::Id::RESERVED,
|
window::Id::RESERVED,
|
||||||
Message::Surface,
|
Message::Surface,
|
||||||
|a| crate::Message::from(a),
|
crate::Message::from,
|
||||||
)
|
)
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::from);
|
.map(crate::pages::Message::from);
|
||||||
|
|
@ -289,7 +289,7 @@ fn input() -> Section<crate::pages::Message> {
|
||||||
Message::SourceProfileChanged,
|
Message::SourceProfileChanged,
|
||||||
window::Id::RESERVED,
|
window::Id::RESERVED,
|
||||||
Message::Surface,
|
Message::Surface,
|
||||||
|a| crate::Message::from(a),
|
crate::Message::from,
|
||||||
)
|
)
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::from);
|
.map(crate::pages::Message::from);
|
||||||
|
|
@ -363,7 +363,7 @@ fn output() -> Section<crate::pages::Message> {
|
||||||
Message::SinkChanged,
|
Message::SinkChanged,
|
||||||
window::Id::RESERVED,
|
window::Id::RESERVED,
|
||||||
Message::Surface,
|
Message::Surface,
|
||||||
|a| crate::Message::from(a),
|
crate::Message::from,
|
||||||
)
|
)
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::from);
|
.map(crate::pages::Message::from);
|
||||||
|
|
@ -383,7 +383,7 @@ fn output() -> Section<crate::pages::Message> {
|
||||||
Message::SinkProfileChanged,
|
Message::SinkProfileChanged,
|
||||||
window::Id::RESERVED,
|
window::Id::RESERVED,
|
||||||
Message::Surface,
|
Message::Surface,
|
||||||
|a| crate::Message::from(a),
|
crate::Message::from,
|
||||||
)
|
)
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::from);
|
.map(crate::pages::Message::from);
|
||||||
|
|
|
||||||
|
|
@ -216,8 +216,8 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
validation_msg = fl!("invalid-username");
|
validation_msg = fl!("invalid-username");
|
||||||
None
|
None
|
||||||
} else if user.password != user.password_confirm
|
} else if user.password != user.password_confirm
|
||||||
&& user.password != ""
|
&& !user.password.is_empty()
|
||||||
&& user.password_confirm != ""
|
&& !user.password_confirm.is_empty()
|
||||||
{
|
{
|
||||||
validation_msg = fl!("password-mismatch");
|
validation_msg = fl!("password-mismatch");
|
||||||
None
|
None
|
||||||
|
|
@ -309,8 +309,8 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
// validation
|
// validation
|
||||||
let mut validation_msg = String::new();
|
let mut validation_msg = String::new();
|
||||||
let complete_maybe = if user.password != user.password_confirm
|
let complete_maybe = if user.password != user.password_confirm
|
||||||
&& user.password != ""
|
&& !user.password.is_empty()
|
||||||
&& user.password_confirm != ""
|
&& !user.password_confirm.is_empty()
|
||||||
{
|
{
|
||||||
validation_msg = fl!("password-mismatch");
|
validation_msg = fl!("password-mismatch");
|
||||||
None
|
None
|
||||||
|
|
@ -393,9 +393,7 @@ impl Page {
|
||||||
is_admin: match user_proxy.account_type().await {
|
is_admin: match user_proxy.account_type().await {
|
||||||
Ok(1) => true,
|
Ok(1) => true,
|
||||||
Ok(_) => false,
|
Ok(_) => false,
|
||||||
Err(_) => {
|
Err(_) => admin_group.is_some_and(|group| group.users.contains(&user.username)),
|
||||||
admin_group.map_or(false, |group| group.users.contains(&user.username))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
username: String::from(user.username),
|
username: String::from(user.username),
|
||||||
full_name: String::from(user.full_name),
|
full_name: String::from(user.full_name),
|
||||||
|
|
@ -578,16 +576,12 @@ impl Page {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
match request_permission_on_denial(&conn, || {
|
if let Err(why) = request_permission_on_denial(&conn, || {
|
||||||
user.set_password(&password_hashed, "")
|
user.set_password(&password_hashed, "")
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Err(why) => {
|
tracing::error!(?why, "failed to set password");
|
||||||
tracing::error!(?why, "failed to set password");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(_) => (),
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.discard();
|
.discard();
|
||||||
|
|
@ -757,7 +751,7 @@ fn user_list() -> Section<crate::pages::Message> {
|
||||||
.on_submit(move |_| Message::ApplyEdit(idx, EditorField::FullName))
|
.on_submit(move |_| Message::ApplyEdit(idx, EditorField::FullName))
|
||||||
.on_unfocus(Message::ApplyEdit(idx, EditorField::FullName));
|
.on_unfocus(Message::ApplyEdit(idx, EditorField::FullName));
|
||||||
|
|
||||||
let fullname_text = text::body(if user.full_name != "" {
|
let fullname_text = text::body(if !user.full_name.is_empty() {
|
||||||
&user.full_name
|
&user.full_name
|
||||||
} else {
|
} else {
|
||||||
&user.username
|
&user.username
|
||||||
|
|
@ -945,14 +939,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn permission_was_denied(result: &zbus::Error) -> bool {
|
fn permission_was_denied(result: &zbus::Error) -> bool {
|
||||||
match result {
|
matches!(result, zbus::Error::MethodError(name, _, _) if name.as_str() == "org.freedesktop.Accounts.Error.PermissionDenied")
|
||||||
zbus::Error::MethodError(name, _, _)
|
|
||||||
if name.as_str() == "org.freedesktop.Accounts.Error.PermissionDenied" =>
|
|
||||||
{
|
|
||||||
true
|
|
||||||
}
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should we allow deprecated methods?
|
// TODO: Should we allow deprecated methods?
|
||||||
|
|
@ -977,14 +964,12 @@ fn get_encrypt_method() -> String {
|
||||||
};
|
};
|
||||||
let reader = BufReader::new(login_defs);
|
let reader = BufReader::new(login_defs);
|
||||||
|
|
||||||
for line in reader.lines() {
|
for line in reader.lines().map_while(Result::ok) {
|
||||||
if let Ok(line) = line {
|
if !line.trim().is_empty() {
|
||||||
if !line.trim().is_empty() {
|
if let Some(index) = line.find(|c: char| c.is_whitespace()) {
|
||||||
if let Some(index) = line.find(|c: char| c.is_whitespace()) {
|
let key = line[0..index].trim();
|
||||||
let key = line[0..index].trim();
|
if key == "ENCRYPT_METHOD" {
|
||||||
if key == "ENCRYPT_METHOD" {
|
value = line[(index + 1)..].trim().to_string();
|
||||||
value = line[(index + 1)..].trim().to_string();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ impl Ord for SystemLocale {
|
||||||
|
|
||||||
impl PartialOrd for SystemLocale {
|
impl PartialOrd for SystemLocale {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
self.display_name.partial_cmp(&other.display_name)
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -315,7 +315,7 @@ impl Page {
|
||||||
|
|
||||||
_ = config.set("system_locales", &locales);
|
_ = config.set("system_locales", &locales);
|
||||||
|
|
||||||
if let Some(language_code) = locales.get(0) {
|
if let Some(language_code) = locales.first() {
|
||||||
if let Some(language) = self
|
if let Some(language) = self
|
||||||
.available_languages
|
.available_languages
|
||||||
.values()
|
.values()
|
||||||
|
|
@ -358,9 +358,10 @@ impl Page {
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
.contains(search_input)
|
.contains(search_input)
|
||||||
{
|
{
|
||||||
let is_installed = self.config.as_ref().map_or(false, |(_, locales)| {
|
let is_installed = self
|
||||||
locales.contains(&available_language.lang_code)
|
.config
|
||||||
});
|
.as_ref()
|
||||||
|
.is_some_and(|(_, locales)| locales.contains(&available_language.lang_code));
|
||||||
|
|
||||||
let button = widget::settings::item_row(vec![
|
let button = widget::settings::item_row(vec![
|
||||||
widget::text::body(&available_language.display_name)
|
widget::text::body(&available_language.display_name)
|
||||||
|
|
@ -488,7 +489,7 @@ impl Page {
|
||||||
let is_selected = self
|
let is_selected = self
|
||||||
.region
|
.region
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |l| l.lang_code == locale.lang_code);
|
.is_some_and(|l| l.lang_code == locale.lang_code);
|
||||||
|
|
||||||
let button = widget::settings::item_row(vec![
|
let button = widget::settings::item_row(vec![
|
||||||
widget::text::body(&locale.region_name)
|
widget::text::body(&locale.region_name)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ pub fn color_picker_context_view<'a, Message: Clone + 'static>(
|
||||||
let theme = theme::active();
|
let theme = theme::active();
|
||||||
let spacing = &theme.cosmic().spacing;
|
let spacing = &theme.cosmic().spacing;
|
||||||
|
|
||||||
let description = description.map(|description| text::caption(description));
|
let description = description.map(text::caption);
|
||||||
|
|
||||||
let color_picker = model
|
let color_picker = model
|
||||||
.builder(on_update)
|
.builder(on_update)
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ pub fn processor_name(bump: &Bump, name: &mut String) {
|
||||||
let s = sysinfo::System::new_with_specifics(
|
let s = sysinfo::System::new_with_specifics(
|
||||||
sysinfo::RefreshKind::nothing().with_cpu(sysinfo::CpuRefreshKind::everything()),
|
sysinfo::RefreshKind::nothing().with_cpu(sysinfo::CpuRefreshKind::everything()),
|
||||||
);
|
);
|
||||||
name.push_str(s.cpus().into_iter().nth(0).unwrap().brand());
|
name.push_str(s.cpus().iter().next().unwrap().brand());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_to_string<'a, P: AsRef<OsStr>>(
|
pub fn read_to_string<'a, P: AsRef<OsStr>>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue