Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion ignis/widgets/picture.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ class Picture(Gtk.Picture, BaseWidget):
__gproperties__ = {**BaseWidget.gproperties}

def __init__(
self, content_fit: str = "contain", width: int = -1, height: int = -1, **kwargs
self,
content_fit: str = "contain",
width: int = -1,
height: int = -1,
blur_radius: int = 0,
**kwargs,
):
Gtk.Picture.__init__(self)
self.override_enum("content_fit", Gtk.ContentFit)
Expand All @@ -47,6 +52,7 @@ def __init__(
self._image: str | GdkPixbuf.Pixbuf | None = None
self._width = width
self._height = height
self._blur_radius = blur_radius
self.width_request = width
self.height_request = height

Expand Down Expand Up @@ -92,6 +98,25 @@ def height(self, value: int) -> None:
self.height_request = value
self.__draw(self.image)

@IgnisProperty
def blur_radius(self) -> int:
"""
The blur radius of the image in pixels.
"""
return self._blur_radius

@blur_radius.setter
def blur_radius(self, value: int) -> None:
self._blur_radius = value
self.queue_draw()

def do_snapshot(self, snapshot: Gtk.Snapshot) -> None:
snapshot.push_blur(self._blur_radius)

Gtk.Picture.do_snapshot(self, snapshot)

snapshot.pop()

def __draw(self, image: "str | GdkPixbuf.Pixbuf") -> None:
if isinstance(image, GdkPixbuf.Pixbuf):
self.__set_from_pixbuf(image)
Expand Down