feat(widgets): add base64 property to image widget.#1434
Open
OddSuvius wants to merge 1 commit into
Open
Conversation
Allows users to bypass disk I/O by passing Base64 encoded image strings directly to the image widget via a new `:base64` property. Decodes natively using GLib and loads into a GTK MemoryInputStream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added a new
:base64property to the(image)widget. This allows users to pass Base64-encoded image data directly to Eww, completely bypassing the need to write and read temporary image files to/from disk.Under the hood, it decodes the string natively using
glib::base64_decodeand pipes the raw bytes into a GTKMemoryInputStreamto be consumed efficiently bygdk_pixbuf::Pixbuf::from_stream_at_scale. It also includes graceful error handling if an invalid string is passed.Usage
You can pass a Base64-encoded image string directly into the
imagewidget.Additional Notes
My use case:
I was building a fast DWM ipc integration and needed a better way to handle app icons. Instead of the usual annoying route of doing slow .desktop file lookups or writing temporary images to the hard drive from memory I just pass the raw
_NET_WM_ICONARGB pixel data from the X11 server encoded to Base64 straight into Eww. This skips disk I/O.Other Potential Use Cases:
/tmp/current_album.pngfile.etc...
Checklist
docs/content/maindirectory has been adjusted to reflect my changes.cargo fmtto automatically format all code before committing