init window tabs, init gemtext parser, refactor app sceleton

This commit is contained in:
yggverse 2024-04-11 16:03:31 +03:00
parent 196b30e8d2
commit ad04be61cb
19 changed files with 664 additions and 884 deletions

View file

@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Box;
class Menu
{
public \GtkBox $box;
public \Yggverse\Yoda\Entity\Menu\Bar\Main $main;
public function __construct(
string $name = 'boxMenu'
) {
$this->box = new \GtkBox(
\GtkOrientation::VERTICAL
);
$this->box->set_name(
$name
);
$this->main = new \Yggverse\Yoda\Entity\Menu\Bar\Main();
$this->box->add(
$this->main->bar
);
}
}

View file

@ -1,123 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Box;
class Navigation
{
public \GtkBox $box;
public \Yggverse\Yoda\Entity\Entry\Address $address;
public \Yggverse\Yoda\Entity\Button\Home $home;
public \Yggverse\Yoda\Entity\Button\Back $back;
public \Yggverse\Yoda\Entity\Button\Forward $forward;
public \Yggverse\Yoda\Entity\Button\Reload $reload;
public \Yggverse\Yoda\Entity\Button\Go $go;
public object $config;
public function __construct(
string $name = 'boxNavigation'
) {
$this->config = \Yggverse\Yoda\Model\File::getConfig();
$this->box = new \GtkBox(
\GtkOrientation::HORIZONTAL
);
$this->box->set_name(
$name
);
if ($this->config->interface->window->navigation->button->home && $this->config->homepage)
{
$this->home = new \Yggverse\Yoda\Entity\Button\Home();
$this->box->pack_start(
$this->home->button,
false,
false,
8
);
}
if ($this->config->interface->window->navigation->button->back || $this->config->interface->window->navigation->button->forward)
{
$boxBackForward = new \GtkButtonBox(
\GtkOrientation::HORIZONTAL
);
$boxBackForward->set_layout(
\GtkButtonBoxStyle::EXPAND
);
if ($this->config->interface->window->navigation->button->back)
{
$this->back = new \Yggverse\Yoda\Entity\Button\Back();
$boxBackForward->pack_start(
$this->back->button,
false,
true,
0
);
}
if ($this->config->interface->window->navigation->button->forward)
{
$this->forward = new \Yggverse\Yoda\Entity\Button\Forward();
$boxBackForward->pack_end(
$this->forward->button,
false,
true,
0
);
}
$this->box->pack_start(
$boxBackForward,
false,
false,
8
);
}
if ($this->config->interface->window->navigation->button->reload)
{
$this->reload = new \Yggverse\Yoda\Entity\Button\Reload();
$this->box->pack_start(
$this->reload->button,
false,
false,
8
);
}
$this->address = new \Yggverse\Yoda\Entity\Entry\Address(
$this->config->homepage
);
$this->box->pack_start(
$this->address->entry,
true,
true,
8
);
if ($this->config->interface->window->navigation->button->go)
{
$this->go = new \Yggverse\Yoda\Entity\Button\Go();
$this->box->pack_end(
$this->go->button,
false,
false,
8
);
}
}
}

View file

@ -1,71 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Box;
class Tab
{
public \GtkBox $box;
public \Yggverse\Yoda\Entity\Box\Menu $menu;
public \Yggverse\Yoda\Entity\Box\Navigation $navigation;
public \Yggverse\Yoda\Entity\Label\Content $content;
public \Yggverse\Yoda\Entity\Label\Tray $tray;
public function __construct(
string $name = 'boxTab'
) {
// Init container
$this->box = new \GtkBox(
\GtkOrientation::VERTICAL
);
$this->box->set_name(
$name
);
// Init dependencies
$this->menu = new \Yggverse\Yoda\Entity\Box\Menu();
$this->box->pack_start(
$this->menu->box,
false,
true,
0
);
$this->navigation = new \Yggverse\Yoda\Entity\Box\Navigation();
$this->box->pack_start(
$this->navigation->box,
false,
true,
8
);
$this->content = new \Yggverse\Yoda\Entity\Label\Content();
$scroll = new \GtkScrolledWindow();
$scroll->add(
$this->content->label
);
$this->box->pack_start(
$scroll,
true,
true,
0
);
$this->tray = new \Yggverse\Yoda\Entity\Label\Tray();
$this->box->pack_start(
$this->tray->label,
false,
true,
0
);
}
}

View file

@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Button;
class Back
{
public \GtkButton $button;
public function __construct(
?string $label = 'Back'
) {
$this->button = \GtkButton::new_with_label(
$label
);
}
}

View file

@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Button;
class Forward
{
public \GtkButton $button;
public function __construct(
?string $label = 'Forward'
) {
$this->button = \GtkButton::new_with_label(
$label
);
}
}

View file

@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Button;
class Go
{
public \GtkButton $button;
public function __construct(
?string $label = 'Go'
) {
$this->button = \GtkButton::new_with_label(
$label
);
}
}

View file

@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Button;
class Home
{
public \GtkButton $button;
public function __construct(
?string $label = 'Home'
) {
$this->button = \GtkButton::new_with_label(
$label
);
}
}

View file

@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Button;
class Reload
{
public \GtkButton $button;
public function __construct(
?string $label = 'Reload'
) {
$this->button = \GtkButton::new_with_label(
$label
);
}
}

View file

@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Entry;
class Address
{
public \GtkEntry $entry;
public function __construct(
?string $text = null,
?string $placeholder = 'URL or any search term...'
) {
$this->entry = new \GtkEntry();
$this->entry->set_text(
$text
);
$this->entry->set_placeholder_text(
$placeholder
);
$this->entry->set_max_length(
1024
);
}
}

View file

@ -1,37 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Label;
class Content
{
public \GtkLabel $label;
public function __construct(string $value = '')
{
$this->label = new \GtkLabel(
$value
);
$this->label->set_use_markup(
true
);
$this->label->set_selectable(
true
);
$this->label->set_line_wrap(
true
);
$this->label->set_xalign(
0
);
$this->label->set_yalign(
0
);
}
}

View file

@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Label;
class Tray
{
public \GtkLabel $label;
public function __construct(string $value = '')
{
$this->label = new \GtkLabel(
$value
);
$this->label->set_use_markup(
true
);
$this->label->set_selectable(
false
);
$this->label->set_xalign(
0
);
$this->label->set_yalign(
0
);
}
}

View file

@ -1,23 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Menu\Bar;
class Main
{
public \GtkMenuBar $bar;
public \Yggverse\Yoda\Entity\Menu\Item\Yoda $yoda;
public function __construct()
{
$this->bar = new \GtkMenuBar();
$this->yoda = new \Yggverse\Yoda\Entity\Menu\Item\Yoda();
$this->bar->append(
$this->yoda->item
);
}
}

View file

@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Menu\Item;
class Quit
{
public \GtkMenuItem $item;
public function __construct(string $label = 'Quit')
{
$this->item = \GtkMenuItem::new_with_label(
$label
);
$this->activate();
}
public function activate(): void
{
$this->item->connect(
'activate',
function ()
{
\Gtk::main_quit();
}
);
}
}

View file

@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Menu\Item;
class Yoda
{
public \GtkMenuItem $item;
public function __construct(string $label = 'Yoda')
{
$this->item = \GtkMenuItem::new_with_label(
$label
);
$children = new \GtkMenu();
$quit = new \Yggverse\Yoda\Entity\Menu\Item\Quit();
$children->append(
$quit->item
);
$this->item->set_submenu(
$children
);
}
}