Browse Source

add filename image support

PHP-GTK3
yggverse 4 months ago
parent
commit
4f6445d167
  1. 28
      src/Abstract/Entity/Button.php

28
src/Abstract/Entity/Button.php

@ -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;
}
} }
} }
Loading…
Cancel
Save