From 313c6b6db5c37373a11a3fcbfa9d848dbe0ceccc Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 17 Apr 2024 10:12:44 +0300 Subject: [PATCH] listen events for visible/enabled elements only --- src/Entity/Tab/Page.php | 134 +++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 71 deletions(-) diff --git a/src/Entity/Tab/Page.php b/src/Entity/Tab/Page.php index e80bcf6..0ff64d9 100644 --- a/src/Entity/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -51,14 +51,6 @@ class Page // Init history $this->history = new \Yggverse\Yoda\Model\History; - // Run database cleaner - if ($this->config->history->database->timeout) - { - $this->app->database->cleanHistory( - $this->config->history->database->timeout - ); - } - // Compose header $this->header = new \GtkBox( \GtkOrientation::HORIZONTAL @@ -84,71 +76,41 @@ class Page $this->config->header->margin ); - // Home button + // Init home button $this->home = \GtkButton::new_with_label( $this->config->header->button->home->label ); - $this->home->connect( - 'clicked', - function ($entry) - { - $this->history->reset(); - - $this->open( - $this->config->header->button->home->url - ); - } - ); - if ($this->config->header->button->home->visible) { + $this->home->connect( + 'clicked', + function ($entry) + { + $this->history->reset(); + + $this->open( + $this->config->header->button->home->url + ); + } + ); + $this->header->add( $this->home ); } - // Back button + // Init back button $this->back = \GtkButton::new_with_label( $this->config->header->button->back->label ); - $this->back->set_sensitive( - false - ); - - $this->back->connect( - 'clicked', - function ($entry) - { - $this->open( - $this->history->goBack(), - false - ); - } - ); - - // Forward button + // Init forward button $this->forward = \GtkButton::new_with_label( $this->config->header->button->forward->label ); - $this->forward->set_sensitive( - false - ); - - $this->forward->connect( - 'clicked', - function ($entry) - { - $this->open( - $this->history->goForward(), - false - ); - } - ); - - /// Group buttons + // Group back/forward buttons if ($this->config->header->button->back->visible || $this->config->header->button->forward->visible) { $buttonGroup = new \GtkButtonBox( @@ -161,6 +123,21 @@ class Page if ($this->config->header->button->back->visible) { + $this->back->set_sensitive( + false + ); + + $this->back->connect( + 'clicked', + function ($entry) + { + $this->open( + $this->history->goBack(), + false + ); + } + ); + $buttonGroup->add( $this->back ); @@ -168,6 +145,21 @@ class Page if ($this->config->header->button->forward->visible) { + $this->forward->set_sensitive( + false + ); + + $this->forward->connect( + 'clicked', + function ($entry) + { + $this->open( + $this->history->goForward(), + false + ); + } + ); + $buttonGroup->add( $this->forward ); @@ -189,6 +181,13 @@ class Page $this->config->header->entry->request->length->max ); + $this->header->pack_start( + $this->request, + true, + true, + 0 + ); + $this->request->connect( 'activate', function ($entry) @@ -199,13 +198,6 @@ class Page } ); - $this->header->pack_start( - $this->request, - true, - true, - 0 - ); - // Init autocomplete if ($this->config->header->entry->request->autocomplete->enabled) { @@ -275,18 +267,18 @@ class Page $this->config->header->button->go->label ); - $this->go->connect( - 'clicked', - function ($entry) - { - $this->open( - $this->request->get_text() - ); - } - ); - if ($this->config->header->button->go->visible) { + $this->go->connect( + 'clicked', + function ($entry) + { + $this->open( + $this->request->get_text() + ); + } + ); + $this->header->add( $this->go );