From 47cd7660ab4b10236362c74f96f9327945dc5cd5 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Mon, 23 Jun 2025 08:54:27 -0400 Subject: [PATCH] allow Svg's --- components/Svg.tsx | 19 +++++++++++++++++-- widget/Hyprland/workspaces.tsx | 26 +++++++++++--------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/components/Svg.tsx b/components/Svg.tsx index cd5796f..60cc9c6 100644 --- a/components/Svg.tsx +++ b/components/Svg.tsx @@ -1,8 +1,23 @@ +import { Gdk, Gtk } from "astal/gtk4"; +import GLib from "gi://GLib?version=2.0"; +import Rsvg from "gi://Rsvg?version=2.0"; + interface SvgProps { color?: string; + path: string; rotation?: number; + size?: number; } -export function Svg({ color, rotation }: SvgProps) { - const svgPath = ``; +export function Svg({ + color = "#cac9c9", + path, + rotation = 0, + size = 24, +}: SvgProps) { + const svgString = `${path}`; + const bytes = new GLib.Bytes(new TextEncoder().encode(svgString)); + const texture = Gdk.Texture.new_from_bytes(bytes); + + return Gtk.Image.new_from_paintable(texture); } diff --git a/widget/Hyprland/workspaces.tsx b/widget/Hyprland/workspaces.tsx index 6673c55..598d1c4 100644 --- a/widget/Hyprland/workspaces.tsx +++ b/widget/Hyprland/workspaces.tsx @@ -2,6 +2,7 @@ import { bind } from "astal"; import { Gdk, Gtk } from "astal/gtk4"; import Hyprland from "gi://AstalHyprland"; import Rsvg from "gi://Rsvg?version=2.0"; +import { Svg } from "../../components/Svg"; const Workspaces = function () { const hyprland = Hyprland.get_default(); @@ -23,30 +24,25 @@ const Workspaces = function () { workspaces.filter((workspace) => workspace.id < 0), ); - Gtk.Image.interface_install_property; - - const activeTrianglePath = - ''; - const inactiveTrianglePath = - ''; - - const activeTrianglePixBuf = - Rsvg.Handle.new_from_data(activeTrianglePath).get_pixbuf(); - const inactiveTrianglePixBuf = - Rsvg.Handle.new_from_data(inactiveTrianglePath).get_pixbuf(); - return ( {workspaces.as((workspaces) => { return workspaces.map((workspace) => ( ));