mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
add base button
This commit is contained in:
parent
bb42afd2ce
commit
f874583740
2 changed files with 89 additions and 13 deletions
|
|
@ -114,6 +114,11 @@
|
|||
"visible":true,
|
||||
"label":"Forward"
|
||||
},
|
||||
"base":
|
||||
{
|
||||
"visible":true,
|
||||
"label":"Base"
|
||||
},
|
||||
"go":
|
||||
{
|
||||
"visible":true,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class Page
|
|||
public \GtkButton $home,
|
||||
$back,
|
||||
$forward,
|
||||
$base,
|
||||
$go;
|
||||
|
||||
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
|
||||
$this->request = new \GtkEntry;
|
||||
|
||||
|
|
@ -449,11 +489,6 @@ class Page
|
|||
$url
|
||||
);
|
||||
|
||||
// Update request field by requested
|
||||
$this->request->set_text(
|
||||
$url
|
||||
);
|
||||
|
||||
// Update history in memory pool
|
||||
if ($history && $this->config->history->memory->enabled && $url != $this->history->getCurrent())
|
||||
{
|
||||
|
|
@ -463,18 +498,54 @@ class Page
|
|||
}
|
||||
|
||||
// Update home button sensibility on match requested
|
||||
$this->home->set_sensitive(
|
||||
!($url == $this->config->header->button->home->url)
|
||||
);
|
||||
if ($this->config->header->button->home->visible)
|
||||
{
|
||||
$this->home->set_sensitive(
|
||||
!($url == $this->config->header->button->home->url)
|
||||
);
|
||||
}
|
||||
|
||||
// Update back button sensibility
|
||||
$this->back->set_sensitive(
|
||||
(bool) $this->history->getBack()
|
||||
);
|
||||
if ($this->config->header->button->back->visible)
|
||||
{
|
||||
$this->back->set_sensitive(
|
||||
(bool) $this->history->getBack()
|
||||
);
|
||||
}
|
||||
|
||||
// Update forward button sensibility
|
||||
$this->forward->set_sensitive(
|
||||
(bool) $this->history->getForward()
|
||||
if ($this->config->header->button->forward->visible)
|
||||
{
|
||||
$this->forward->set_sensitive(
|
||||
(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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue