mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
feat(sway): support workspace rename events (#799)
And reorder based on label with fallback to widget name
This commit is contained in:
parent
13c2f8fa8b
commit
9f7c3918c4
2 changed files with 23 additions and 1 deletions
|
@ -109,6 +109,16 @@ impl From<WorkspaceEvent> for WorkspaceUpdate {
|
||||||
WorkspaceChange::Move => {
|
WorkspaceChange::Move => {
|
||||||
Self::Move(event.current.expect("Missing current workspace").into())
|
Self::Move(event.current.expect("Missing current workspace").into())
|
||||||
}
|
}
|
||||||
|
WorkspaceChange::Rename => {
|
||||||
|
if let Some(node) = event.current {
|
||||||
|
Self::Rename {
|
||||||
|
id: node.id,
|
||||||
|
name: node.name.unwrap_or_default(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Self::Unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
WorkspaceChange::Urgent => {
|
WorkspaceChange::Urgent => {
|
||||||
if let Some(node) = event.current {
|
if let Some(node) = event.current {
|
||||||
Self::Urgent {
|
Self::Urgent {
|
||||||
|
|
|
@ -164,7 +164,15 @@ fn reorder_workspaces(container: >k::Box) {
|
||||||
let mut buttons = container
|
let mut buttons = container
|
||||||
.children()
|
.children()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|child| (child.widget_name().to_string(), child))
|
.map(|child| {
|
||||||
|
let label = child
|
||||||
|
.downcast_ref::<Button>()
|
||||||
|
.and_then(|button| button.label())
|
||||||
|
.unwrap_or_else(|| child.widget_name())
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
(label, child)
|
||||||
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
buttons.sort_by(|(label_a, _), (label_b, _a)| {
|
buttons.sort_by(|(label_a, _), (label_b, _a)| {
|
||||||
|
@ -346,6 +354,10 @@ impl Module<gtk::Box> for WorkspacesModule {
|
||||||
let name = name_map.get(&name).unwrap_or(&name);
|
let name = name_map.get(&name).unwrap_or(&name);
|
||||||
btn.set_label(name);
|
btn.set_label(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.sort == SortOrder::Alphanumeric {
|
||||||
|
reorder_workspaces(&container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WorkspaceUpdate::Add(workspace) => {
|
WorkspaceUpdate::Add(workspace) => {
|
||||||
if fav_names.contains(&workspace.name) {
|
if fav_names.contains(&workspace.name) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue