diff --git a/config.json b/config.json index 0c950b08..7a374f1f 100644 --- a/config.json +++ b/config.json @@ -134,6 +134,13 @@ } } } + }, + "history": + { + "time": + { + "format":"c" + } } } } diff --git a/src/Entity/Tab/History.php b/src/Entity/Tab/History.php index 3f80969a..4dcab183 100644 --- a/src/Entity/Tab/History.php +++ b/src/Entity/Tab/History.php @@ -8,6 +8,11 @@ class History { public \Yggverse\Yoda\Entity\App $app; + public \GtkBox $box; + public \GtkListStore $list; + public \GtkTreeView $treeview; + public \GtkScrolledWindow $container; + public object $config; public function __construct( @@ -17,6 +22,69 @@ class History $this->app = $app; // Init config - $this->config = \Yggverse\Yoda\Model\File::getConfig()->app->tab->page; + $this->config = \Yggverse\Yoda\Model\File::getConfig()->app->tab->history; + + // Build history list + $this->treeview = new \GtkTreeView(); + + $this->treeview->append_column( + new \GtkTreeViewColumn( + 'URL', + new \GtkCellRendererText(), + 'text', + 0 + ) + ); + + $this->treeview->append_column( + new \GtkTreeViewColumn( + 'Time', + new \GtkCellRendererText(), + 'text', + 1 + ) + ); + + // Create list storage + $this->list = new \GtkListStore( + \GObject::TYPE_STRING, + \GObject::TYPE_STRING + ); + + $this->treeview->set_model( + $this->list + ); + + // 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 + ) + ] + ); + } + + // Compose page + $this->box = new \GtkBox( + \GtkOrientation::VERTICAL + ); + + $this->container = new \GtkScrolledWindow(); + + $this->container->add( + $this->treeview + ); + + $this->box->pack_start( + $this->container, + true, + true, + 0 + ); } } \ No newline at end of file