diff --git a/config.json b/config.json index 19c2af54..55146236 100644 --- a/config.json +++ b/config.json @@ -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": diff --git a/src/Entity/App.php b/src/Entity/App.php index cbcbfd4f..68a38fb3 100644 --- a/src/Entity/App.php +++ b/src/Entity/App.php @@ -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( diff --git a/src/Entity/Tab/Page.php b/src/Entity/Tab/Page.php index fba2a71c..80a6c85e 100644 --- a/src/Entity/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -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