Browse Source

draft history tab features

main
yggverse 2 months ago
parent
commit
fa92487489
  1. 2
      README.md
  2. 2
      config.json
  3. 22
      src/Entity/App.php
  4. 31
      src/Entity/Tab/History.php
  5. 2
      src/Entity/Tab/Page.php

2
README.md

@ -8,7 +8,7 @@ At this moment project under development! @@ -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

2
config.json

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

22
src/Entity/App.php

@ -8,6 +8,8 @@ class App @@ -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 @@ -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();

31
src/Entity/Tab/History.php

@ -56,18 +56,7 @@ class History @@ -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 @@ -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
)
]
);
}
}
}

2
src/Entity/Tab/Page.php

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

Loading…
Cancel
Save