From 7398ed7af203e20108fa7fefbe1890142f2653e8 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 10 Apr 2024 06:52:50 +0300 Subject: [PATCH] Display document h1 at window title, hostname if not found --- src/Box/Tab.php | 20 ++++++++++++++++++++ src/Yoda.php | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Box/Tab.php b/src/Box/Tab.php index 37f2a2d9..75965cba 100644 --- a/src/Box/Tab.php +++ b/src/Box/Tab.php @@ -8,6 +8,8 @@ class Tab { public \GtkBox $box; + public \GtkWindow $window; + public \Yggverse\Yoda\Box\Menu $menu; public \Yggverse\Yoda\Box\Navigation $navigation; public \Yggverse\Yoda\Label\Content $content; @@ -18,8 +20,12 @@ class Tab public object $config; public function __construct( + \GtkWindow $window, string $name = 'boxTab' ) { + // Init window + $this->window = $window; + // Init config $this->config = \Yggverse\Yoda\Model\File::getConfig(); @@ -195,6 +201,20 @@ class Tab $response->getBody() ); + $body = new \Yggverse\Gemini\Gemtext\Body( + $response->getBody() + ); + + if ($h1 = $body->getH1()) + { + $this->window->set_title( + sprintf( + '%s - Yoda', + empty($h1[0]) ? $address->getHost() : $h1[0] + ) + ); + } + $this->tray->label->set_text( sprintf( '%s | %s | %d bytes | %s seconds', diff --git a/src/Yoda.php b/src/Yoda.php index 0975621c..8b92dc33 100644 --- a/src/Yoda.php +++ b/src/Yoda.php @@ -61,7 +61,9 @@ $window->connect( } ); -$tab = new \Yggverse\Yoda\Box\Tab(); +$tab = new \Yggverse\Yoda\Box\Tab( + $window +); $window->add( $tab->box