Browse Source

draft reorderPage method

PHP-GTK3
yggverse 2 months ago
parent
commit
6dc10404ce
  1. 51
      src/Entity/Browser/Container/Tab.php

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

@ -85,9 +85,7 @@ class Tab
?\GtkWidget $child, ?\GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->reorderPage( $this->reorderPage();
$page_num
);
} }
); );
} }
@ -180,7 +178,7 @@ class Tab
$this->gtk->remove_page( $this->gtk->remove_page(
$page_num $page_num
); );
/*
// Free memory // Free memory
$this->_page[$page_num] = null; $this->_page[$page_num] = null;
@ -188,20 +186,45 @@ class Tab
unset( unset(
$this->_page[$page_num] $this->_page[$page_num]
); );
*/
// Reorder @TODO // Reorder
$this->reorderPage();
} }
public function reorderPage( public function reorderPage(
int $page_num ?int $page_num = null
): void ): void
{ {
/* @TODO // Reorder all pages
$this->_page = array_splice( if (is_null($page_num))
$this->_page, {
$page_num, // Init new index
0, $_page = [];
// @TODO get $page
); */ foreach ($this->_page as $page)
{
// Get current entity $page_num
$page_num = $this->gtk->page_num(
$page->gtk
);
// Skip deleted
if ($page_num === -1)
{
continue;
}
// Update position
$_page[] = $this->_page[$page_num];
}
// Reorder
$this->_page = $_page;
}
// Reorder by $page_num
else throw new \Exception(
'Reorder by $page_num value not implemented'
);
} }
} }
Loading…
Cancel
Save