diff --git a/src/Entity/Browser/Menu/Tab.php b/src/Entity/Browser/Menu/Tab.php index e1b7d0dd..b0ffd990 100644 --- a/src/Entity/Browser/Menu/Tab.php +++ b/src/Entity/Browser/Menu/Tab.php @@ -6,6 +6,7 @@ namespace Yggverse\Yoda\Entity\Browser\Menu; use \GtkMenu; use \GtkMenuItem; +use \GtkSeparatorMenuItem; use \Yggverse\Yoda\Entity\Browser\Menu; @@ -20,6 +21,7 @@ class Tab // Requirements public Tab\Add $add; public Tab\Close $close; + public Tab\Clean $clean; // Defaults public const LABEL = 'Tab'; @@ -60,6 +62,24 @@ class Tab $tab ); + // Add separator + $tab->append( + new GtkSeparatorMenuItem + ); + + // Init close all tabs menu item + $this->clean = new Tab\Clean( + $this + ); + + $tab->append( + $this->clean->gtk + ); + + $this->gtk->set_submenu( + $tab + ); + // Render $this->gtk->show(); } diff --git a/src/Entity/Browser/Menu/Tab/Clean.php b/src/Entity/Browser/Menu/Tab/Clean.php new file mode 100644 index 00000000..590580c5 --- /dev/null +++ b/src/Entity/Browser/Menu/Tab/Clean.php @@ -0,0 +1,77 @@ +tab = $tab; + + // Init menu item + $this->gtk = \GtkMenuItem::new_with_label( + _($this::LABEL) + ); + + $this->gtk->set_tooltip_text( + _($this::TOOLTIP) + ); + + // Render + $this->gtk->show(); + + // Int events + $this->gtk->connect( + 'activate', + function() + { + $dialog = new GtkMessageDialog( + $this->tab->menu->browser->gtk, + GtkDialogFlags::MODAL, + GtkMessageType::WARNING, + GtkButtonsType::OK_CANCEL, + $this::DIALOG_MESSAGE_FORMAT + ); + + $dialog->format_secondary_text( + $this::DIALOG_FORMAT_SECONDARY_TEXT + ); + + if (GtkResponseType::OK == $dialog->run()) + { + foreach ($this->tab->menu->browser->container->tab->pages as $page_num => $page) + { + $this->tab->menu->browser->container->tab->close( + $page_num + ); + } + } + + $dialog->destroy(); + } + ); + } +} \ No newline at end of file