mirror of
https://github.com/apognu/tuigreet.git
synced 2024-11-25 09:43:57 +03:00
Fix Clippy lints.
This commit is contained in:
parent
1594e09951
commit
2f74df5cc2
@ -22,7 +22,9 @@ use tokio::{
|
||||
use zeroize::Zeroize;
|
||||
|
||||
use crate::{
|
||||
info::{get_issue, get_last_session, get_last_session_path, get_last_user_name, get_last_user_session, get_last_user_session_path, get_last_user_username, get_min_max_uids, get_users},
|
||||
info::{
|
||||
get_issue, get_last_session, get_last_session_path, get_last_user_name, get_last_user_session, get_last_user_session_path, get_last_user_username, get_min_max_uids, get_sessions, get_users,
|
||||
},
|
||||
power::PowerOption,
|
||||
ui::{
|
||||
common::menu::Menu,
|
||||
@ -102,7 +104,7 @@ pub struct Greeter {
|
||||
pub greeting: Option<String>,
|
||||
pub message: Option<String>,
|
||||
|
||||
pub power_commands: Menu<Power>,
|
||||
pub powers: Menu<Power>,
|
||||
pub power_command: Option<Command>,
|
||||
pub power_command_notify: Arc<Notify>,
|
||||
pub power_setsid: bool,
|
||||
@ -124,7 +126,7 @@ impl Greeter {
|
||||
|
||||
greeter.set_locale();
|
||||
|
||||
greeter.power_commands = Menu {
|
||||
greeter.powers = Menu {
|
||||
title: fl!("title_power"),
|
||||
options: Default::default(),
|
||||
selected: 0,
|
||||
@ -133,7 +135,7 @@ impl Greeter {
|
||||
greeter.parse_options().await;
|
||||
greeter.sessions = Menu {
|
||||
title: fl!("title_session"),
|
||||
options: crate::info::get_sessions(&greeter).unwrap_or_default(),
|
||||
options: get_sessions(&greeter).unwrap_or_default(),
|
||||
selected: 0,
|
||||
};
|
||||
|
||||
@ -421,13 +423,13 @@ impl Greeter {
|
||||
self.greeting = get_issue();
|
||||
}
|
||||
|
||||
self.power_commands.options.push(Power {
|
||||
self.powers.options.push(Power {
|
||||
action: PowerOption::Shutdown,
|
||||
label: fl!("shutdown"),
|
||||
command: self.config().opt_str("power-shutdown"),
|
||||
});
|
||||
|
||||
self.power_commands.options.push(Power {
|
||||
self.powers.options.push(Power {
|
||||
action: PowerOption::Reboot,
|
||||
label: fl!("reboot"),
|
||||
command: self.config().opt_str("power-reboot"),
|
||||
|
@ -128,7 +128,7 @@ impl Ipc {
|
||||
|
||||
if let Some(Session { session_type, .. }) = session {
|
||||
if *session_type != SessionType::None {
|
||||
env.push(format!("XDG_SESSION_TYPE={}", session_type.to_xdg_session_type()));
|
||||
env.push(format!("XDG_SESSION_TYPE={}", session_type.as_xdg_session_type()));
|
||||
}
|
||||
|
||||
if *session_type == SessionType::X11 {
|
||||
|
@ -96,8 +96,8 @@ pub async fn handle(greeter: Arc<RwLock<Greeter>>, events: &mut Events, ipc: Ipc
|
||||
}
|
||||
|
||||
if let Mode::Power = greeter.mode {
|
||||
if greeter.power_commands.selected > 0 {
|
||||
greeter.power_commands.selected -= 1;
|
||||
if greeter.powers.selected > 0 {
|
||||
greeter.powers.selected -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,8 +116,8 @@ pub async fn handle(greeter: Arc<RwLock<Greeter>>, events: &mut Events, ipc: Ipc
|
||||
}
|
||||
|
||||
if let Mode::Power = greeter.mode {
|
||||
if greeter.power_commands.selected < greeter.power_commands.options.len() - 1 {
|
||||
greeter.power_commands.selected += 1;
|
||||
if greeter.powers.selected < greeter.powers.options.len() - 1 {
|
||||
greeter.powers.selected += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -218,7 +218,7 @@ pub async fn handle(greeter: Arc<RwLock<Greeter>>, events: &mut Events, ipc: Ipc
|
||||
}
|
||||
|
||||
Mode::Power => {
|
||||
let power_command = greeter.power_commands.options.get(greeter.power_commands.selected).cloned();
|
||||
let power_command = greeter.powers.options.get(greeter.powers.selected).cloned();
|
||||
|
||||
if let Some(command) = power_command {
|
||||
power(&mut greeter, command.action);
|
||||
|
@ -12,7 +12,7 @@ pub enum PowerOption {
|
||||
}
|
||||
|
||||
pub fn power(greeter: &mut Greeter, option: PowerOption) {
|
||||
let command = match greeter.power_commands.options.iter().find(|opt| opt.action == option) {
|
||||
let command = match greeter.powers.options.iter().find(|opt| opt.action == option) {
|
||||
None => None,
|
||||
|
||||
Some(Power { command: Some(args), .. }) => {
|
||||
|
@ -111,7 +111,7 @@ pub async fn draw(greeter: Arc<RwLock<Greeter>>, terminal: &mut Term) -> Result<
|
||||
let cursor = match greeter.mode {
|
||||
Mode::Command => self::command::draw(&mut greeter, f).ok(),
|
||||
Mode::Sessions => greeter.sessions.draw(&greeter, f).ok(),
|
||||
Mode::Power => greeter.power_commands.draw(&greeter, f).ok(),
|
||||
Mode::Power => greeter.powers.draw(&greeter, f).ok(),
|
||||
Mode::Users => greeter.users.draw(&greeter, f).ok(),
|
||||
Mode::Processing => self::processing::draw(&mut greeter, f).ok(),
|
||||
_ => self::prompt::draw(&mut greeter, f).ok(),
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{power::PowerOption, ui::common::menu::MenuItem};
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
#[derive(SmartDefault, Clone)]
|
||||
pub struct Power {
|
||||
pub action: PowerOption,
|
||||
pub label: String,
|
||||
|
@ -6,17 +6,17 @@ use super::common::menu::MenuItem;
|
||||
pub enum SessionType {
|
||||
X11,
|
||||
Wayland,
|
||||
TTY,
|
||||
Tty,
|
||||
#[default]
|
||||
None,
|
||||
}
|
||||
|
||||
impl SessionType {
|
||||
pub fn to_xdg_session_type(&self) -> &'static str {
|
||||
pub fn as_xdg_session_type(&self) -> &'static str {
|
||||
match self {
|
||||
SessionType::X11 => "x11",
|
||||
SessionType::Wayland => "wayland",
|
||||
SessionType::TTY => "tty",
|
||||
SessionType::Tty => "tty",
|
||||
SessionType::None => "unspecified",
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user