mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
init window as entity
This commit is contained in:
parent
7b38e00089
commit
183c26e56a
@ -2,10 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yggverse\Yoda\Tab;
|
||||
namespace Yggverse\Yoda\Entity\Tab;
|
||||
|
||||
class Page
|
||||
{
|
||||
public \Yggverse\Yoda\Entity\Window $window;
|
||||
|
||||
public \Yggverse\Yoda\Model\Memory $dns;
|
||||
public \Yggverse\Yoda\Model\History $history;
|
||||
|
||||
@ -29,8 +31,11 @@ class Page
|
||||
public object $config;
|
||||
|
||||
public function __construct(
|
||||
?string $url = null
|
||||
\Yggverse\Yoda\Entity\Window $window
|
||||
) {
|
||||
// Init window
|
||||
$this->window = $window;
|
||||
|
||||
// Init config
|
||||
$this->config = \Yggverse\Yoda\Model\File::getConfig()->window->tab->page;
|
||||
|
||||
@ -70,10 +75,6 @@ class Page
|
||||
$this->config->header->button->home->label
|
||||
);
|
||||
|
||||
$this->home->set_sensitive(
|
||||
!($url == $this->config->header->button->home->url)
|
||||
);
|
||||
|
||||
$this->home->connect(
|
||||
'released',
|
||||
function ($entry)
|
||||
@ -166,13 +167,6 @@ class Page
|
||||
// Address field
|
||||
$this->address = new \GtkEntry();
|
||||
|
||||
if ($url)
|
||||
{
|
||||
$this->address->set_text(
|
||||
$url
|
||||
);
|
||||
}
|
||||
|
||||
$this->address->set_placeholder_text(
|
||||
$this->config->header->address->placeholder
|
||||
);
|
82
src/Entity/Window.php
Normal file
82
src/Entity/Window.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yggverse\Yoda\Entity;
|
||||
|
||||
class Window
|
||||
{
|
||||
public \GtkWindow $window;
|
||||
public \GtkNotebook $tab;
|
||||
|
||||
public object $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = \Yggverse\Yoda\Model\File::getConfig()->window; // @TODO
|
||||
|
||||
$this->window = new \GtkWindow();
|
||||
|
||||
$this->window->set_size_request(
|
||||
$this->config->width,
|
||||
$this->config->height
|
||||
);
|
||||
|
||||
if ($this->config->header->enabled)
|
||||
{
|
||||
$header = new \GtkHeaderBar();
|
||||
|
||||
$header->set_title(
|
||||
$this->config->title
|
||||
);
|
||||
|
||||
$header->set_show_close_button(
|
||||
$this->config->header->button->close
|
||||
);
|
||||
|
||||
$this->window->set_titlebar(
|
||||
$header
|
||||
);
|
||||
}
|
||||
|
||||
$this->window->connect(
|
||||
'destroy',
|
||||
function()
|
||||
{
|
||||
\Gtk::main_quit();
|
||||
}
|
||||
);
|
||||
|
||||
$page = new \Yggverse\Yoda\Entity\Tab\Page(
|
||||
$this
|
||||
);
|
||||
|
||||
$page->open(
|
||||
$this->config->tab->page->header->button->home->url
|
||||
);
|
||||
|
||||
$this->tab = new \GtkNotebook();
|
||||
|
||||
$this->tab->set_scrollable(
|
||||
true
|
||||
);
|
||||
|
||||
$this->tab->append_page(
|
||||
$page->box,
|
||||
new \GtkLabel(
|
||||
'New page' // @TODO
|
||||
)
|
||||
);
|
||||
|
||||
$this->tab->set_tab_reorderable(
|
||||
$page->box,
|
||||
true
|
||||
);
|
||||
|
||||
$this->window->add(
|
||||
$this->tab
|
||||
);
|
||||
|
||||
$this->window->show_all();
|
||||
}
|
||||
}
|
52
src/Yoda.php
52
src/Yoda.php
@ -9,56 +9,6 @@ require_once __DIR__ .
|
||||
// Init app
|
||||
\Gtk::init();
|
||||
|
||||
$config = \Yggverse\Yoda\Model\File::getConfig(); // @TODO
|
||||
|
||||
$window = new \GtkWindow();
|
||||
|
||||
$window->set_size_request(
|
||||
$config->window->width,
|
||||
$config->window->height
|
||||
);
|
||||
|
||||
if ($config->window->header->enabled)
|
||||
{
|
||||
$header = new \GtkHeaderBar();
|
||||
|
||||
$header->set_title(
|
||||
$config->window->title
|
||||
);
|
||||
|
||||
$header->set_show_close_button(
|
||||
$config->window->header->button->close
|
||||
);
|
||||
|
||||
$window->set_titlebar(
|
||||
$header
|
||||
);
|
||||
}
|
||||
|
||||
$window->connect(
|
||||
'destroy',
|
||||
function()
|
||||
{
|
||||
\Gtk::main_quit();
|
||||
}
|
||||
);
|
||||
|
||||
$page = new \Yggverse\Yoda\Tab\Page();
|
||||
|
||||
$page->open(
|
||||
'yoda://welcome'
|
||||
);
|
||||
|
||||
$tab = new \GtkNotebook();
|
||||
|
||||
$tab->add(
|
||||
$page->box
|
||||
);
|
||||
|
||||
$window->add(
|
||||
$tab
|
||||
);
|
||||
|
||||
$window->show_all();
|
||||
new \Yggverse\Yoda\Entity\Window();
|
||||
|
||||
\Gtk::main();
|
Loading…
x
Reference in New Issue
Block a user