Browse Source

implement history tab constructor

PHP-GTK3
yggverse 6 months ago
parent
commit
5df6332346
  1. 7
      config.json
  2. 70
      src/Entity/Tab/History.php

7
config.json

@ -134,6 +134,13 @@ @@ -134,6 +134,13 @@
}
}
}
},
"history":
{
"time":
{
"format":"c"
}
}
}
}

70
src/Entity/Tab/History.php

@ -8,6 +8,11 @@ class History @@ -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 @@ -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
);
}
}
Loading…
Cancel
Save