From 183c26e56a82e77bcb27a22d7556dea562a93008 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 11 Apr 2024 22:48:33 +0300 Subject: [PATCH] init window as entity --- src/{ => Entity}/Tab/Page.php | 20 +++------ src/Entity/Window.php | 82 +++++++++++++++++++++++++++++++++++ src/Yoda.php | 52 +--------------------- 3 files changed, 90 insertions(+), 64 deletions(-) rename src/{ => Entity}/Tab/Page.php (97%) create mode 100644 src/Entity/Window.php diff --git a/src/Tab/Page.php b/src/Entity/Tab/Page.php similarity index 97% rename from src/Tab/Page.php rename to src/Entity/Tab/Page.php index b6b8700..94bcdf5 100644 --- a/src/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -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 ); diff --git a/src/Entity/Window.php b/src/Entity/Window.php new file mode 100644 index 0000000..8e0f756 --- /dev/null +++ b/src/Entity/Window.php @@ -0,0 +1,82 @@ +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(); + } +} \ No newline at end of file diff --git a/src/Yoda.php b/src/Yoda.php index 1c24ded..2be8f84 100644 --- a/src/Yoda.php +++ b/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(); \ No newline at end of file