fix(agsV2): update to fixed decorators
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-10-22 13:09:39 -04:00
parent e03d34d75b
commit 3143100da0
19 changed files with 94 additions and 120 deletions

Binary file not shown.

View file

@ -1,6 +1,6 @@
import { App } from 'astal/gtk3'; import { App } from 'astal/gtk3';
import GLib from 'gi://GLib?version=2.0'; import GLib from 'gi://GLib';
import style from './style.scss'; import style from './style.scss';

View file

@ -1,6 +1,6 @@
import { Gdk } from 'astal/gtk3'; import { Gdk } from 'astal/gtk3';
import AstalHyprland from 'gi://AstalHyprland?version=0.1'; import AstalHyprland from 'gi://AstalHyprland';
const Hyprland = AstalHyprland.get_default(); const Hyprland = AstalHyprland.get_default();
/* Types */ /* Types */

View file

@ -2,7 +2,7 @@ import { subprocess } from 'astal';
import { App } from 'astal/gtk3'; import { App } from 'astal/gtk3';
import GObject, { register, signal } from 'astal/gobject'; import GObject, { register, signal } from 'astal/gobject';
import AstalIO from 'gi://AstalIO?version=0.1'; import AstalIO from 'gi://AstalIO';
import { hyprMessage } from '../lib'; import { hyprMessage } from '../lib';

View file

@ -2,7 +2,7 @@ import { App, Gtk, Widget } from 'astal/gtk3';
import { register } from 'astal/gobject'; import { register } from 'astal/gobject';
/* Types */ /* Types */
import AstalApps from 'gi://AstalApps?version=0.1'; import AstalApps from 'gi://AstalApps';
type AppItemProps = Widget.BoxProps & { type AppItemProps = Widget.BoxProps & {
app: AstalApps.Application app: AstalApps.Application
}; };

View file

