close tab on double click

This commit is contained in:
yggverse 2024-07-19 20:21:04 +03:00
parent fb2f135e0d
commit 9cc75a8fcf
2 changed files with 49 additions and 51 deletions

View file

@ -76,9 +76,7 @@ class Tab
?\GtkWidget $child,
int $page_num
) {
$this->reorderPage(
null // all
);
$this->reorder();
}
);
@ -89,9 +87,7 @@ class Tab
?\GtkWidget $child,
int $page_num
) {
$this->reorderPage(
null // all
);
$this->reorder();
}
);
@ -102,9 +98,21 @@ class Tab
?\GtkWidget $child,
int $page_num
) {
$this->reorderPage(
null // all
$this->reorder();
}
);
$this->gtk->connect(
'button-press-event',
function (
?\GtkNotebook $self,
?\GdkEvent $event
) {
// Close tab on double click
if ($event->type == 5) // @TODO PHP-GTK3 Gdk.EventType.DOUBLE_BUTTON_PRESS
{
$this->close();
}
}
);
}
@ -185,7 +193,7 @@ class Tab
return $this->_page[$page_num];
}
public function closePage(
public function close(
?int $page_num = null
): void
{
@ -196,16 +204,14 @@ class Tab
$page->gtk
)
);
$this->reorder();
}
}
public function reorderPage(
?int $page_num = null,
public function reorder(
bool $session = true
): void
{
// Reorder all pages
if (is_null($page_num))
{
// Init new index
$_page = [];
@ -244,12 +250,6 @@ class Tab
}
}
// Reorder by $page_num
else throw new \Exception(
'Reorder by $page_num value not implemented'
);
}
public function updateSession(): void
{
$pid = pcntl_fork();

View file

@ -33,9 +33,7 @@ class Close
'activate',
function()
{
$this->tab->menu->browser->container->tab->closePage(
null // active
);
$this->tab->menu->browser->container->tab->close();
}
);
}