feat: parse widget_action ucontainer actions like shell
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -515,6 +515,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shared_utils",
|
||||
"shell-words",
|
||||
"simple-signal",
|
||||
"smart-default",
|
||||
"static_assertions",
|
||||
@@ -1925,6 +1926,12 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell-words"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
|
||||
@@ -49,6 +49,7 @@ wait-timeout = "0.2"
|
||||
syn = "2.0.107"
|
||||
quote = "1.0.41"
|
||||
proc-macro2 = "1.0.101"
|
||||
shell-words = "1.1.0"
|
||||
|
||||
[profile.dev]
|
||||
split-debuginfo = "unpacked"
|
||||
|
||||
@@ -50,6 +50,7 @@ tokio = { workspace = true, features = ["full"] }
|
||||
unescape.workspace = true
|
||||
wait-timeout.workspace = true
|
||||
rhai = { workspace = true, features = ["internals"] }
|
||||
shell-words.workspace = true
|
||||
# Plugin loading
|
||||
libloading = "0.8.9"
|
||||
|
||||
|
||||
@@ -579,19 +579,27 @@ pub(super) fn build_widgetaction_util(
|
||||
move |_, _| {
|
||||
if let Some(child) = gtk_widget.first_child() {
|
||||
for action in &actions {
|
||||
let mut parts = action.split_whitespace();
|
||||
let parts = match shell_words::split(action) {
|
||||
Ok(v) => v,
|
||||
Err(err) => {
|
||||
log::error!("Failed to parse action `{action}`: {err}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
let mut parts = parts.into_iter();
|
||||
let cmd = parts.next();
|
||||
|
||||
match cmd {
|
||||
match cmd.as_deref() {
|
||||
Some("add-class") => {
|
||||
if let Some(class) = parts.next() {
|
||||
child.add_css_class(class);
|
||||
child.add_css_class(&class);
|
||||
}
|
||||
}
|
||||
|
||||
Some("remove-class") => {
|
||||
if let Some(class) = parts.next() {
|
||||
child.remove_css_class(class);
|
||||
child.remove_css_class(&class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user