import { execAsync } from 'astal'; import { register } from 'astal/gobject'; import { Gtk, Widget } from 'astal/gtk3'; export interface EntryObject { id: number content: string entry: string } const SCALE = 150; const BINARY_DATA = /\[\[ binary data (\d+) (KiB|MiB) (\w+) (\d+)x(\d+) \]\]/; export const CLIP_SCRIPT = `${SRC}/widgets/clipboard/cliphist.sh`; @register() export class ClipItem extends Widget.Box { declare id: number; declare content: string; public show_image(file: string, width: string | number, height: string | number) { this.children[2].destroy(); const initCss = () => { const _widthPx = Number(width); const heightPx = Number(height); const maxWidth = 400; const widthPx = (_widthPx / heightPx) * SCALE; let css = `background-image: url("${file}");`; if (widthPx > maxWidth) { const newHeightPx = (SCALE / widthPx) * maxWidth; css += `min-height: ${newHeightPx}px; min-width: ${maxWidth}px;`; } else { css += `min-height: 150px; min-width: ${widthPx}px;`; } return css; }; const icon = ( ); this.children = [...this.children, icon]; }; constructor({ item }: { item: EntryObject }) { super({ children: [