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 @@ -65,8 +65,27 @@ abstract class Button
int $size = \GtkIconSize::BUTTON
): 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(
\GtkImage::new_from_icon_name(
$image,
@ -74,6 +93,11 @@ abstract class Button @@ -74,6 +93,11 @@ abstract class Button
)
);
} else throw new \Exception;
break;
default:
throw new \Exception;
}
}
}
Loading…
Cancel
Save