Browse Source

update application namespaces, update window title on page change

main
yggverse 3 months ago
parent
commit
c2bc925b70
  1. 2
      config.json
  2. 11
      src/Entity/App.php
  3. 29
      src/Entity/Tab/Page.php
  4. 2
      src/Yoda.php

2
config.json

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
{
"window":
"app":
{
"title":"Yoda",
"theme":"Default",

11
src/Entity/Window.php → src/Entity/App.php

@ -4,7 +4,7 @@ declare(strict_types=1); @@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity;
class Window
class App
{
public \GtkWindow $window;
public \GtkNotebook $tab;
@ -13,7 +13,7 @@ class Window @@ -13,7 +13,7 @@ class Window
public function __construct()
{
$this->config = \Yggverse\Yoda\Model\File::getConfig()->window; // @TODO
$this->config = \Yggverse\Yoda\Model\File::getConfig()->app; // @TODO
$this->window = new \GtkWindow();
@ -68,6 +68,13 @@ class Window @@ -68,6 +68,13 @@ class Window
)
);
$this->tab->set_menu_label(
$page->box,
new \GtkLabel(
'2' // @TODO
)
);
$this->tab->set_tab_reorderable(
$page->box,
true

29
src/Entity/Tab/Page.php

@ -6,9 +6,9 @@ namespace Yggverse\Yoda\Entity\Tab; @@ -6,9 +6,9 @@ namespace Yggverse\Yoda\Entity\Tab;
class Page
{
public \Yggverse\Yoda\Entity\Window $window;
public \Yggverse\Yoda\Entity\App $app;
public \Yggverse\Yoda\Model\Memory $dns;
public \Yggverse\Yoda\Model\Memory $dns;
public \Yggverse\Yoda\Model\History $history;
public \GtkBox $box,
@ -31,13 +31,13 @@ class Page @@ -31,13 +31,13 @@ class Page
public object $config;
public function __construct(
\Yggverse\Yoda\Entity\Window $window
\Yggverse\Yoda\Entity\App $app
) {
// Init window
$this->window = $window;
// Init app
$this->app = $app;
// Init config
$this->config = \Yggverse\Yoda\Model\File::getConfig()->window->tab->page;
$this->config = \Yggverse\Yoda\Model\File::getConfig()->app->tab->page;
// Init DNS memory
$this->dns = new \Yggverse\Yoda\Model\Memory();
@ -423,21 +423,22 @@ class Page @@ -423,21 +423,22 @@ class Page
)
);
/* @TODO
$body = new \Yggverse\Gemini\Gemtext\Body(
$response->getBody()
);
if ($h1 = $body->getH1())
{
$this->window->set_title(
$this->app->window->set_title(
sprintf(
'%s - Yoda',
empty($h1[0]) ? $address->getHost() : $h1[0]
'%s - %s',
empty($h1[0]) ? $address->getHost() : $h1[0],
$this->app->config->title
)
);
// @TODO update tab title
}
*/
$this->status->set_text(
str_replace( // Custom macros mask from config.json
@ -487,18 +488,18 @@ class Page @@ -487,18 +488,18 @@ class Page
);
// Parse gemtext
/* @TODO
$body = new \Yggverse\Gemini\Gemtext\Body(
$data
);
if ($h1 = $body->getH1())
{
$this->window->set_title(
$this->app->window->set_title(
$h1[0]
);
// @TODO update tab title
}
*/
}
private function _gemtext(

2
src/Yoda.php

@ -9,6 +9,6 @@ require_once __DIR__ . @@ -9,6 +9,6 @@ require_once __DIR__ .
// Init app
\Gtk::init();
new \Yggverse\Yoda\Entity\Window();
new \Yggverse\Yoda\Entity\App();
\Gtk::main();
Loading…
Cancel
Save