draft history tab features

This commit is contained in:
yggverse 2024-04-14 17:32:50 +03:00
parent 5df6332346
commit fa92487489
5 changed files with 46 additions and 13 deletions

View file

@ -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

View file

@ -137,6 +137,8 @@
},
"history":
{
"enabled":true,
"label":"History",
"time":
{
"format":"c"

View file

@ -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();

View file

@ -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
)
]
);
}
}
}

View file

@ -399,6 +399,8 @@ class Page
$this->app->database->addHistory(
$url
);
$this->app->history->refresh();
}
}