Browse Source

fix page entity operations

PHP-GTK3
yggverse 4 months ago
parent
commit
f65458ca70
  1. 35
      src/Entity/Browser/Container/Tab.php
  2. 4
      src/Entity/Browser/Menu/Tab/Close.php

35
src/Entity/Browser/Container/Tab.php

@ -75,8 +75,8 @@ class Tab
?\GtkWidget $child, ?\GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->closePage( $this->reorderPage(
$page_num null // all
); );
} }
); );
@ -88,7 +88,9 @@ class Tab
?\GtkWidget $child, ?\GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->reorderPage(); $this->reorderPage(
null // all
);
} }
); );
} }
@ -168,30 +170,17 @@ class Tab
} }
public function closePage( public function closePage(
int $page_num ?int $page_num = null
): void ): void
{ {
// Validate page index exists if ($page = $this->getPage($page_num))
if (empty($this->_page[$page_num]))
{ {
throw new \Exception; $this->gtk->remove_page(
$this->gtk->page_num(
$page->gtk
)
);
} }
// Remove GTK node
$this->gtk->remove_page(
$page_num
);
/*
// Free memory
$this->_page[$page_num] = null;
// Cleanup internal record
unset(
$this->_page[$page_num]
);
*/
// Reorder
$this->reorderPage();
} }
public function reorderPage( public function reorderPage(

4
src/Entity/Browser/Menu/Tab/Close.php

@ -34,10 +34,8 @@ class Close
function() function()
{ {
$this->tab->menu->browser->container->tab->closePage( $this->tab->menu->browser->container->tab->closePage(
$this->tab->menu->browser->container->tab->gtk->get_current_page() null // active
); );
// @TODO unset page entity
} }
); );
} }

Loading…
Cancel
Save