Browse Source

update application namespaces, update window title on page change

PHP-GTK3
yggverse 7 months ago
parent
commit
c2bc925b70
  1. 2
      config.json
  2. 11
      src/Entity/App.php
  3. 27
      src/Entity/Tab/Page.php
  4. 2
      src/Yoda.php

2
config.json

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

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

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

27
src/Entity/Tab/Page.php

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

2
src/Yoda.php

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