mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,22 +4,17 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Yoda\Controller;
|
namespace Yggverse\Yoda\Controller;
|
||||||
|
|
||||||
class Tab
|
class Browser extends \Yggverse\Yoda\Abstract\Window
|
||||||
{
|
{
|
||||||
public \GtkWindow $window;
|
|
||||||
|
|
||||||
public \Yggverse\Yoda\Entity\Box\Tab $tab;
|
public \Yggverse\Yoda\Entity\Box\Tab $tab;
|
||||||
|
|
||||||
public \Yggverse\Yoda\Model\Memory $memory;
|
public \Yggverse\Yoda\Model\Memory $memory;
|
||||||
|
|
||||||
public object $config;
|
public function __construct()
|
||||||
|
{
|
||||||
public function __construct(
|
parent::__construct(
|
||||||
\GtkWindow $window
|
\Yggverse\Yoda\Model\File::getConfig()
|
||||||
) {
|
);
|
||||||
$this->window = $window;
|
|
||||||
|
|
||||||
$this->config = \Yggverse\Yoda\Model\File::getConfig();
|
|
||||||
|
|
||||||
$this->memory = new \Yggverse\Yoda\Model\Memory();
|
$this->memory = new \Yggverse\Yoda\Model\Memory();
|
||||||
|
|
||||||
|
|
@ -72,7 +67,11 @@ class Tab
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO back, forward buttons
|
$this->window->add(
|
||||||
|
$this->tab->box
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->window->show_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function navigate(string $url)
|
public function navigate(string $url)
|
||||||
64
src/Yoda.php
64
src/Yoda.php
|
|
@ -6,69 +6,9 @@ require_once __DIR__ .
|
||||||
DIRECTORY_SEPARATOR . 'vendor' .
|
DIRECTORY_SEPARATOR . 'vendor' .
|
||||||
DIRECTORY_SEPARATOR . 'autoload.php';
|
DIRECTORY_SEPARATOR . 'autoload.php';
|
||||||
|
|
||||||
// Init config
|
// Init app
|
||||||
$config = \Yggverse\Yoda\Model\File::getConfig();
|
|
||||||
|
|
||||||
// Init GTK
|
|
||||||
\Gtk::init();
|
\Gtk::init();
|
||||||
|
|
||||||
// Init theme
|
new \Yggverse\Yoda\Controller\Browser();
|
||||||
$css = new \GtkCssProvider();
|
|
||||||
|
|
||||||
$css->load_from_data(
|
|
||||||
\Yggverse\Yoda\Model\File::getTheme(
|
|
||||||
$config->interface->theme
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$style = new \GtkStyleContext();
|
|
||||||
|
|
||||||
$style->add_provider_for_screen(
|
|
||||||
$css,
|
|
||||||
600
|
|
||||||
);
|
|
||||||
|
|
||||||
// Init app window
|
|
||||||
$window = new \GtkWindow();
|
|
||||||
|
|
||||||
$window->set_size_request(
|
|
||||||
$config->interface->window->width,
|
|
||||||
$config->interface->window->height
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($config->interface->window->header->enabled)
|
|
||||||
{
|
|
||||||
$header = new \GtkHeaderBar();
|
|
||||||
|
|
||||||
$header->set_show_close_button(
|
|
||||||
$config->interface->window->header->button->close
|
|
||||||
);
|
|
||||||
|
|
||||||
$window->set_titlebar(
|
|
||||||
$header
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$window->set_title(
|
|
||||||
'Yoda'
|
|
||||||
);
|
|
||||||
|
|
||||||
$window->connect(
|
|
||||||
'destroy',
|
|
||||||
function()
|
|
||||||
{
|
|
||||||
\Gtk::main_quit();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$controller = new \Yggverse\Yoda\Controller\Tab(
|
|
||||||
$window
|
|
||||||
);
|
|
||||||
|
|
||||||
$window->add(
|
|
||||||
$controller->tab->box
|
|
||||||
);
|
|
||||||
|
|
||||||
$window->show_all();
|
|
||||||
|
|
||||||
\Gtk::main();
|
\Gtk::main();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue