mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
update page title behaviour
This commit is contained in:
parent
64ae36eecf
commit
a011d5e004
3 changed files with 34 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"app":
|
||||
{
|
||||
"name":"Yoda",
|
||||
"theme":"Default",
|
||||
"database":
|
||||
{
|
||||
|
|
@ -13,11 +14,9 @@
|
|||
"enabled":true,
|
||||
"title":
|
||||
{
|
||||
"default":"Yoda",
|
||||
"postfix":" - Yoda",
|
||||
"length":
|
||||
{
|
||||
"max":32
|
||||
"max":64
|
||||
}
|
||||
},
|
||||
"button":
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class App
|
|||
$this->header = new \GtkHeaderBar;
|
||||
|
||||
$this->header->set_title(
|
||||
$this->config->header->title->default
|
||||
$this->config->name
|
||||
);
|
||||
|
||||
$this->header->set_show_close_button(
|
||||
|
|
@ -121,15 +121,18 @@ class App
|
|||
// Init event listener
|
||||
$this->tabs->connect(
|
||||
'switch-page',
|
||||
function ($tabs, $child, $position)
|
||||
{
|
||||
function (
|
||||
\GtkNotebook $tabs,
|
||||
\GtkWidget $child,
|
||||
int $position
|
||||
) {
|
||||
// Update window title on tab change
|
||||
$this->setTitle(
|
||||
$tabs->get_tab_label_text($child)
|
||||
$tabs->get_tab_label($child)->get_text()
|
||||
);
|
||||
|
||||
// Add new tab event
|
||||
if ('+' == $tabs->get_tab_label_text($child))
|
||||
if ('+' == $tabs->get_tab_label($child)->get_text())
|
||||
{
|
||||
\Gtk::timeout_add(
|
||||
0,
|
||||
|
|
@ -188,15 +191,18 @@ class App
|
|||
{
|
||||
if ($value)
|
||||
{
|
||||
|
||||
/* @TODO
|
||||
$title = urldecode(
|
||||
mb_strlen($value) > $this->config->header->title->length->max ? mb_substr($value, 0, $this->config->header->title->length->max) . '...'
|
||||
: $value
|
||||
);
|
||||
*/ $title = $value;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$title = $this->config->header->title->default;
|
||||
$title = $this->config->name;
|
||||
}
|
||||
|
||||
$this->header->set_title(
|
||||
|
|
|
|||
|
|
@ -637,17 +637,31 @@ class Page
|
|||
$response->getBody()
|
||||
);
|
||||
|
||||
// Try to detect document title
|
||||
if ($h1 = $body->getH1())
|
||||
{
|
||||
$title = reset(
|
||||
$h1
|
||||
) . $this->app->config->header->title->postfix;
|
||||
);
|
||||
}
|
||||
|
||||
else if ($h2 = $body->getH2())
|
||||
{
|
||||
$title = reset(
|
||||
$h2
|
||||
);
|
||||
}
|
||||
|
||||
else if ($h3 = $body->getH3())
|
||||
{
|
||||
$title = reset(
|
||||
$h3
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$title = $origin->getHost() .
|
||||
$this->app->config->header->title->postfix;
|
||||
$title = $origin->getHost();
|
||||
}
|
||||
|
||||
$this->app->setTitle(
|
||||
|
|
@ -759,10 +773,12 @@ class Page
|
|||
{
|
||||
if ($value)
|
||||
{
|
||||
/* @TODO
|
||||
$title = urldecode(
|
||||
mb_strlen($value) > $this->config->title->length->max ? mb_substr($value, 0, $this->config->title->length->max) . '...'
|
||||
: $value
|
||||
: $value
|
||||
);
|
||||
*/ $title = $value;
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue