Browse Source

add base button

main
yggverse 2 months ago
parent
commit
f874583740
  1. 5
      config.json
  2. 81
      src/Entity/Tab/Page.php

5
config.json

@ -114,6 +114,11 @@
"visible":true, "visible":true,
"label":"Forward" "label":"Forward"
}, },
"base":
{
"visible":true,
"label":"Base"
},
"go": "go":
{ {
"visible":true, "visible":true,

81
src/Entity/Tab/Page.php

@ -19,6 +19,7 @@ class Page
public \GtkButton $home, public \GtkButton $home,
$back, $back,
$forward, $forward,
$base,
$go; $go;
public \GtkEntry $request; public \GtkEntry $request;
@ -170,6 +171,45 @@ class Page
); );
} }
// Init base button
$this->base = \GtkButton::new_with_label(
$this->config->header->button->base->label
);
$this->base->set_sensitive(
false
);
if ($this->config->header->button->base->visible)
{
$this->base->connect(
'clicked',
function (\GtkButton $button)
{
$base = new \Yggverse\Net\Address(
$this->request->get_text()
);
$this->open(
$base->get(
true, // scheme
true, // user
true, // pass
true, // host
true, // port
false, // path
false, // query
false // fragment
)
);
}
);
$this->header->add(
$this->base
);
}
// Request field // Request field
$this->request = new \GtkEntry; $this->request = new \GtkEntry;
@ -449,11 +489,6 @@ class Page
$url $url
); );
// Update request field by requested
$this->request->set_text(
$url
);
// Update history in memory pool // Update history in memory pool
if ($history && $this->config->history->memory->enabled && $url != $this->history->getCurrent()) if ($history && $this->config->history->memory->enabled && $url != $this->history->getCurrent())
{ {
@ -463,19 +498,55 @@ class Page
} }
// Update home button sensibility on match requested // Update home button sensibility on match requested
if ($this->config->header->button->home->visible)
{
$this->home->set_sensitive( $this->home->set_sensitive(
!($url == $this->config->header->button->home->url) !($url == $this->config->header->button->home->url)
); );
}
// Update back button sensibility // Update back button sensibility
if ($this->config->header->button->back->visible)
{
$this->back->set_sensitive( $this->back->set_sensitive(
(bool) $this->history->getBack() (bool) $this->history->getBack()
); );
}
// Update forward button sensibility // Update forward button sensibility
if ($this->config->header->button->forward->visible)
{
$this->forward->set_sensitive( $this->forward->set_sensitive(
(bool) $this->history->getForward() (bool) $this->history->getForward()
); );
}
// Update base button sensibility
if ($this->config->header->button->base->visible)
{
// Update address
$base = new \Yggverse\Net\Address(
$this->request->get_text()
);
$this->base->set_sensitive(
!($url == $base->get(
true, // scheme
true, // user
true, // pass
true, // host
true, // port
false, // path
false, // query
false // fragment
))
);
}
// Update request field by requested
$this->request->set_text(
$url
);
// Open current address // Open current address
switch (true) switch (true)

Loading…
Cancel
Save