From c2bc925b70f5278878c227f5445cc826337fcf19 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 12 Apr 2024 07:37:52 +0300 Subject: [PATCH] update application namespaces, update window title on page change --- config.json | 2 +- src/Entity/{Window.php => App.php} | 11 +++++++++-- src/Entity/Tab/Page.php | 29 +++++++++++++++-------------- src/Yoda.php | 2 +- 4 files changed, 26 insertions(+), 18 deletions(-) rename src/Entity/{Window.php => App.php} (90%) diff --git a/config.json b/config.json index 514ec100..0c9fc4c0 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "window": + "app": { "title":"Yoda", "theme":"Default", diff --git a/src/Entity/Window.php b/src/Entity/App.php similarity index 90% rename from src/Entity/Window.php rename to src/Entity/App.php index 8e0f7561..84e24134 100644 --- a/src/Entity/Window.php +++ b/src/Entity/App.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity; -class Window +class App { public \GtkWindow $window; public \GtkNotebook $tab; @@ -13,7 +13,7 @@ class Window public function __construct() { - $this->config = \Yggverse\Yoda\Model\File::getConfig()->window; // @TODO + $this->config = \Yggverse\Yoda\Model\File::getConfig()->app; // @TODO $this->window = new \GtkWindow(); @@ -68,6 +68,13 @@ class Window ) ); + $this->tab->set_menu_label( + $page->box, + new \GtkLabel( + '2' // @TODO + ) + ); + $this->tab->set_tab_reorderable( $page->box, true diff --git a/src/Entity/Tab/Page.php b/src/Entity/Tab/Page.php index 94bcdf5f..fbc6cdcb 100644 --- a/src/Entity/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -6,9 +6,9 @@ namespace Yggverse\Yoda\Entity\Tab; class Page { - public \Yggverse\Yoda\Entity\Window $window; + public \Yggverse\Yoda\Entity\App $app; - public \Yggverse\Yoda\Model\Memory $dns; + public \Yggverse\Yoda\Model\Memory $dns; public \Yggverse\Yoda\Model\History $history; public \GtkBox $box, @@ -31,13 +31,13 @@ class Page public object $config; public function __construct( - \Yggverse\Yoda\Entity\Window $window + \Yggverse\Yoda\Entity\App $app ) { - // Init window - $this->window = $window; + // Init app + $this->app = $app; // Init config - $this->config = \Yggverse\Yoda\Model\File::getConfig()->window->tab->page; + $this->config = \Yggverse\Yoda\Model\File::getConfig()->app->tab->page; // Init DNS memory $this->dns = new \Yggverse\Yoda\Model\Memory(); @@ -423,21 +423,22 @@ class Page ) ); - /* @TODO $body = new \Yggverse\Gemini\Gemtext\Body( $response->getBody() ); if ($h1 = $body->getH1()) { - $this->window->set_title( + $this->app->window->set_title( sprintf( - '%s - Yoda', - empty($h1[0]) ? $address->getHost() : $h1[0] + '%s - %s', + empty($h1[0]) ? $address->getHost() : $h1[0], + $this->app->config->title ) ); + + // @TODO update tab title } - */ $this->status->set_text( str_replace( // Custom macros mask from config.json @@ -487,18 +488,18 @@ class Page ); // Parse gemtext - /* @TODO $body = new \Yggverse\Gemini\Gemtext\Body( $data ); if ($h1 = $body->getH1()) { - $this->window->set_title( + $this->app->window->set_title( $h1[0] ); + + // @TODO update tab title } - */ } private function _gemtext( diff --git a/src/Yoda.php b/src/Yoda.php index 2be8f845..b43fb766 100644 --- a/src/Yoda.php +++ b/src/Yoda.php @@ -9,6 +9,6 @@ require_once __DIR__ . // Init app \Gtk::init(); -new \Yggverse\Yoda\Entity\Window(); +new \Yggverse\Yoda\Entity\App(); \Gtk::main(); \ No newline at end of file