save session on browser close only

This commit is contained in:
yggverse 2024-07-26 13:34:24 +03:00
parent 196b55e072
commit 48198668fd
4 changed files with 38 additions and 79 deletions

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity;
use \Gtk;
use \GtkWindow;
use \Yggverse\Yoda\Entity\Browser\Header;
@ -78,5 +79,31 @@ class Browser
// @TODO render data wordwrap by $window->get_size()
}
);
$this->gtk->connect(
'destroy',
function()
{
// Save session
$pid = pcntl_fork();
if ($pid === 0)
{
$this->database->cleanSession();
foreach ($this->container->tab->pages as $page)
{
$this->database->addSession(
$page->navbar->request->getValue()
);
}
exit;
}
// Exit application
Gtk::main_quit();
}
);
}
}