diff --git a/README.md b/README.md index f6d7a248..a8694ecc 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ At this moment project under development! * [x] Flexible settings in `config.json`, then UI * [x] Native GTK environment, no custom colors until you change it by `css` * [x] Multi-tabs -* [ ] Navigation history +* [x] Navigation history * [ ] Bookmarks * [ ] Certificate features * [ ] Local snaps to make resources accessible even offline diff --git a/config.json b/config.json index 7a374f1f..83c07625 100644 --- a/config.json +++ b/config.json @@ -137,6 +137,8 @@ }, "history": { + "enabled":true, + "label":"History", "time": { "format":"c" diff --git a/src/Entity/App.php b/src/Entity/App.php index 8ea4ecef..cbcbfd4f 100644 --- a/src/Entity/App.php +++ b/src/Entity/App.php @@ -8,6 +8,8 @@ class App { public \Yggverse\Yoda\Model\Database $database; + public \Yggverse\Yoda\Entity\Tab\History $history; + public \GtkWindow $window; public \GtkHeaderBar $header; public \GtkNotebook $tabs; @@ -82,6 +84,26 @@ class App ) ); + // History features + if ($this->config->tab->history->enabled) + { + $this->history = new \Yggverse\Yoda\Entity\Tab\History( + $this + ); + + $this->tabs->append_page( + $this->history->box, + new \GtkLabel( + $this->config->tab->history->label + ) + ); + + $this->tabs->set_tab_reorderable( + $this->history->box, + true + ); + } + // Append blank page $page = $this->blankPage(); diff --git a/src/Entity/Tab/History.php b/src/Entity/Tab/History.php index 4dcab183..5c4bf926 100644 --- a/src/Entity/Tab/History.php +++ b/src/Entity/Tab/History.php @@ -56,18 +56,7 @@ class History ); // Build history list from database records - foreach ($this->app->database->getHistory() as $record) - { - $this->list->append( - [ - $record->url, - date( - $this->config->time->format, - $record->time - ) - ] - ); - } + $this->refresh(); // Compose page $this->box = new \GtkBox( @@ -87,4 +76,22 @@ class History 0 ); } + + public function refresh(): void + { + $this->list->clear(); + + foreach ($this->app->database->getHistory() as $record) + { + $this->list->append( + [ + $record->url, + date( + $this->config->time->format, + $record->time + ) + ] + ); + } + } } \ No newline at end of file diff --git a/src/Entity/Tab/Page.php b/src/Entity/Tab/Page.php index c625058b..ac84d68c 100644 --- a/src/Entity/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -399,6 +399,8 @@ class Page $this->app->database->addHistory( $url ); + + $this->app->history->refresh(); } }