@ -1,6 +1,6 @@
import { execAsync } from 'astal'; import { execAsync } from 'astal';
import AstalApps from 'gi://AstalApps?version=0.1'; import AstalApps from 'gi://AstalApps';
const bash = async(strings: TemplateStringsArray | string, ...values: unknown[]) => { const bash = async(strings: TemplateStringsArray | string, ...values: unknown[]) => {

View file

@ -1,7 +1,7 @@
import { App, Astal, Gtk, Widget } from 'astal/gtk3'; import { App, Astal, Gtk, Widget } from 'astal/gtk3';
import { idle } from 'astal'; import { idle } from 'astal';
import AstalApps from 'gi://AstalApps?version=0.1'; import AstalApps from 'gi://AstalApps';
import { Fzf, FzfResultItem } from 'fzf'; import { Fzf, FzfResultItem } from 'fzf';

View file

@ -1,7 +1,7 @@
import { App, Astal, Gdk, Gtk, Widget } from 'astal/gtk3'; import { App, Astal, Gdk, Gtk, Widget } from 'astal/gtk3';
import { bind, Variable } from 'astal'; import { bind, Variable } from 'astal';
import AstalHyprland from 'gi://AstalHyprland?version=0.1'; import AstalHyprland from 'gi://AstalHyprland';
const Hyprland = AstalHyprland.get_default(); const Hyprland = AstalHyprland.get_default();
import { get_hyprland_monitor_desc, get_monitor_desc, hyprMessage } from '../../lib'; import { get_hyprland_monitor_desc, get_monitor_desc, hyprMessage } from '../../lib';

View file

@ -1,7 +1,7 @@
import { bind, Variable } from 'astal'; import { bind, Variable } from 'astal';
import { App } from 'astal/gtk3'; import { App } from 'astal/gtk3';
import GLib from 'gi://GLib?version=2.0'; import GLib from 'gi://GLib';
import { PopupWindow } from '../../misc/popup-window'; import { PopupWindow } from '../../misc/popup-window';

View file

@ -1,9 +1,9 @@
import { bind, Variable } from 'astal'; import { bind, Variable } from 'astal';
import AstalApps from 'gi://AstalApps?version=0.1'; import AstalApps from 'gi://AstalApps';
const Applications = AstalApps.Apps.new(); const Applications = AstalApps.Apps.new();
import AstalHyprland from 'gi://AstalHyprland?version=0.1'; import AstalHyprland from 'gi://AstalHyprland';
const Hyprland = AstalHyprland.get_default(); const Hyprland = AstalHyprland.get_default();
import Separator from '../../misc/separator'; import Separator from '../../misc/separator';

View file

@ -1,7 +1,7 @@
import { bind } from 'astal'; import { bind } from 'astal';
import { App } from 'astal/gtk3'; import { App } from 'astal/gtk3';
import AstalNotifd from 'gi://AstalNotifd?version=0.1'; import AstalNotifd from 'gi://AstalNotifd';
const Notifications = AstalNotifd.get_default(); const Notifications = AstalNotifd.get_default();
import Separator from '../../misc/separator'; import Separator from '../../misc/separator';

View file

@ -1,7 +1,7 @@
import { Gtk, Widget } from 'astal/gtk3'; import { Gtk, Widget } from 'astal/gtk3';
import { timeout } from 'astal'; import { timeout } from 'astal';
import AstalHyprland from 'gi://AstalHyprland?version=0.1'; import AstalHyprland from 'gi://AstalHyprland';
const Hyprland = AstalHyprland.get_default(); const Hyprland = AstalHyprland.get_default();
import { hyprMessage } from '../../../lib'; import { hyprMessage } from '../../../lib';

View file

@ -1,7 +1,7 @@
import { bind, Variable } from 'astal'; import { bind, Variable } from 'astal';
import { Astal, Gtk } from 'astal/gtk3'; import { Astal, Gtk } from 'astal/gtk3';
import GLib from 'gi://GLib?version=2.0'; import GLib from 'gi://GLib';
import PopupWindow from '../misc/popup-window'; import PopupWindow from '../misc/popup-window';

View file

@ -3,7 +3,7 @@ import { App, Astal, Gdk, Gtk, Widget } from 'astal/gtk3';
import { register } from 'astal/gobject'; import { register } from 'astal/gobject';
import AstalAuth from 'gi://AstalAuth'; import AstalAuth from 'gi://AstalAuth';
import Lock from 'gi://GtkSessionLock?version=0.1'; import Lock from 'gi://GtkSessionLock';
import Separator from '../misc/separator'; import Separator from '../misc/separator';
import { get_hyprland_monitor_desc } from '../../lib'; import { get_hyprland_monitor_desc } from '../../lib';

View file

@ -1,5 +1,5 @@
import { App, Astal, Gtk, Widget } from 'astal/gtk3'; import { App, Astal, Gtk, Widget } from 'astal/gtk3';
import { register } from 'astal/gobject'; import { property, register } from 'astal/gobject';
import { Binding, idle } from 'astal'; import { Binding, idle } from 'astal';
import { get_hyprland_monitor, hyprMessage } from '../../lib'; import { get_hyprland_monitor, hyprMessage } from '../../lib';
@ -20,8 +20,12 @@ type PopupWindowProps = Widget.WindowProps & {
@register() @register()
export class PopupWindow extends Widget.Window { export class PopupWindow extends Widget.Window {
transition: HyprTransition | Binding<HyprTransition>; @property(String)
close_on_unfocus: CloseType | Binding<CloseType>; declare transition: HyprTransition | Binding<HyprTransition>;
@property(String)
declare close_on_unfocus: CloseType | Binding<CloseType>;
on_open: PopupCallback; on_open: PopupCallback;
on_close: PopupCallback; on_close: PopupCallback;

View file

@ -1,7 +1,7 @@
import { bind, timeout } from 'astal'; import { bind, timeout } from 'astal';
import { App, Gtk, Widget } from 'astal/gtk3'; import { App, Gtk, Widget } from 'astal/gtk3';
import AstalNotifd from 'gi://AstalNotifd?version=0.1'; import AstalNotifd from 'gi://AstalNotifd';
const Notifications = AstalNotifd.get_default(); const Notifications = AstalNotifd.get_default();
import { Notification, HasNotifs } from './notification'; import { Notification, HasNotifs } from './notification';

View file

@ -1,10 +1,10 @@
import { Gdk, Gtk, Widget } from 'astal/gtk3'; import { Gdk, Gtk, Widget } from 'astal/gtk3';
import { register, signal } from 'astal/gobject'; import { property, register } from 'astal/gobject';
import { idle, interval } from 'astal'; import { idle, interval } from 'astal';
import AstalIO from 'gi://AstalIO?version=0.1'; import AstalIO from 'gi://AstalIO';
import AstalNotifd from 'gi://AstalNotifd?version=0.1'; import AstalNotifd from 'gi://AstalNotifd';
const Notifications = AstalNotifd.get_default(); const Notifications = AstalNotifd.get_default();
import { hyprMessage } from '../../lib'; import { hyprMessage } from '../../lib';
@ -47,68 +47,80 @@ type NotifGestureWrapperProps = Widget.BoxProps & {
@register() @register()
export class NotifGestureWrapper extends Widget.EventBox { export class NotifGestureWrapper extends Widget.EventBox {
static popups = new Map<number, NotifGestureWrapper>(); public static popups = new Map<number, NotifGestureWrapper>();
public static sliding_in = 0;
public static on_sliding_in: (amount: number) => void;
readonly id: number; readonly id: number;
readonly slide_in_from: 'Left' | 'Right'; readonly slide_in_from: 'Left' | 'Right';
readonly is_popup: boolean; readonly is_popup: boolean;
private timer_object: AstalIO.Time | undefined; private timer_object: AstalIO.Time | undefined;
public popup_timer: number; @property(Number)
declare popup_timer: number;
@signal(Number) @property(Boolean)
declare timer_update: (popup_timer: number) => void; declare dragging: boolean;
public static sliding_in = 0;
public static on_sliding_in: (amount: number) => void;
public dragging: boolean;
private async get_hovered(): Promise<boolean> { private async get_hovered(): Promise<boolean> {
try { const layers = JSON.parse(await hyprMessage('j/layers')) as LayerResult;
const layers = JSON.parse(await hyprMessage('j/layers')) as LayerResult; const cursorPos = JSON.parse(await hyprMessage('j/cursorpos')) as CursorPos;
const cursorPos = JSON.parse(await hyprMessage('j/cursorpos')) as CursorPos;
const monitor = display?.get_monitor_at_window(this.get_window()!); const win = this.get_window();
const plugName = get_hyprland_monitor(monitor!)?.name;
const notifLayer = layers[plugName ?? '']?.levels['3'] if (!win) {
?.find((n) => n.namespace === 'notifications'); return false;
if (!notifLayer) {
return false;
}
const index = [...NotifGestureWrapper.popups.keys()]
.sort((a, b) => b - a)
.indexOf(this.id);
const popups = [...NotifGestureWrapper.popups.entries()]
.sort((a, b) => b[0] - a[0])
.map(([key, val]) => [key, val.get_allocated_height()]);
const thisY = notifLayer.y + popups
.map((v) => v[1])
.slice(0, index)
.reduce((prev, curr) => prev + curr, 0);
if (cursorPos.y >= thisY && cursorPos.y <= thisY + (popups[index][1] ?? 0)) {
if (cursorPos.x >= notifLayer.x &&
cursorPos.x <= notifLayer.x + notifLayer.w) {
return true;
}
}
} }
catch (e) {
console.log(e); const monitor = display?.get_monitor_at_window(win);
if (!monitor) {
return false;
}
const plugName = get_hyprland_monitor(monitor)?.name;
const notifLayer = layers[plugName ?? '']?.levels['3']
?.find((n) => n.namespace === 'notifications');
if (!notifLayer) {
return false;
}
const index = [...NotifGestureWrapper.popups.keys()]
.sort((a, b) => b - a)
.indexOf(this.id);
const popups = [...NotifGestureWrapper.popups.entries()]
.sort((a, b) => b[0] - a[0])
.map(([key, val]) => [key, val.get_allocated_height()]);
const thisY = notifLayer.y + popups
.map((v) => v[1])
.slice(0, index)
.reduce((prev, curr) => prev + curr, 0);
if (cursorPos.y >= thisY && cursorPos.y <= thisY + (popups[index][1] ?? 0)) {
if (cursorPos.x >= notifLayer.x &&
cursorPos.x <= notifLayer.x + notifLayer.w) {
return true;
}
} }
return false; return false;
} }
private setCursor(cursor: string) {
if (!display) {
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
cursor,
));
}
public slideAway(side: 'Left' | 'Right') { public slideAway(side: 'Left' | 'Right') {
if (!this.sensitive) { if (!this.sensitive) {
return; return;
@ -158,50 +170,25 @@ export class NotifGestureWrapper extends Widget.EventBox {
this.popup_timer = popup_timer; this.popup_timer = popup_timer;
this.is_popup = this.popup_timer !== 0; this.is_popup = this.popup_timer !== 0;
this.timer_update(this.popup_timer);
// OnClick // OnClick
this.connect('button-press-event', () => { this.connect('button-press-event', () => {
if (!display) { this.setCursor('grabbing');
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grabbing',
));
}); });
// OnRelease // OnRelease
this.connect('button-release-event', () => { this.connect('button-release-event', () => {
if (!display) { this.setCursor('grab');
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grab',
));
}); });
// OnHover // OnHover
this.connect('enter-notify-event', () => { this.connect('enter-notify-event', () => {
if (!display) { this.setCursor('grab');
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grab',
));
}); });
// OnHoverLost // OnHoverLost
this.connect('leave-notify-event', () => { this.connect('leave-notify-event', () => {
if (!display) { this.setCursor('grab');
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grab',
));
}); });
// Handle timeout before sliding away if it is a popup // Handle timeout before sliding away if it is a popup
@ -212,7 +199,7 @@ export class NotifGestureWrapper extends Widget.EventBox {
this.slideAway('Left'); this.slideAway('Left');
} }
else { else {
this.timer_update(--this.popup_timer); --this.popup_timer;
} }
} }
}); });
@ -260,13 +247,7 @@ export class NotifGestureWrapper extends Widget.EventBox {
// Put a threshold on if a click is actually dragging // Put a threshold on if a click is actually dragging
this.dragging = Math.abs(offset) > SLIDE_MIN_THRESHOLD; this.dragging = Math.abs(offset) > SLIDE_MIN_THRESHOLD;
if (!display) { this.setCursor('grabbing');
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grabbing',
));
}) })
// On drag end // On drag end
@ -279,24 +260,13 @@ export class NotifGestureWrapper extends Widget.EventBox {
// If crosses threshold after letting go, slide away // If crosses threshold after letting go, slide away
if (Math.abs(offset) > MAX_OFFSET) { if (Math.abs(offset) > MAX_OFFSET) {
if (offset > 0) { this.slideAway(offset > 0 ? 'Right' : 'Left');
this.slideAway('Right');
}
else {
this.slideAway('Left');
}
} }
else { else {
self.css = defaultStyle; self.css = defaultStyle;
this.dragging = false; this.dragging = false;
if (!display) { this.setCursor('grab');
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grab',
));
} }
}); });

