refactor: astal widget type
There is no base type, but the return type of astalify works
This commit is contained in:
parent
af927d12a3
commit
0274360617
3 changed files with 9 additions and 4 deletions
|
|
@ -4,6 +4,7 @@ import Updates from "@/services/updates";
|
|||
import { getAppCategoryIcon } from "@/utils/icons";
|
||||
import { ellipsize } from "@/utils/strings";
|
||||
import { bindCurrentTime, osIcon } from "@/utils/system";
|
||||
import type { AstalWidget } from "@/utils/types";
|
||||
import { setupCustomTooltip } from "@/utils/widgets";
|
||||
import type PopupWindow from "@/widgets/popupwindow";
|
||||
import { execAsync, register, Variable } from "astal";
|
||||
|
|
@ -20,7 +21,7 @@ import AstalWp01 from "gi://AstalWp";
|
|||
const hyprland = AstalHyprland.get_default();
|
||||
|
||||
const hookFocusedClientProp = (
|
||||
self: any, // Ugh why is there no base Widget type
|
||||
self: AstalWidget,
|
||||
prop: keyof AstalHyprland.Client,
|
||||
callback: (c: AstalHyprland.Client | null) => void
|
||||
) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import type { astalify } from "astal/gtk3";
|
||||
import type AstalHyprland from "gi://AstalHyprland";
|
||||
|
||||
export type AstalWidget = InstanceType<ReturnType<typeof astalify>>;
|
||||
|
||||
export type Address = `0x${string}`;
|
||||
|
||||
export interface Client {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { Binding, register } from "astal";
|
||||
import { Astal, astalify, Gtk, Widget, type ConstructProps } from "astal/gtk3";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import type { AstalWidget } from "./types";
|
||||
|
||||
export const setupCustomTooltip = (self: any, text: string | Binding<string>) => {
|
||||
export const setupCustomTooltip = (self: AstalWidget, text: string | Binding<string>) => {
|
||||
if (!text) return null;
|
||||
|
||||
const window = new Widget.Window({
|
||||
|
|
@ -27,7 +28,7 @@ export const setupCustomTooltip = (self: any, text: string | Binding<string>) =>
|
|||
|
||||
window.marginLeft = marginLeft;
|
||||
});
|
||||
if (text instanceof Binding) self.hook(text, (_: any, v: string) => !v && window.hide());
|
||||
if (text instanceof Binding) self.hook(text, (_, v) => !v && window.hide());
|
||||
|
||||
self.connect("query-tooltip", () => {
|
||||
if (text instanceof Binding && !text.get()) return false;
|
||||
|
|
@ -54,7 +55,7 @@ export const setupCustomTooltip = (self: any, text: string | Binding<string>) =>
|
|||
return window;
|
||||
};
|
||||
|
||||
export const setupChildClickthrough = (self: any) =>
|
||||
export const setupChildClickthrough = (self: AstalWidget) =>
|
||||
self.connect("size-allocate", () => self.get_window()?.set_child_input_shapes());
|
||||
|
||||
@register()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue