add filename image support

This commit is contained in:
yggverse 2024-07-24 19:01:56 +03:00
parent 80766fb62c
commit 4f6445d167

View file

@ -65,8 +65,27 @@ abstract class Button
int $size = \GtkIconSize::BUTTON int $size = \GtkIconSize::BUTTON
): void ): void
{ {
if (\GtkIconTheme::get_default()->has_icon($image)) switch (true)
{ {
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
):
$this->gtk->set_image( $this->gtk->set_image(
\GtkImage::new_from_icon_name( \GtkImage::new_from_icon_name(
$image, $image,
@ -74,6 +93,11 @@ abstract class Button
) )
); );
} else throw new \Exception; break;
default:
throw new \Exception;
}
} }
} }