View file

@ -1,12 +1,12 @@
import { App, Gtk, Gdk, Widget } from 'astal/gtk3'; import { App, Gtk, Gdk, Widget } from 'astal/gtk3';
import { Variable } from 'astal'; import { Variable } from 'astal';
import GLib from 'gi://GLib?version=2.0'; import GLib from 'gi://GLib';
import AstalApps from 'gi://AstalApps?version=0.1'; import AstalApps from 'gi://AstalApps';
const Applications = AstalApps.Apps.new(); const Applications = AstalApps.Apps.new();
import AstalNotifd from 'gi://AstalNotifd?version=0.1'; import AstalNotifd from 'gi://AstalNotifd';
const Notifications = AstalNotifd.get_default(); const Notifications = AstalNotifd.get_default();
import NotifGestureWrapper from './gesture'; import NotifGestureWrapper from './gesture';
@ -115,7 +115,7 @@ export const Notification = ({
slide_in_from={slide_in_from} slide_in_from={slide_in_from}
setup_notif={(self) => { setup_notif={(self) => {
if (self.is_popup) { if (self.is_popup) {
self.connect('timer-update', () => { self.connect('notify::popup-timer', () => {
progress.fraction = self.popup_timer / 5; progress.fraction = self.popup_timer / 5;
}); });
} }

View file

@ -1,4 +1,4 @@
import AstalNotifd from 'gi://AstalNotifd?version=0.1'; import AstalNotifd from 'gi://AstalNotifd';
const Notifications = AstalNotifd.get_default(); const Notifications = AstalNotifd.get_default();
import { NotifGestureWrapper } from './gesture'; import { NotifGestureWrapper } from './gesture';