mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
throw exception on image icon not found
This commit is contained in:
parent
2ebb870cb9
commit
d76686760b
1 changed files with 11 additions and 6 deletions
|
|
@ -15,9 +15,17 @@ abstract class Button
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
// Init button
|
||||||
$this->gtk = new \GtkButton;
|
$this->gtk = new \GtkButton;
|
||||||
|
|
||||||
if (!$this->setImage($this::IMAGE))
|
if ($this::IMAGE)
|
||||||
|
{
|
||||||
|
$this->setImage(
|
||||||
|
$this::IMAGE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$this->gtk->set_label(
|
$this->gtk->set_label(
|
||||||
_($this::LABEL)
|
_($this::LABEL)
|
||||||
|
|
@ -55,7 +63,7 @@ abstract class Button
|
||||||
public function setImage(
|
public function setImage(
|
||||||
?string $image = null,
|
?string $image = null,
|
||||||
int $size = \GtkIconSize::BUTTON
|
int $size = \GtkIconSize::BUTTON
|
||||||
): bool
|
): void
|
||||||
{
|
{
|
||||||
if (\GtkIconTheme::get_default()->has_icon($image))
|
if (\GtkIconTheme::get_default()->has_icon($image))
|
||||||
{
|
{
|
||||||
|
|
@ -66,9 +74,6 @@ abstract class Button
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
} else throw new \Exception;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue