Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,16 @@ pub enum AccessibilityEvent {
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive)]
#[derive(Default)]
pub enum ColorFilter {
Greyscale,
Deuteranopia,
Protanopia,
Tritanopia,
#[default]
Unknown,
}

impl Default for ColorFilter {
fn default() -> Self {
ColorFilter::Unknown
}
}

#[derive(Debug, Clone, Copy)]
pub enum AccessibilityRequest {
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
page::AppMode::GnomeTransition
} else {
// If being run by the cosmic-initial-setup user, we are in OEM mode.
page::AppMode::NewInstall { create_user: pwd::Passwd::current_user().map_or(false, |current_user| current_user.name == "cosmic-initial-setup") }
page::AppMode::NewInstall { create_user: pwd::Passwd::current_user().is_some_and(|current_user| current_user.name == "cosmic-initial-setup") }
};

let mut settings = Settings::default();
Expand Down Expand Up @@ -312,7 +312,7 @@ impl Application for App {
tasks = tasks.chain(
cosmic::Task::future(async {
_ = std::process::Command::new("loginctl")
.args(&["terminate-user", "cosmic-initial-setup"])
.args(["terminate-user", "cosmic-initial-setup"])
.status();
})
.discard(),
Expand Down
12 changes: 6 additions & 6 deletions src/page/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use std::{ffi::OsStr, io::Read};

use crate::{fl, page};

static COSMIC_DARK_PNG: &'static [u8] = include_bytes!("../../res/cosmic-dark.png");
static COSMIC_LIGHT_PNG: &'static [u8] = include_bytes!("../../res/cosmic-light.png");
static COSMIC_DARK_PNG: &[u8] = include_bytes!("../../res/cosmic-dark.png");
static COSMIC_LIGHT_PNG: &[u8] = include_bytes!("../../res/cosmic-light.png");

fn dark_icon() -> widget::image::Handle {
widget::image::Handle::from_bytes(COSMIC_DARK_PNG)
Expand All @@ -38,7 +38,7 @@ impl PartialEq for Theme {

impl PartialOrd for Theme {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.name.partial_cmp(&other.name)
Some(self.cmp(other))
}
}

Expand Down Expand Up @@ -146,7 +146,7 @@ impl Page {
}
}

themes.extend(extra_themes.into_iter());
themes.extend(extra_themes);
}

Self {
Expand Down Expand Up @@ -196,10 +196,10 @@ impl Page {
}
}

return cosmic::Task::done(page::Message::SetTheme(cosmic::Theme {
cosmic::Task::done(page::Message::SetTheme(cosmic::Theme {
theme_type: ThemeType::Custom(Arc::new(theme)),
..cosmic::Theme::default()
}));
}))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/page/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum Message {

impl From<Message> for super::Message {
fn from(message: Message) -> Self {
super::Message::Keyboard(message).into()
super::Message::Keyboard(message)
}
}

Expand Down Expand Up @@ -268,7 +268,7 @@ impl page::Page for Page {
}

fn open(&mut self) -> cosmic::Task<page::Message> {
return widget::text_input::focus(self.search_id.clone());
widget::text_input::focus(self.search_id.clone())
}

fn completed(&self) -> bool {
Expand Down
12 changes: 6 additions & 6 deletions src/page/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum Message {

impl From<Message> for super::Message {
fn from(message: Message) -> Self {
super::Message::Language(message).into()
super::Message::Language(message)
}
}

Expand Down Expand Up @@ -213,7 +213,7 @@ impl super::Page for Page {

let current_lang = std::env::var("LANG").ok();
if let Some(lang) = current_lang.as_ref() {
if let Some(locale) = registry.locale(&lang) {
if let Some(locale) = registry.locale(lang) {
selected = available_languages.insert(localized_locale(&locale, lang.clone()));
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ impl super::Page for Page {
}

fn open(&mut self) -> cosmic::Task<page::Message> {
return widget::text_input::focus(self.search_id.clone());
widget::text_input::focus(self.search_id.clone())
}

fn completed(&self) -> bool {
Expand Down Expand Up @@ -286,7 +286,7 @@ impl super::Page for Page {
.spacing(space_xxs),
),
)
.on_press(Message::Select(id.clone()))
.on_press(Message::Select(id))
.class(if selected {
theme::Button::Link
} else {
Expand All @@ -305,7 +305,7 @@ impl super::Page for Page {
if let Some(first) = first_opt {
if self.regex_opt.is_some() {
// Select first item if no item is selected and there is a search
search_input = search_input.on_submit(move |_| Message::Select(first.clone()));
search_input = search_input.on_submit(move |_| Message::Select(first));
}
}

Expand Down Expand Up @@ -384,7 +384,7 @@ impl Ord for SystemLocale {

impl PartialOrd for SystemLocale {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.display_name.partial_cmp(&other.display_name)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/page/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cosmic::{

use crate::{fl, page};

static LAUNCHER_SVG: &'static [u8] = include_bytes!("../../res/launcher.svg");
static LAUNCHER_SVG: &[u8] = include_bytes!("../../res/launcher.svg");

pub struct Page {
handle: widget::svg::Handle,
Expand Down
6 changes: 3 additions & 3 deletions src/page/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::fl;
use crate::page;
use cosmic::{Element, Task, cosmic_theme, iced::Alignment, theme, widget};

static CITIES: &'static [u8] = include_bytes!("../../res/cities.bitcode-v0-6");
static CITIES: &[u8] = include_bytes!("../../res/cities.bitcode-v0-6");

#[derive(Clone, Debug)]
pub enum Message {
Expand Down Expand Up @@ -66,7 +66,7 @@ impl Page {
let timezone = city.timezone.clone();
tokio::spawn(async move {
_ = tokio::process::Command::new("timedatectl")
.args(&["set-timezone", &timezone])
.args(["set-timezone", &timezone])
.status()
.await;
});
Expand All @@ -87,7 +87,7 @@ impl page::Page for Page {
}

fn open(&mut self) -> cosmic::Task<page::Message> {
return widget::text_input::focus(self.search_id.clone());
widget::text_input::focus(self.search_id.clone())
}

fn completed(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/page/new_apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cosmic::{
};
use std::any::Any;

static SCREENSHOT: &'static [u8] = include_bytes!("../../res/new-apps.svg");
static SCREENSHOT: &[u8] = include_bytes!("../../res/new-apps.svg");

pub struct Page {
handle: widget::svg::Handle,
Expand Down
2 changes: 1 addition & 1 deletion src/page/new_shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cosmic::{
};
use std::any::Any;

static SCREENSHOT: &'static [u8] = include_bytes!("../../res/new-shortcuts.svg");
static SCREENSHOT: &[u8] = include_bytes!("../../res/new-shortcuts.svg");

pub struct Page {
handle: widget::svg::Handle,
Expand Down
25 changes: 8 additions & 17 deletions src/page/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,7 @@ where
}

fn permission_was_denied(result: &zbus::Error) -> bool {
match result {
zbus::Error::MethodError(name, _, _)
if name.as_str() == "org.freedesktop.Accounts.Error.PermissionDenied" =>
{
true
}
_ => false,
}
matches!(result, zbus::Error::MethodError(name, _, _) if name.as_str() == "org.freedesktop.Accounts.Error.PermissionDenied")
}

// TODO: Should we allow deprecated methods?
Expand All @@ -371,14 +364,12 @@ fn get_encrypt_method() -> String {
};
let reader = BufReader::new(login_defs);

for line in reader.lines() {
if let Ok(line) = line {
if !line.trim().is_empty() {
if let Some(index) = line.find(|c: char| c.is_whitespace()) {
let key = line[0..index].trim();
if key == "ENCRYPT_METHOD" {
value = line[(index + 1)..].trim().to_string();
}
for line in reader.lines().map_while(Result::ok) {
if !line.trim().is_empty() {
if let Some(index) = line.find(|c: char| c.is_whitespace()) {
let key = line[0..index].trim();
if key == "ENCRYPT_METHOD" {
value = line[(index + 1)..].trim().to_string();
}
}
}
Expand All @@ -389,7 +380,7 @@ fn get_encrypt_method() -> String {
fn username_valid(username: &str) -> bool {
Regex::new("^[a-z][a-z0-9-]{0,30}$")
.unwrap()
.is_match(&username)
.is_match(username)
}

fn password_valid(password: &str, password_confirm: &str) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/page/wifi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl super::Page for Page {
let view_more: Option<Element<_>> = if self
.view_more_popup
.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)))
.position(widget::popover::Position::Bottom)
Expand Down Expand Up @@ -355,7 +355,7 @@ pub enum Message {

impl From<Message> for super::Message {
fn from(message: Message) -> Self {
super::Message::WiFi(message).into()
super::Message::WiFi(message)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/page/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cosmic::{
};
use std::any::Any;

static SCREENSHOT: &'static [u8] = include_bytes!("../../res/workspaces.svg");
static SCREENSHOT: &[u8] = include_bytes!("../../res/workspaces.svg");

pub struct Page {
handle: widget::svg::Handle,
Expand Down