refactor(agsV2): don't make func wrappers around widget class
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
974036aba2
commit
9939ff8c60
16 changed files with 31 additions and 23 deletions
|
@ -4,7 +4,8 @@ import AstalHyprland from 'gi://AstalHyprland';
|
||||||
const Hyprland = AstalHyprland.get_default();
|
const Hyprland = AstalHyprland.get_default();
|
||||||
|
|
||||||
/* Types */
|
/* Types */
|
||||||
import type { PopupWindow } from './widgets/misc/popup-window';
|
import PopupWindow from './widgets/misc/popup-window';
|
||||||
|
|
||||||
export interface Layer {
|
export interface Layer {
|
||||||
address: string
|
address: string
|
||||||
x: number
|
x: number
|
||||||
|
|
|
@ -17,7 +17,7 @@ const ON_CLICK_TRIGGERS = [
|
||||||
];
|
];
|
||||||
|
|
||||||
/* Types */
|
/* Types */
|
||||||
import { PopupWindow } from '../widgets/misc/popup-window';
|
import PopupWindow from '../widgets/misc/popup-window';
|
||||||
import { CursorPos, Layer, LayerResult } from '../lib';
|
import { CursorPos, Layer, LayerResult } from '../lib';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,4 +62,4 @@ export class AppItem extends Widget.Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (props: AppItemProps) => new AppItem(props);
|
export default AppItem;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import AstalApps from 'gi://AstalApps';
|
||||||
import SortedList from '../misc/sorted-list';
|
import SortedList from '../misc/sorted-list';
|
||||||
|
|
||||||
import { launchApp } from './launch';
|
import { launchApp } from './launch';
|
||||||
import AppItemWidget, { AppItem } from './app-item';
|
import AppItem from './app-item';
|
||||||
|
|
||||||
|
|
||||||
export default () => SortedList({
|
export default () => SortedList({
|
||||||
|
@ -13,7 +13,7 @@ export default () => SortedList({
|
||||||
|
|
||||||
create_list: () => AstalApps.Apps.new().get_list(),
|
create_list: () => AstalApps.Apps.new().get_list(),
|
||||||
|
|
||||||
create_row: (app) => AppItemWidget({ app }),
|
create_row: (app) => <AppItem app={app} />,
|
||||||
|
|
||||||
fzf_options: {
|
fzf_options: {
|
||||||
selector: (app) => app.name + app.executable,
|
selector: (app) => app.name + app.executable,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { bind, Variable } from 'astal';
|
||||||
import { App } from 'astal/gtk3';
|
import { App } from 'astal/gtk3';
|
||||||
|
|
||||||
import GLib from 'gi://GLib';
|
import GLib from 'gi://GLib';
|
||||||
import { PopupWindow } from '../../misc/popup-window';
|
import PopupWindow from '../../misc/popup-window';
|
||||||
|
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import Separator from '../../misc/separator';
|
||||||
const SPACING = 4;
|
const SPACING = 4;
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { PopupWindow } from '../../misc/popup-window';
|
import PopupWindow from '../../misc/popup-window';
|
||||||
|
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
|
|
|
@ -94,3 +94,5 @@ export class ClipItem extends Widget.Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default ClipItem;
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default () => SortedList<EntryObject>({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
create_row: (item) => new ClipItem({ item }),
|
create_row: (item) => <ClipItem item={item} />,
|
||||||
|
|
||||||
fzf_options: {
|
fzf_options: {
|
||||||
selector: (item) => item.content,
|
selector: (item) => item.content,
|
||||||
|
|
|
@ -109,4 +109,4 @@ export class PopupWindow extends Widget.Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (props: PopupWindowProps) => new PopupWindow(props);
|
export default PopupWindow;
|
||||||
|
|
|
@ -58,4 +58,4 @@ class SmoothProgress extends Widget.Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (props?: SmoothProgressProps) => new SmoothProgress(props);
|
export default SmoothProgress;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { idle } from 'astal';
|
||||||
|
|
||||||
import { AsyncFzf, FzfOptions, FzfResultItem } from 'fzf';
|
import { AsyncFzf, FzfOptions, FzfResultItem } from 'fzf';
|
||||||
|
|
||||||
import PopupWindow, { PopupWindow as PopupWindowClass } from '../misc/popup-window';
|
import PopupWindow from '../misc/popup-window';
|
||||||
import { centerCursor } from '../../lib';
|
import { centerCursor } from '../../lib';
|
||||||
|
|
||||||
export interface SortedListProps<T> {
|
export interface SortedListProps<T> {
|
||||||
|
@ -29,7 +29,7 @@ export class SortedList<T> {
|
||||||
private item_list: T[] = [];
|
private item_list: T[] = [];
|
||||||
private fzf_results: FzfResultItem<T>[] = [];
|
private fzf_results: FzfResultItem<T>[] = [];
|
||||||
|
|
||||||
readonly window: PopupWindowClass;
|
readonly window: PopupWindow;
|
||||||
private _item_map = new Map<T, Gtk.Widget>();
|
private _item_map = new Map<T, Gtk.Widget>();
|
||||||
|
|
||||||
readonly create_list: () => T[] | Promise<T[]>;
|
readonly create_list: () => T[] | Promise<T[]>;
|
||||||
|
@ -171,7 +171,7 @@ export class SortedList<T> {
|
||||||
</eventbox>
|
</eventbox>
|
||||||
</box>
|
</box>
|
||||||
</PopupWindow>
|
</PopupWindow>
|
||||||
) as PopupWindowClass;
|
) as PopupWindow;
|
||||||
|
|
||||||
this.create_list = create_list;
|
this.create_list = create_list;
|
||||||
this.create_row = create_row;
|
this.create_row = create_row;
|
||||||
|
|
|
@ -5,7 +5,7 @@ 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';
|
||||||
import { NotifGestureWrapper } from './gesture';
|
import NotifGestureWrapper from './gesture';
|
||||||
|
|
||||||
|
|
||||||
const addNotif = (box: Widget.Box, notifObj: AstalNotifd.Notification) => {
|
const addNotif = (box: Widget.Box, notifObj: AstalNotifd.Notification) => {
|
||||||
|
|
|
@ -345,4 +345,4 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (props: NotifGestureWrapperProps) => new NotifGestureWrapper(props);
|
export default NotifGestureWrapper;
|
||||||
|
|
|
@ -91,7 +91,7 @@ export const Notification = ({
|
||||||
id = 0,
|
id = 0,
|
||||||
popup_timer = 0,
|
popup_timer = 0,
|
||||||
slide_in_from = 'Left' as 'Left' | 'Right',
|
slide_in_from = 'Left' as 'Left' | 'Right',
|
||||||
}): ReturnType<typeof NotifGestureWrapper> | undefined => {
|
}): NotifGestureWrapper | undefined => {
|
||||||
const notifObj = Notifications.get_notification(id);
|
const notifObj = Notifications.get_notification(id);
|
||||||
|
|
||||||
if (!notifObj) {
|
if (!notifObj) {
|
||||||
|
@ -201,5 +201,5 @@ export const Notification = ({
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
</NotifGestureWrapper>
|
</NotifGestureWrapper>
|
||||||
) as ReturnType<typeof NotifGestureWrapper>;
|
) as NotifGestureWrapper;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import AstalNotifd from 'gi://AstalNotifd';
|
import AstalNotifd from 'gi://AstalNotifd';
|
||||||
const Notifications = AstalNotifd.get_default();
|
const Notifications = AstalNotifd.get_default();
|
||||||
|
|
||||||
import { NotifGestureWrapper } from './gesture';
|
import NotifGestureWrapper from './gesture';
|
||||||
import { Notification } from './notification';
|
import { Notification } from './notification';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { bind, timeout } from 'astal';
|
||||||
import { register } from 'astal/gobject';
|
import { register } from 'astal/gobject';
|
||||||
import { App, Astal, astalify, Gtk, Widget, type ConstructProps } from 'astal/gtk3';
|
import { App, Astal, astalify, Gtk, Widget, type ConstructProps } from 'astal/gtk3';
|
||||||
|
|
||||||
import AstalWp from "gi://AstalWp"
|
import AstalWp from 'gi://AstalWp';
|
||||||
|
|
||||||
import PopupWindow from '../misc/popup-window';
|
import PopupWindow from '../misc/popup-window';
|
||||||
import Brightness from '../../services/brightness';
|
import Brightness from '../../services/brightness';
|
||||||
|
@ -17,7 +17,8 @@ class ProgressBar extends astalify(Gtk.ProgressBar) {
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
Gtk.ProgressBar.ConstructorProps
|
Gtk.ProgressBar.ConstructorProps
|
||||||
>) {
|
>) {
|
||||||
super(props as any)
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
super(props as any);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +47,16 @@ export default () => {
|
||||||
App.get_window('win-osd')?.set_visible(false);
|
App.get_window('win-osd')?.set_visible(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
globalThis.popup_osd = popup;
|
globalThis.popup_osd = popup;
|
||||||
|
|
||||||
const speaker = AstalWp.get_default()?.audio.default_speaker!;
|
const speaker = AstalWp.get_default()?.audio.default_speaker;
|
||||||
const microphone = AstalWp.get_default()?.audio.default_microphone!;
|
const microphone = AstalWp.get_default()?.audio.default_microphone;
|
||||||
|
|
||||||
|
if (!speaker || !microphone) {
|
||||||
|
throw new Error('Could not find default audio devices.');
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PopupWindow
|
<PopupWindow
|
||||||
|
|
Loading…
Reference in a new issue