From 4f6445d1677ae38bda58426f5ca43fba3edbd760 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 24 Jul 2024 19:01:56 +0300 Subject: [PATCH] add filename image support --- src/Abstract/Entity/Button.php | 40 +++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/Abstract/Entity/Button.php b/src/Abstract/Entity/Button.php index 3c0b4901..4d7911bc 100644 --- a/src/Abstract/Entity/Button.php +++ b/src/Abstract/Entity/Button.php @@ -65,15 +65,39 @@ abstract class Button int $size = \GtkIconSize::BUTTON ): void { - if (\GtkIconTheme::get_default()->has_icon($image)) + switch (true) { - $this->gtk->set_image( - \GtkImage::new_from_icon_name( - $image, - $size - ) - ); + case file_exists( + $image + ) && is_readable( + $image + ): + + $this->gtk->set_image( + \GtkImage::new_from_file( + $image, + $size + ) + ); + + break; + + case \GtkIconTheme::get_default()->has_icon( + $image + ): - } else throw new \Exception; + $this->gtk->set_image( + \GtkImage::new_from_icon_name( + $image, + $size + ) + ); + + break; + + default: + + throw new \Exception; + } } } \ No newline at end of file