Browse Source

init tabs feature

PHP-GTK3
yggverse 8 months ago
parent
commit
2fe9de0163
  1. 2
      README.md
  2. 82
      src/Entity/App.php

2
README.md

@ -7,7 +7,7 @@ At this moment project under development!
* [x] Custom DNS resolver with memory cache, oriented to alt networks like [Yggdrasil](https://github.com/yggdrasil-network/yggdrasil-go) * [x] Custom DNS resolver with memory cache, oriented to alt networks like [Yggdrasil](https://github.com/yggdrasil-network/yggdrasil-go)
* [x] Flexible settings in `config.json`, then UI * [x] Flexible settings in `config.json`, then UI
* [x] Native GTK environment, no custom colors until you change it in `css` * [x] Native GTK environment, no custom colors until you change it in `css`
* [ ] Page tabs * [x] Page tabs
* [ ] Local pages history snaps to make it accessible even offline * [ ] Local pages history snaps to make it accessible even offline
* [ ] Bookmarks * [ ] Bookmarks
* [ ] Certificate features * [ ] Certificate features

82
src/Entity/App.php

@ -14,9 +14,11 @@ class App
public function __construct() public function __construct()
{ {
// Init config
$this->config = \Yggverse\Yoda\Model\File::getConfig()->app; // @TODO $this->config = \Yggverse\Yoda\Model\File::getConfig()->app; // @TODO
$this->window = new \GtkWindow(); // Init window
$this->window = new \GtkWindow;
$this->window->set_size_request( $this->window->set_size_request(
$this->config->width, $this->config->width,
@ -25,7 +27,7 @@ class App
if ($this->config->header->enabled) if ($this->config->header->enabled)
{ {
$this->header = new \GtkHeaderBar(); $this->header = new \GtkHeaderBar;
$this->header->set_title( $this->header->set_title(
$this->config->header->title->default $this->config->header->title->default
@ -40,34 +42,72 @@ class App
); );
} }
$this->window->connect( // Init tabs
'destroy', $this->tabs = new \GtkNotebook;
function()
{ $this->tabs->set_scrollable(
\Gtk::main_quit(); true
}
); );
$this->tabs = new \GtkNotebook(); // + button
$blank = new \GtkLabel;
$this->tabs->set_scrollable( $this->tabs->append_page(
$blank,
new \GtkLabel(
'+'
)
);
$this->tabs->set_tab_reorderable(
$blank,
true true
); );
// Append blank page
$page = $this->blankPage();
$page->open(
$this->config->tab->page->header->button->home->url // @TODO
);
// Render
$this->window->add( $this->window->add(
$this->tabs $this->tabs
); );
$this->openPage( $this->window->show_all();
$this->config->tab->page->header->button->home->url // @TODO
// Init event listener
$this->tabs->connect(
'switch-page',
function ($tabs, $child, $position)
{
if ('+' == $tabs->get_tab_label_text($child))
{
$page = $this->blankPage();
$this->tabs->show_all();
$this->tabs->set_current_page(
$this->tabs->page_num(
$page->box
)
);
}
}
); );
$this->window->show_all(); $this->window->connect(
'destroy',
function()
{
\Gtk::main_quit();
}
);
} }
public function openPage( public function blankPage(): \Yggverse\Yoda\Entity\Tab\Page
string $url
): void
{ {
$page = new \Yggverse\Yoda\Entity\Tab\Page( $page = new \Yggverse\Yoda\Entity\Tab\Page(
$this $this
@ -85,9 +125,15 @@ class App
true true
); );
$page->open( $this->tabs->show_all();
$url
$this->tabs->set_current_page(
$this->tabs->page_num(
$page->box
)
); );
return $page;
} }
public function setTitle( public function setTitle(

Loading…
Cancel
Save