use const for default values, use namespace

This commit is contained in:
yggverse 2024-07-21 19:35:41 +03:00
parent 8a622ec335
commit c985cf20af
20 changed files with 157 additions and 130 deletions

View file

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \Yggverse\Yoda\Entity\Browser\Menu;
use \Yggverse\Yoda\Entity\Browser\Menu\File\Open;
use \Yggverse\Yoda\Entity\Browser\Menu\File\Save;
@ -12,20 +14,20 @@ class File
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu $menu;
public Menu $menu;
// Defaults
private string $_label = 'File';
public const LABEL = 'File';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu $menu
Menu $menu
) {
// Init dependencies
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
$this::LABEL
);
// Init submenu container

View file

@ -4,32 +4,33 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu\File;
use \Yggverse\Yoda\Entity\Browser\Menu\File;
class Open
{
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu\File $file;
public File $file;
// Defaults
private string $_label = 'Open';
private bool $_multiple = true;
private array $_pattern =
[
public const LABEL = 'Open';
public const MULTIPLE = true;
public const PATTERN = [
// pattern:name
'*' => 'All',
'*.gmi' => null
];
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu\File $file
File $file
) {
// Init dependencies
$this->file = $file;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
$this::LABEL
);
// Render
@ -60,10 +61,10 @@ class Open
}
$dialog->set_select_multiple(
$this->_multiple
$this::MULTIPLE
);
foreach ($this->_pattern as $pattern => $name)
foreach ($this::PATTERN as $pattern => $name)
{
$filter = new \GtkFileFilter;

View file

@ -4,25 +4,27 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu\File;
use \Yggverse\Yoda\Entity\Browser\Menu\File;
class Save
{
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu\File $file;
public File $file;
// Defaults
private string $_label = 'Save As..';
public const LABEL = 'Save As..';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu\File $file
File $file
) {
// Init dependencies
$this->file = $file;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
$this::LABEL
);
// Render

View file

@ -4,25 +4,27 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \Yggverse\Yoda\Entity\Browser\Menu;
class History
{
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu $menu;
public Menu $menu;
// Defaults
private string $_label = 'History';
public const LABEL = 'History';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu $menu
Menu $menu
) {
// Init dependencies
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
$this::LABEL
);
// Render

View file

@ -4,25 +4,27 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \Yggverse\Yoda\Entity\Browser\Menu;
class Quit
{
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu $menu;
public Menu $menu;
// Defaults
private string $_label = 'Quit';
public const LABEL = 'Quit';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu $menu
Menu $menu
) {
// Init dependencies
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
$this::LABEL
);
// Render

View file

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \Yggverse\Yoda\Entity\Browser\Menu;
use \Yggverse\Yoda\Entity\Browser\Menu\Tab\Add;
use \Yggverse\Yoda\Entity\Browser\Menu\Tab\Close;
@ -12,24 +14,24 @@ class Tab
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu $menu;
public Menu $menu;
// Requirements
public \Yggverse\Yoda\Entity\Browser\Menu\Tab\Add $add;
public \Yggverse\Yoda\Entity\Browser\Menu\Tab\Close $close;
public Add $add;
public Close $close;
// Defaults
private string $_label = 'Tab';
public const LABEL = 'Tab';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu $menu
Menu $menu
) {
// Init dependencies
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
$this::LABEL
);
// Init submenu container

View file

@ -14,8 +14,8 @@ class Add
public Tab $tab;
// Defaults
private string $_label = 'Add';
private string $_tooltip = 'New tab';
public const LABEL = 'Add';
public const TOOLTIP = 'New tab';
public function __construct(
Tab $tab
@ -25,11 +25,11 @@ class Add
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
_($this->_label)
_($this::LABEL)
);
$this->gtk->set_tooltip_text(
_($this->_tooltip)
_($this::TOOLTIP)
);
// Render

View file

@ -14,8 +14,8 @@ class Close
public Tab $tab;
// Defaults
private string $_label = 'Close';
private string $_tooltip = 'Close active tab (double click on tab)';
public const LABEL = 'Close';
public const TOOLTIP = 'Close active tab (double click on tab)';
public function __construct(
Tab $tab
@ -25,11 +25,11 @@ class Close
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
_($this->_label)
_($this::LABEL)
);
$this->gtk->set_tooltip_text(
_($this->_tooltip)
_($this::TOOLTIP)
);
// Render