mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
init window as entity
This commit is contained in:
parent
7b38e00089
commit
183c26e56a
3 changed files with 90 additions and 64 deletions
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Yoda\Tab;
|
namespace Yggverse\Yoda\Entity\Tab;
|
||||||
|
|
||||||
class Page
|
class Page
|
||||||
{
|
{
|
||||||
|
public \Yggverse\Yoda\Entity\Window $window;
|
||||||
|
|
||||||
public \Yggverse\Yoda\Model\Memory $dns;
|
public \Yggverse\Yoda\Model\Memory $dns;
|
||||||
public \Yggverse\Yoda\Model\History $history;
|
public \Yggverse\Yoda\Model\History $history;
|
||||||
|
|
||||||
|
|
@ -29,8 +31,11 @@ class Page
|
||||||
public object $config;
|
public object $config;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
?string $url = null
|
\Yggverse\Yoda\Entity\Window $window
|
||||||
) {
|
) {
|
||||||
|
// Init window
|
||||||
|
$this->window = $window;
|
||||||
|
|
||||||
// Init config
|
// Init config
|
||||||
$this->config = \Yggverse\Yoda\Model\File::getConfig()->window->tab->page;
|
$this->config = \Yggverse\Yoda\Model\File::getConfig()->window->tab->page;
|
||||||
|
|
||||||
|
|
@ -70,10 +75,6 @@ class Page
|
||||||
$this->config->header->button->home->label
|
$this->config->header->button->home->label
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->home->set_sensitive(
|
|
||||||
!($url == $this->config->header->button->home->url)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->home->connect(
|
$this->home->connect(
|
||||||
'released',
|
'released',
|
||||||
function ($entry)
|
function ($entry)
|
||||||
|
|
@ -166,13 +167,6 @@ class Page
|
||||||
// Address field
|
// Address field
|
||||||
$this->address = new \GtkEntry();
|
$this->address = new \GtkEntry();
|
||||||
|
|
||||||
if ($url)
|
|
||||||
{
|
|
||||||
$this->address->set_text(
|
|
||||||
$url
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->address->set_placeholder_text(
|
$this->address->set_placeholder_text(
|
||||||
$this->config->header->address->placeholder
|
$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
|
// Init app
|
||||||
\Gtk::init();
|
\Gtk::init();
|
||||||
|
|
||||||
$config = \Yggverse\Yoda\Model\File::getConfig(); // @TODO
|
new \Yggverse\Yoda\Entity\Window();
|
||||||
|
|
||||||
$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();
|
|
||||||
|
|
||||||
\Gtk::main();
|
\Gtk::main();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue