✨ ags(workspaces, style): use eventbox instead of button, better styling
This commit is contained in:
@@ -12,29 +12,31 @@ export const SpecialWorkspaces: (() => Gtk.Widget) = () => new Widget.EventBox({
|
||||
spacing: 4,
|
||||
children: bind(AstalHyprland.get_default(), "workspaces").as((workspaces) =>
|
||||
workspaces.filter(ws => ws.id < 0).sort((a, b) => a.id - b.id).map((workspace) =>
|
||||
new Widget.Button({
|
||||
new Widget.EventBox({
|
||||
className: bind(AstalHyprland.get_default(), "focusedWorkspace").as(focusWs =>
|
||||
`${focusWs.id === workspace.id ? "focus" : ""}`),
|
||||
tooltipText: bind(workspace, "name").as((name) => {
|
||||
name = name.replace(/^special\:/, "");
|
||||
return name.charAt(0).toUpperCase().concat(name.substring(1, name.length));
|
||||
}),
|
||||
child: new Widget.Icon({
|
||||
className: "last-app-icon",
|
||||
visible: Variable.derive([
|
||||
bind(workspace, "lastClient"),
|
||||
bind(AstalHyprland.get_default(), "focusedWorkspace")
|
||||
], (lastClient, focusedWorkspace) => focusedWorkspace?.id === workspace.id ?
|
||||
false : Boolean(lastClient))(),
|
||||
icon: bind(workspace, "lastClient").as((lastClient) =>
|
||||
lastClient ?
|
||||
getAppIcon(lastClient.initialClass) || "image-missing"
|
||||
: "image-missing")
|
||||
} as Widget.IconProps),
|
||||
onClicked: () => AstalHyprland.get_default().dispatch(
|
||||
child: new Widget.Box({
|
||||
child: new Widget.Icon({
|
||||
className: "last-app-icon",
|
||||
visible: Variable.derive([
|
||||
bind(workspace, "lastClient"),
|
||||
bind(AstalHyprland.get_default(), "focusedWorkspace")
|
||||
], (lastClient, focusedWorkspace) => focusedWorkspace?.id === workspace.id ?
|
||||
false : Boolean(lastClient))(),
|
||||
icon: bind(workspace, "lastClient").as((lastClient) =>
|
||||
lastClient ?
|
||||
getAppIcon(lastClient.initialClass) || "image-missing"
|
||||
: "image-missing")
|
||||
} as Widget.IconProps)
|
||||
} as Widget.BoxProps),
|
||||
onClickRelease: () => AstalHyprland.get_default().dispatch(
|
||||
"togglespecialworkspace", workspace.name.replace(/^special\:/, "")
|
||||
)
|
||||
} as Widget.ButtonProps)
|
||||
} as Widget.EventBoxProps)
|
||||
)
|
||||
)
|
||||
} as Widget.BoxProps)
|
||||
|
||||
@@ -23,23 +23,24 @@ export function Workspaces(): Gtk.Widget {
|
||||
(a: AstalHyprland.Workspace, b: AstalHyprland.Workspace) => a.get_id() - b.get_id());
|
||||
|
||||
return sortedWorkspaces.map((workspace: AstalHyprland.Workspace) =>
|
||||
new Widget.Button({
|
||||
new Widget.EventBox({
|
||||
className: Variable.derive([
|
||||
bind(hyprland, "focusedWorkspace"),
|
||||
showWorkspaceNumbers()
|
||||
], (focusedWs, showWsNumbers) =>
|
||||
`${focusedWs.id === workspace.id ? "focus" : ""} ${showWsNumbers ? "show" : ""}`
|
||||
)(),
|
||||
visible: true,
|
||||
onClickRelease: () => workspace.focus(),
|
||||
tooltipText: Variable.derive([
|
||||
bind(workspace, "lastClient"),
|
||||
bind(hyprland, "focusedWorkspace")
|
||||
],(lastClient, focusWs) => focusWs.id === workspace.id ? "" :
|
||||
], (lastClient, focusWs) => focusWs.id === workspace.id ? "" :
|
||||
`Workspace ${workspace.id}${ lastClient ? ` - ${
|
||||
!lastClient.title.toLowerCase().includes(lastClient.class) ?
|
||||
`${lastClient.get_class()}: `
|
||||
: ""
|
||||
} ${lastClient.title}` : "" }`)(),
|
||||
!lastClient.title.toLowerCase().includes(lastClient.class) ?
|
||||
`${lastClient.get_class()}: `
|
||||
: ""
|
||||
} ${lastClient.title}` : "" }`
|
||||
)(),
|
||||
child: new Widget.Box({
|
||||
children: bind(workspace, "lastClient").as((lastClient) => [
|
||||
new Widget.Revealer({
|
||||
@@ -49,8 +50,7 @@ export function Workspaces(): Gtk.Widget {
|
||||
child: new Widget.Label({
|
||||
label: bind(workspace, "id").as(String),
|
||||
className: "id",
|
||||
xalign: 0.5,
|
||||
hexpand: true,
|
||||
hexpand: true
|
||||
} as Widget.LabelProps)
|
||||
} as Widget.RevealerProps),
|
||||
new Widget.Icon({
|
||||
@@ -65,9 +65,8 @@ export function Workspaces(): Gtk.Widget {
|
||||
: undefined
|
||||
} as Widget.IconProps)
|
||||
])
|
||||
} as Widget.BoxProps),
|
||||
onClicked: () => workspace.focus()
|
||||
} as Widget.ButtonProps)
|
||||
} as Widget.BoxProps)
|
||||
} as Widget.EventBoxProps)
|
||||
)
|
||||
})
|
||||
} as Widget.BoxProps)
|
||||
|
||||
Reference in New Issue
Block a user