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, ?\GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->reorderPage( $this->reorder();
null // all
);
} }
); );
@ -89,9 +87,7 @@ class Tab
?\GtkWidget $child, ?\GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->reorderPage( $this->reorder();
null // all
);
} }
); );
@ -102,9 +98,21 @@ class Tab
?\GtkWidget $child, ?\GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->reorderPage( $this->reorder();
null // all }
); );
$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]; return $this->_page[$page_num];
} }
public function closePage( public function close(
?int $page_num = null ?int $page_num = null
): void ): void
{ {
@ -196,16 +204,14 @@ class Tab
$page->gtk $page->gtk
) )
); );
$this->reorder();
} }
} }
public function reorderPage( public function reorder(
?int $page_num = null,
bool $session = true bool $session = true
): void ): void
{
// Reorder all pages
if (is_null($page_num))
{ {
// Init new index // Init new index
$_page = []; $_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 public function updateSession(): void
{ {
$pid = pcntl_fork(); $pid = pcntl_fork();

View file

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