Fix a few clippy warnings (#59)
This commit is contained in:
parent
2e8b1af083
commit
ac8bc7d8b5
11 changed files with 36 additions and 46 deletions
|
@ -7,7 +7,6 @@ use crate::{
|
||||||
widgets,
|
widgets,
|
||||||
};
|
};
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use crossbeam_channel;
|
|
||||||
use debug_stub_derive::*;
|
use debug_stub_derive::*;
|
||||||
use gdk::WindowExt;
|
use gdk::WindowExt;
|
||||||
use gtk::{ContainerExt, CssProviderExt, GtkWindowExt, StyleContextExt, WidgetExt};
|
use gtk::{ContainerExt, CssProviderExt, GtkWindowExt, StyleContextExt, WidgetExt};
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl<'a, 'b> XmlNode<'a, 'b> {
|
||||||
match self {
|
match self {
|
||||||
XmlNode::Text(x) => x.0,
|
XmlNode::Text(x) => x.0,
|
||||||
XmlNode::Element(x) => x.0,
|
XmlNode::Element(x) => x.0,
|
||||||
XmlNode::Ignored(x) => x.clone(),
|
XmlNode::Ignored(x) => *x,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ impl<'a, 'b> fmt::Display for XmlElement<'a, 'b> {
|
||||||
.map(|x| x.lines().map(|line| format!(" {}", line)).join("\n"))
|
.map(|x| x.lines().map(|line| format!(" {}", line)).join("\n"))
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
if children.len() == 0 {
|
if children.is_empty() {
|
||||||
write!(f, "{}</{}>", self.as_tag_string(), self.tag_name())
|
write!(f, "{}</{}>", self.as_tag_string(), self.tag_name())
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}\n{}\n</{}>", self.as_tag_string(), children, self.tag_name())
|
write!(f, "{}\n{}\n</{}>", self.as_tag_string(), children, self.tag_name())
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -10,8 +10,6 @@ extern crate gtk;
|
||||||
|
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
|
|
||||||
use log;
|
|
||||||
use pretty_env_logger;
|
|
||||||
use std::{os::unix::net, path::PathBuf};
|
use std::{os::unix::net, path::PathBuf};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
@ -33,12 +31,12 @@ lazy_static::lazy_static! {
|
||||||
.join("eww-server");
|
.join("eww-server");
|
||||||
|
|
||||||
pub static ref CONFIG_DIR: std::path::PathBuf = std::env::var("XDG_CONFIG_HOME")
|
pub static ref CONFIG_DIR: std::path::PathBuf = std::env::var("XDG_CONFIG_HOME")
|
||||||
.map(|v| PathBuf::from(v))
|
.map(PathBuf::from)
|
||||||
.unwrap_or_else(|_| PathBuf::from(std::env::var("HOME").unwrap()).join(".config"))
|
.unwrap_or_else(|_| PathBuf::from(std::env::var("HOME").unwrap()).join(".config"))
|
||||||
.join("eww");
|
.join("eww");
|
||||||
|
|
||||||
pub static ref LOG_FILE: std::path::PathBuf = std::env::var("XDG_CACHE_HOME")
|
pub static ref LOG_FILE: std::path::PathBuf = std::env::var("XDG_CACHE_HOME")
|
||||||
.map(|v| PathBuf::from(v))
|
.map(PathBuf::from)
|
||||||
.unwrap_or_else(|_| PathBuf::from(std::env::var("HOME").unwrap()).join(".cache"))
|
.unwrap_or_else(|_| PathBuf::from(std::env::var("HOME").unwrap()).join(".cache"))
|
||||||
.join("eww.log");
|
.join("eww.log");
|
||||||
}
|
}
|
||||||
|
@ -56,14 +54,14 @@ fn main() {
|
||||||
opts::Action::WithServer(action) => {
|
opts::Action::WithServer(action) => {
|
||||||
log::info!("Trying to find server process");
|
log::info!("Trying to find server process");
|
||||||
if let Ok(stream) = net::UnixStream::connect(&*IPC_SOCKET_PATH) {
|
if let Ok(stream) = net::UnixStream::connect(&*IPC_SOCKET_PATH) {
|
||||||
|
|
||||||
client::forward_command_to_server(stream, action).context("Error while forwarding command to server")?;
|
client::forward_command_to_server(stream, action).context("Error while forwarding command to server")?;
|
||||||
|
} else if action.needs_server_running() {
|
||||||
|
println!("No eww server running");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if action.needs_server_running() {
|
log::info!("No server running, initializing server...");
|
||||||
println!("No eww server running");
|
server::initialize_server(opts.should_detach, action)?;
|
||||||
} else {
|
|
||||||
log::info!("No server running, initializing server...");
|
|
||||||
server::initialize_server(opts.should_detach, action)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,9 +93,7 @@ fn parse_var_update_arg(s: &str) -> Result<(VarName, PrimitiveValue)> {
|
||||||
impl ActionWithServer {
|
impl ActionWithServer {
|
||||||
pub fn into_eww_command(self) -> (app::EwwCommand, Option<crossbeam_channel::Receiver<String>>) {
|
pub fn into_eww_command(self) -> (app::EwwCommand, Option<crossbeam_channel::Receiver<String>>) {
|
||||||
let command = match self {
|
let command = match self {
|
||||||
ActionWithServer::Update { mappings } => {
|
ActionWithServer::Update { mappings } => app::EwwCommand::UpdateVars(mappings.into_iter().collect()),
|
||||||
app::EwwCommand::UpdateVars(mappings.into_iter().map(|x| x.into()).collect())
|
|
||||||
}
|
|
||||||
ActionWithServer::OpenWindow {
|
ActionWithServer::OpenWindow {
|
||||||
window_name,
|
window_name,
|
||||||
pos,
|
pos,
|
||||||
|
|
|
@ -10,9 +10,9 @@ use crate::{
|
||||||
};
|
};
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use app::EwwCommand;
|
use app::EwwCommand;
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use glib;
|
|
||||||
use scheduled_executor;
|
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
|
|
||||||
use self::script_var_process::ScriptVarProcess;
|
use self::script_var_process::ScriptVarProcess;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::{app, config, eww_state::*, opts, script_var_handler, try_logging_errors, util};
|
use crate::{app, config, eww_state::*, opts, script_var_handler, try_logging_errors, util};
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use log;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
io::Write,
|
io::Write,
|
||||||
|
@ -25,8 +24,7 @@ pub fn initialize_server(should_detach: bool, action: opts::ActionWithServer) ->
|
||||||
let config_dir = config_file_path
|
let config_dir = config_file_path
|
||||||
.parent()
|
.parent()
|
||||||
.context("config file did not have a parent?!")?
|
.context("config file did not have a parent?!")?
|
||||||
.to_owned()
|
.to_owned();
|
||||||
.to_path_buf();
|
|
||||||
let scss_file_path = config_dir.join("eww.scss");
|
let scss_file_path = config_dir.join("eww.scss");
|
||||||
|
|
||||||
log::info!("reading configuration from {:?}", &config_file_path);
|
log::info!("reading configuration from {:?}", &config_file_path);
|
||||||
|
@ -39,7 +37,7 @@ pub fn initialize_server(should_detach: bool, action: opts::ActionWithServer) ->
|
||||||
let script_var_handler = script_var_handler::ScriptVarHandler::new(evt_send.clone())?;
|
let script_var_handler = script_var_handler::ScriptVarHandler::new(evt_send.clone())?;
|
||||||
|
|
||||||
let mut app = app::App {
|
let mut app = app::App {
|
||||||
eww_state: EwwState::from_default_vars(eww_config.generate_initial_state()?.clone()),
|
eww_state: EwwState::from_default_vars(eww_config.generate_initial_state()?),
|
||||||
eww_config,
|
eww_config,
|
||||||
windows: HashMap::new(),
|
windows: HashMap::new(),
|
||||||
css_provider: gtk::CssProvider::new(),
|
css_provider: gtk::CssProvider::new(),
|
||||||
|
@ -68,7 +66,7 @@ pub fn initialize_server(should_detach: bool, action: opts::ActionWithServer) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
run_server_thread(evt_send.clone())?;
|
run_server_thread(evt_send.clone())?;
|
||||||
let _hotwatch = run_filewatch_thread(&config_file_path, &scss_file_path, evt_send.clone())?;
|
let _hotwatch = run_filewatch_thread(&config_file_path, &scss_file_path, evt_send)?;
|
||||||
|
|
||||||
evt_recv.attach(None, move |msg| {
|
evt_recv.attach(None, move |msg| {
|
||||||
app.handle_command(msg);
|
app.handle_command(msg);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use extend::ext;
|
use extend::ext;
|
||||||
use grass;
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|
|
@ -86,28 +86,26 @@ impl AttrValue {
|
||||||
curly_count = 2;
|
curly_count = 2;
|
||||||
varref.push(c);
|
varref.push(c);
|
||||||
}
|
}
|
||||||
} else {
|
} else if c == '{' {
|
||||||
if c == '{' {
|
curly_count += 1;
|
||||||
curly_count += 1;
|
if curly_count == 2 {
|
||||||
if curly_count == 2 {
|
if !cur_word.is_empty() {
|
||||||
if !cur_word.is_empty() {
|
elements.push(AttrValueElement::primitive(std::mem::take(&mut cur_word)));
|
||||||
elements.push(AttrValueElement::primitive(std::mem::take(&mut cur_word)));
|
|
||||||
}
|
|
||||||
cur_varref = Some(String::new())
|
|
||||||
}
|
}
|
||||||
} else {
|
cur_varref = Some(String::new())
|
||||||
if curly_count == 1 {
|
|
||||||
cur_word.push('{');
|
|
||||||
}
|
|
||||||
curly_count = 0;
|
|
||||||
cur_word.push(c);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if curly_count == 1 {
|
||||||
|
cur_word.push('{');
|
||||||
|
}
|
||||||
|
curly_count = 0;
|
||||||
|
cur_word.push(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(unfinished_varref) = cur_varref.take() {
|
if let Some(unfinished_varref) = cur_varref.take() {
|
||||||
elements.push(AttrValueElement::primitive(unfinished_varref));
|
elements.push(AttrValueElement::primitive(unfinished_varref));
|
||||||
} else if !cur_word.is_empty() {
|
} else if !cur_word.is_empty() {
|
||||||
elements.push(AttrValueElement::primitive(cur_word.to_owned()));
|
elements.push(AttrValueElement::primitive(cur_word));
|
||||||
}
|
}
|
||||||
AttrValue(elements)
|
AttrValue(elements)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use derive_more;
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{convert::TryFrom, fmt, iter::FromIterator};
|
use std::{convert::TryFrom, fmt, iter::FromIterator};
|
||||||
|
@ -63,7 +62,7 @@ impl From<&str> for PrimitiveValue {
|
||||||
|
|
||||||
impl PrimitiveValue {
|
impl PrimitiveValue {
|
||||||
pub fn from_string(s: String) -> Self {
|
pub fn from_string(s: String) -> Self {
|
||||||
PrimitiveValue(s.to_string())
|
PrimitiveValue(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_inner(self) -> String {
|
pub fn into_inner(self) -> String {
|
||||||
|
|
|
@ -146,10 +146,12 @@ fn build_builtin_gtk_widget(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget.dynamic_cast_ref().map(|w| resolve_range_attrs(&mut bargs, &w));
|
if let Some(w) = gtk_widget.dynamic_cast_ref() {
|
||||||
gtk_widget
|
resolve_range_attrs(&mut bargs, &w)
|
||||||
.dynamic_cast_ref()
|
}
|
||||||
.map(|w| resolve_orientable_attrs(&mut bargs, &w));
|
if let Some(w) = gtk_widget.dynamic_cast_ref() {
|
||||||
|
resolve_orientable_attrs(&mut bargs, &w)
|
||||||
|
};
|
||||||
resolve_widget_attrs(&mut bargs, >k_widget);
|
resolve_widget_attrs(&mut bargs, >k_widget);
|
||||||
|
|
||||||
if !bargs.unhandled_attrs.is_empty() {
|
if !bargs.unhandled_attrs.is_empty() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use super::{run_command, BuilderArgs};
|
use super::{run_command, BuilderArgs};
|
||||||
use crate::{config, eww_state, resolve_block, value::AttrValue};
|
use crate::{config, eww_state, resolve_block, value::AttrValue};
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use gdk_pixbuf;
|
|
||||||
use gtk::{prelude::*, ImageExt};
|
use gtk::{prelude::*, ImageExt};
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue