mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
init abstract window controller
This commit is contained in:
parent
78a2fa16c9
commit
75806cd295
3 changed files with 83 additions and 74 deletions
70
src/Abstract/Window.php
Normal file
70
src/Abstract/Window.php
Normal 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
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue