Browse Source

Display document h1 at window title, hostname if not found

PHP-GTK3
yggverse 7 months ago
parent
commit
7398ed7af2
  1. 20
      src/Box/Tab.php
  2. 4
      src/Yoda.php

20
src/Box/Tab.php

@ -8,6 +8,8 @@ class Tab @@ -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 @@ -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 @@ -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',

4
src/Yoda.php

@ -61,7 +61,9 @@ $window->connect( @@ -61,7 +61,9 @@ $window->connect(
}
);
$tab = new \Yggverse\Yoda\Box\Tab();
$tab = new \Yggverse\Yoda\Box\Tab(
$window
);
$window->add(
$tab->box

Loading…
Cancel
Save