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 GLib from 'gi://GLib?version=2.0';
import GLib from 'gi://GLib';
import style from './style.scss';

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
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[]) => {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
import { bind, Variable } from 'astal';
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';

View file

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

View file

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

View file

@ -1,7 +1,7 @@
import { bind, timeout } from 'astal';
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();
import { Notification, HasNotifs } from './notification';

View file

@ -1,10 +1,10 @@
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 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();
import { hyprMessage } from '../../lib';
@ -47,33 +47,39 @@ type NotifGestureWrapperProps = Widget.BoxProps & {
@register()
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 slide_in_from: 'Left' | 'Right';
readonly is_popup: boolean;
private timer_object: AstalIO.Time | undefined;
public popup_timer: number;
@property(Number)
declare popup_timer: number;
@signal(Number)
declare timer_update: (popup_timer: number) => void;
public static sliding_in = 0;
public static on_sliding_in: (amount: number) => void;
public dragging: boolean;
@property(Boolean)
declare dragging: boolean;
private async get_hovered(): Promise<boolean> {
try {
const layers = JSON.parse(await hyprMessage('j/layers')) as LayerResult;
const cursorPos = JSON.parse(await hyprMessage('j/cursorpos')) as CursorPos;
const monitor = display?.get_monitor_at_window(this.get_window()!);
const plugName = get_hyprland_monitor(monitor!)?.name;
const win = this.get_window();
if (!win) {
return false;
}
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');
@ -101,14 +107,20 @@ export class NotifGestureWrapper extends Widget.EventBox {
return true;
}
}
}
catch (e) {
console.log(e);
}
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') {
if (!this.sensitive) {
return;
@ -158,50 +170,25 @@ export class NotifGestureWrapper extends Widget.EventBox {
this.popup_timer = popup_timer;
this.is_popup = this.popup_timer !== 0;
this.timer_update(this.popup_timer);
// OnClick
this.connect('button-press-event', () => {
if (!display) {
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grabbing',
));
this.setCursor('grabbing');
});
// OnRelease
this.connect('button-release-event', () => {
if (!display) {
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grab',
));
this.setCursor('grab');
});
// OnHover
this.connect('enter-notify-event', () => {
if (!display) {
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grab',
));
this.setCursor('grab');
});
// OnHoverLost
this.connect('leave-notify-event', () => {
if (!display) {
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grab',
));
this.setCursor('grab');
});
// Handle timeout before sliding away if it is a popup
@ -212,7 +199,7 @@ export class NotifGestureWrapper extends Widget.EventBox {
this.slideAway('Left');
}
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
this.dragging = Math.abs(offset) > SLIDE_MIN_THRESHOLD;
if (!display) {
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grabbing',
));
this.setCursor('grabbing');
})
// On drag end
@ -279,24 +260,13 @@ export class NotifGestureWrapper extends Widget.EventBox {
// If crosses threshold after letting go, slide away
if (Math.abs(offset) > MAX_OFFSET) {
if (offset > 0) {
this.slideAway('Right');
}
else {
this.slideAway('Left');
}
this.slideAway(offset > 0 ? 'Right' : 'Left');
}
else {
self.css = defaultStyle;
this.dragging = false;
if (!display) {
return;
}
this.window.set_cursor(Gdk.Cursor.new_from_name(
display,
'grab',
));
this.setCursor('grab');
}
});

View file

@ -1,12 +1,12 @@
import { App, Gtk, Gdk, Widget } from 'astal/gtk3';
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();
import AstalNotifd from 'gi://AstalNotifd?version=0.1';
import AstalNotifd from 'gi://AstalNotifd';
const Notifications = AstalNotifd.get_default();
import NotifGestureWrapper from './gesture';
@ -115,7 +115,7 @@ export const Notification = ({
slide_in_from={slide_in_from}
setup_notif={(self) => {
if (self.is_popup) {
self.connect('timer-update', () => {
self.connect('notify::popup-timer', () => {
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();
import { NotifGestureWrapper } from './gesture';