✨ ags(bar, notifications, control-center): add status icons to bar, notification history fixed, notification history below control-center
This commit is contained in:
+95
-63
@@ -1,12 +1,10 @@
|
||||
import { Variable } from "astal";
|
||||
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
|
||||
import { getAstalApps } from "../scripts/apps";
|
||||
import { cleanExec, getAstalApps } from "../scripts/apps";
|
||||
import AstalApps from "gi://AstalApps";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
|
||||
const { TOP, LEFT, RIGHT, BOTTOM } = Astal.WindowAnchor;
|
||||
const searchString = new Variable<string>("");
|
||||
const appsArray = new Variable<Array<AstalApps.Application>>([]);
|
||||
let searchSubscription: () => void;
|
||||
|
||||
export const AppsWindow = new Widget.Window({
|
||||
@@ -16,64 +14,98 @@ export const AppsWindow = new Widget.Window({
|
||||
anchor: TOP | LEFT | RIGHT | BOTTOM,
|
||||
visible: false,
|
||||
keymode: Astal.Keymode.EXCLUSIVE,
|
||||
onKeyPressEvent: (_, event: Gdk.Event) => {
|
||||
event.get_keyval()[1] === Gdk.KEY_Escape &&
|
||||
hideAppsWindow(_);
|
||||
},
|
||||
setup: () => {
|
||||
searchSubscription = searchString.subscribe((str: string) => {
|
||||
appsArray.set(getAstalApps().fuzzy_query(str));
|
||||
});
|
||||
},
|
||||
child: new Widget.Box({
|
||||
className: "apps-window container",
|
||||
expand: true,
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: [
|
||||
new Widget.Entry({
|
||||
className: "entry",
|
||||
hexpand: true,
|
||||
vexpand: false,
|
||||
onDraw: (_) => _.grab_focus(),
|
||||
onChanged: (entry) => {
|
||||
searchString.set(entry.text);
|
||||
}
|
||||
} as Widget.EntryProps),
|
||||
new Widget.Box({
|
||||
className: "apps",
|
||||
hexpand: true,
|
||||
vexpand: true,
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: appsArray((apps: Array<AstalApps.Application>) =>
|
||||
apps.map((app: AstalApps.Application) =>
|
||||
new Widget.Button({
|
||||
className: "app",
|
||||
onClickRelease: (_) => {
|
||||
_.get_window()?.hide();
|
||||
AstalHyprland.get_default().dispatch("exec", app.get_executable());
|
||||
},
|
||||
child: new Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: [
|
||||
new Widget.Icon({
|
||||
className: "icon",
|
||||
iconName: app.get_icon_name()
|
||||
} as Widget.IconProps),
|
||||
new Widget.Label({
|
||||
className: "name",
|
||||
label: app.get_name()
|
||||
} as Widget.LabelProps)
|
||||
]
|
||||
} as Widget.BoxProps)
|
||||
} as Widget.ButtonProps)
|
||||
)
|
||||
)
|
||||
} as Widget.BoxProps)
|
||||
]
|
||||
} as Widget.BoxProps)
|
||||
} as Widget.WindowProps);
|
||||
onDestroy: () => searchSubscription(),
|
||||
setup: (window) => {
|
||||
const flowbox = new Gtk.FlowBox({
|
||||
rowSpacing: 6,
|
||||
homogeneous: true,
|
||||
columnSpacing: 6,
|
||||
expand: false,
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
visible: true
|
||||
} as Gtk.FlowBox.ConstructorProps);
|
||||
|
||||
function hideAppsWindow(window: Widget.Window) {
|
||||
searchString.set("");
|
||||
window.hide();
|
||||
}
|
||||
const entry = new Widget.Entry({
|
||||
className: "entry",
|
||||
halign: Gtk.Align.CENTER,
|
||||
primary_icon_name: "system-search",
|
||||
onChanged: (entry) => {
|
||||
searchString.set(entry.text);
|
||||
}
|
||||
} as Widget.EntryProps);
|
||||
|
||||
searchSubscription = searchString.subscribe((str: string) => {
|
||||
const results: Array<AstalApps.Application> = getAstalApps().fuzzy_query(str);
|
||||
|
||||
// Destroy is handled by GnomeJS
|
||||
flowbox.get_children().map(flowboxChild => flowbox.remove(flowboxChild));
|
||||
|
||||
results.map(app => {
|
||||
flowbox.insert(new Widget.Button({
|
||||
onClick: (_button, event: Astal.ClickEvent) => {
|
||||
if(event.button === Astal.MouseButton.PRIMARY) {
|
||||
searchString.set("");
|
||||
entry.text = "";
|
||||
window.hide();
|
||||
cleanExec(app);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// select app launch options TODO
|
||||
},
|
||||
child: new Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: [
|
||||
new Widget.Icon({
|
||||
className: "icon",
|
||||
expand: true,
|
||||
icon: app.get_icon_name()
|
||||
} as Widget.IconProps),
|
||||
new Widget.Label({
|
||||
className: "name",
|
||||
truncate: true,
|
||||
label: app.get_name()
|
||||
} as Widget.LabelProps)
|
||||
]
|
||||
} as Widget.BoxProps)
|
||||
} as Widget.ButtonProps), -1);
|
||||
|
||||
const flowboxchild = flowbox.get_children()[flowbox.get_children().length-1];
|
||||
flowboxchild.set_valign(Gtk.Align.START);
|
||||
});
|
||||
|
||||
const firstChild = flowbox.get_child_at_index(0);
|
||||
firstChild && flowbox.select_child(firstChild);
|
||||
});
|
||||
|
||||
window.add(new Widget.EventBox({
|
||||
onClick: () => {
|
||||
searchString.set("");
|
||||
entry.text = "";
|
||||
window.hide();
|
||||
},
|
||||
onKeyPressEvent: (_, event: Gdk.Event) => {
|
||||
if(event.get_keyval()[1] === Gdk.KEY_Escape) {
|
||||
searchString.set("");
|
||||
entry.text = "";
|
||||
window.hide();
|
||||
}
|
||||
},
|
||||
child: new Widget.Box({
|
||||
className: "apps-window-container",
|
||||
expand: true,
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: [
|
||||
entry,
|
||||
new Widget.Scrollable({
|
||||
vscroll: Gtk.PolicyType.AUTOMATIC,
|
||||
hscroll: Gtk.PolicyType.NEVER,
|
||||
expand: true,
|
||||
child: flowbox
|
||||
} as Widget.ScrollableProps)
|
||||
]
|
||||
} as Widget.BoxProps)
|
||||
} as Widget.EventBoxProps));
|
||||
}
|
||||
} as Widget.WindowProps);
|
||||
|
||||
+5
-4
@@ -1,12 +1,12 @@
|
||||
import { Astal, Gtk, Widget } from "astal/gtk3";
|
||||
|
||||
import { Clock } from "../widget/bar/Clock";
|
||||
import { Logo } from "../widget/bar/Logo";
|
||||
import { Tray } from "../widget/bar/Tray";
|
||||
import { Workspaces } from "../widget/bar/Workspaces";
|
||||
import { Audio } from "../widget/bar/Audio";
|
||||
import { FocusedClient } from "../widget/bar/FocusedClient";
|
||||
import { Media } from "../widget/bar/Media";
|
||||
import { Status } from "../widget/bar/Status";
|
||||
import { Apps } from "../widget/bar/Apps";
|
||||
|
||||
export const Bar: Widget.Window = new Widget.Window({
|
||||
monitor: 0,
|
||||
@@ -14,6 +14,7 @@ export const Bar: Widget.Window = new Widget.Window({
|
||||
anchor: Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT,
|
||||
layer: Astal.Layer.TOP,
|
||||
exclusivity: Astal.Exclusivity.EXCLUSIVE,
|
||||
heightRequest: 46,
|
||||
canFocus: false,
|
||||
visible: true,
|
||||
child: new Widget.Box({
|
||||
@@ -27,7 +28,7 @@ export const Bar: Widget.Window = new Widget.Window({
|
||||
homogeneous: false,
|
||||
halign: Gtk.Align.START,
|
||||
children: [
|
||||
Logo(),
|
||||
Apps(),
|
||||
Workspaces(),
|
||||
FocusedClient()
|
||||
]
|
||||
@@ -47,7 +48,7 @@ export const Bar: Widget.Window = new Widget.Window({
|
||||
halign: Gtk.Align.END,
|
||||
children: [
|
||||
Tray(),
|
||||
Audio()
|
||||
Status()
|
||||
]
|
||||
} as Widget.BoxProps)
|
||||
} as Widget.CenterBoxProps)
|
||||
|
||||
+38
-15
@@ -1,35 +1,58 @@
|
||||
import { Gtk, Widget } from "astal/gtk3";
|
||||
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
|
||||
import { QuickActions } from "../widget/control-center/QuickActions";
|
||||
import { Tiles } from "../widget/control-center/Tiles";
|
||||
import { Sliders } from "../widget/control-center/Sliders";
|
||||
import { PopupWindow, PopupWindowProps } from "../widget/PopupWindow";
|
||||
import { hidePages, PagesWidget } from "../widget/control-center/Pages";
|
||||
import { NotifHistory } from "../widget/control-center/NotifHistory";
|
||||
|
||||
const connections: Array<number> = [];
|
||||
const { TOP, LEFT, BOTTOM, RIGHT } = Astal.WindowAnchor;
|
||||
|
||||
export const ControlCenter: Widget.Window = PopupWindow({
|
||||
className: "control-center",
|
||||
export const ControlCenter = new Widget.Window({
|
||||
namespace: "control-center",
|
||||
marginTop: 10,
|
||||
marginRight: 10,
|
||||
monitor: 0,
|
||||
onClose: () => hidePages(),
|
||||
halign: Gtk.Align.END,
|
||||
valign: Gtk.Align.START,
|
||||
className: "control-center",
|
||||
anchor: TOP | BOTTOM | LEFT | RIGHT,
|
||||
exclusivity: Astal.Exclusivity.NORMAL,
|
||||
keymode: Astal.Keymode.EXCLUSIVE,
|
||||
layer: Astal.Layer.OVERLAY,
|
||||
focusOnMap: true,
|
||||
visible: false,
|
||||
vexpand: true,
|
||||
monitor: 0,
|
||||
onDestroy: (_) => connections.map(id => _.disconnect(id)),
|
||||
onButtonPressEvent: (_, event: Gdk.Event) => {
|
||||
const [, posX, posY] = event.get_coords();
|
||||
const childAllocation = _.get_child()!.get_allocation();
|
||||
|
||||
if((posX < childAllocation.x || posX > (childAllocation.x + childAllocation.width)) ||
|
||||
(posY < childAllocation.y || posY > (childAllocation.y + childAllocation.height))) {
|
||||
_.hide();
|
||||
hidePages();
|
||||
}
|
||||
},
|
||||
onKeyPressEvent: (_, event: Gdk.Event) => {
|
||||
if(event.get_keyval()[1] === Gdk.KEY_Escape) {
|
||||
_.hide();
|
||||
hidePages();
|
||||
}
|
||||
},
|
||||
child: new Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
expand: true,
|
||||
className: "popup",
|
||||
halign: Gtk.Align.END,
|
||||
css: `.popup {
|
||||
margin-top: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
}`,
|
||||
vexpand: true,
|
||||
widthRequest: 400,
|
||||
onButtonPressEvent: () => true,
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: [
|
||||
new Widget.Box({
|
||||
className: "control-center-container",
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
widthRequest: 400,
|
||||
vexpand: false,
|
||||
hexpand: true,
|
||||
children: [
|
||||
QuickActions,
|
||||
Sliders,
|
||||
@@ -40,7 +63,7 @@ export const ControlCenter: Widget.Window = PopupWindow({
|
||||
NotifHistory
|
||||
]
|
||||
} as Widget.BoxProps)
|
||||
} as PopupWindowProps);
|
||||
} as Widget.WindowProps);
|
||||
|
||||
connections.push(ControlCenter.connect("hide", (_) => {
|
||||
hidePages();
|
||||
|
||||
Reference in New Issue
Block a user