chore: run cargo fmt
This commit is contained in:
@@ -41,7 +41,9 @@ fn build_gtk_widget_from_node(
|
||||
|
||||
let gtk_widget = match root_node {
|
||||
WidgetNode::Box { props, children } => build_gtk_box(props, children, widget_reg)?.upcast(),
|
||||
WidgetNode::FlowBox { props, children } => build_gtk_flowbox(props, children, widget_reg)?.upcast(),
|
||||
WidgetNode::FlowBox { props, children } => {
|
||||
build_gtk_flowbox(props, children, widget_reg)?.upcast()
|
||||
}
|
||||
WidgetNode::EventBox { props, children } => {
|
||||
build_event_box(props, children, widget_reg)?.upcast()
|
||||
}
|
||||
|
||||
@@ -770,10 +770,13 @@ pub(crate) fn build_gtk_flowbox(
|
||||
|
||||
let controller_data = Rc::new(RefCell::new(FlowBoxCtrlData {
|
||||
onaccept_cmd: String::new(),
|
||||
cmd_timeout: Duration::from_millis(200)
|
||||
cmd_timeout: Duration::from_millis(200),
|
||||
}));
|
||||
|
||||
gtk_widget.connect_child_activated(glib::clone!(#[strong] controller_data, move |_: >k4::FlowBox, child: >k4::FlowBoxChild| {
|
||||
gtk_widget.connect_child_activated(glib::clone!(
|
||||
#[strong]
|
||||
controller_data,
|
||||
move |_: >k4::FlowBox, child: >k4::FlowBoxChild| {
|
||||
let controller = controller_data.borrow();
|
||||
|
||||
let index = child.index();
|
||||
@@ -782,7 +785,8 @@ pub(crate) fn build_gtk_flowbox(
|
||||
} else {
|
||||
log::error!("Failed to get child index.");
|
||||
}
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
for child in children {
|
||||
let child_widget = build_gtk_widget(&WidgetInput::BorrowedNode(child), widget_registry)?;
|
||||
@@ -797,7 +801,10 @@ pub(crate) fn build_gtk_flowbox(
|
||||
}
|
||||
}
|
||||
|
||||
let apply_props = |props: &Map, gtk_widget: >k4::FlowBox, controller_data: Rc<RefCell<FlowBoxCtrlData>>| -> Result<()> {
|
||||
let apply_props = |props: &Map,
|
||||
gtk_widget: >k4::FlowBox,
|
||||
controller_data: Rc<RefCell<FlowBoxCtrlData>>|
|
||||
-> Result<()> {
|
||||
if let Ok(space_evenly) = get_bool_prop(&props, "space_evenly", Some(true)) {
|
||||
gtk_widget.set_homogeneous(space_evenly);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use ahash::AHasher;
|
||||
use anyhow::Result;
|
||||
use rhai::Map;
|
||||
use scan_prop_proc::scan_prop;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use scan_prop_proc::scan_prop;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[scan_prop]
|
||||
|
||||
@@ -14,7 +14,7 @@ pub fn format_eval_error(
|
||||
let error_str = error.to_string();
|
||||
|
||||
if error_str == "" || error_str == "module_eval_failed" || error_str == "module_parse_failed" {
|
||||
return String::new()
|
||||
return String::new();
|
||||
}
|
||||
|
||||
let better_error =
|
||||
@@ -33,7 +33,7 @@ pub fn format_parse_error(error: &ParseError, code: &str, file_id: Option<&str>)
|
||||
let error_str = error.to_string();
|
||||
|
||||
if error_str == "" || error_str == "module_eval_failed" || error_str == "module_parse_failed" {
|
||||
return String::new()
|
||||
return String::new();
|
||||
}
|
||||
|
||||
let better_error = BetterError::improve_parse_error(error, code).unwrap_or(BetterError {
|
||||
@@ -67,15 +67,12 @@ pub fn format_codespan_error(be: BetterError, code: &str, file_id: Option<&str>)
|
||||
let mut labels = Vec::new();
|
||||
if be.span.start() != be.span.end() {
|
||||
labels.push(
|
||||
Label::primary(file_id, be.span.start()..be.span.end())
|
||||
.with_message(&be.message),
|
||||
Label::primary(file_id, be.span.start()..be.span.end()).with_message(&be.message),
|
||||
);
|
||||
}
|
||||
|
||||
let diagnostic = Diagnostic::error()
|
||||
.with_message(&be.message)
|
||||
.with_labels(labels)
|
||||
.with_notes(notes);
|
||||
let diagnostic =
|
||||
Diagnostic::error().with_message(&be.message).with_labels(labels).with_notes(notes);
|
||||
|
||||
let mut buffer = Buffer::ansi();
|
||||
let config = term::Config::default();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{parse_macro_input, DeriveInput, Data, Fields};
|
||||
use syn::{parse_macro_input, Data, DeriveInput, Fields};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn scan_prop(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
@@ -8,8 +8,10 @@ pub fn scan_prop(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let name = &input.ident;
|
||||
|
||||
let props_matches = if let Data::Enum(data_enum) = &input.data {
|
||||
data_enum.variants.iter().filter_map(|v| {
|
||||
match &v.fields {
|
||||
data_enum
|
||||
.variants
|
||||
.iter()
|
||||
.filter_map(|v| match &v.fields {
|
||||
Fields::Named(fields) => {
|
||||
for f in &fields.named {
|
||||
if f.ident.as_ref().map(|id| id == "props").unwrap_or(false) {
|
||||
@@ -22,8 +24,8 @@ pub fn scan_prop(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}).collect::<Vec<_>>()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user