init abstract window controller

This commit is contained in:
yggverse 2024-04-10 08:58:16 +03:00
parent 78a2fa16c9
commit 75806cd295
3 changed files with 83 additions and 74 deletions

70
src/Abstract/Window.php Normal file
View file

@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Abstract;
abstract class Window
{
public \GtkWindow $window;
public \GtkCssProvider $css;
public \GtkStyleContext $style;
public object $config;
public function __construct(
object $config
) {
$this->config = $config;
$this->window = new \GtkWindow();
$this->window->set_size_request(
$this->config->interface->window->width,
$this->config->interface->window->height
);
if ($this->config->interface->window->header->enabled)
{
$header = new \GtkHeaderBar();
$header->set_show_close_button(
$this->config->interface->window->header->button->close
);
$this->window->set_titlebar(
$header
);
}
$this->window->set_title(
'Yoda'
);
$this->window->connect(
'destroy',
function()
{
\Gtk::main_quit();
}
);
}
public function setTheme(
string $css
): void
{
$this->css = new \GtkCssProvider();
$this->css->load_from_data(
$css
);
$this->style = new \GtkStyleContext();
$this->style->add_provider_for_screen(
$this->css,
600
);
}
}