Browse Source

define dependencies ns

PHP-GTK3
yggverse 4 months ago
parent
commit
14ee41e735
  1. 11
      src/Entity/Browser.php
  2. 10
      src/Entity/Browser/Container.php
  3. 7
      src/Entity/Browser/Header.php
  4. 5
      src/Entity/Browser/History.php
  5. 10
      src/Entity/Browser/History/Container.php
  6. 7
      src/Entity/Browser/History/Container/Content.php
  7. 20
      src/Entity/Browser/History/Container/Content/Table.php
  8. 15
      src/Entity/Browser/History/Container/Content/Table/Data.php
  9. 7
      src/Entity/Browser/History/Container/Content/Viewport.php
  10. 9
      src/Entity/Browser/History/Container/Navbar.php
  11. 4
      src/Entity/Browser/History/Container/Navbar/Delete.php
  12. 15
      src/Entity/Browser/History/Container/Navbar/Filter.php
  13. 4
      src/Entity/Browser/History/Container/Navbar/Open.php
  14. 6
      src/Entity/Browser/History/Header.php
  15. 9
      src/Entity/Browser/Menu.php
  16. 10
      src/Entity/Browser/Menu/File.php
  17. 23
      src/Entity/Browser/Menu/File/Open.php
  18. 20
      src/Entity/Browser/Menu/File/Save.php
  19. 11
      src/Entity/Browser/Menu/History.php
  20. 10
      src/Entity/Browser/Menu/Quit.php
  21. 10
      src/Entity/Browser/Menu/Tab.php
  22. 7
      src/Entity/Browser/Menu/Tab/Add.php

11
src/Entity/Browser.php

@ -4,6 +4,8 @@ declare(strict_types=1); @@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity;
use \GtkWindow;
use \Yggverse\Yoda\Entity\Browser\Header;
use \Yggverse\Yoda\Entity\Browser\Container;
@ -11,7 +13,8 @@ use \Yggverse\Yoda\Model\Database; @@ -11,7 +13,8 @@ use \Yggverse\Yoda\Model\Database;
class Browser
{
public \GtkWindow $gtk;
// GTK
public GtkWindow $gtk;
// Dependencies
public Database $database;
@ -32,7 +35,7 @@ class Browser @@ -32,7 +35,7 @@ class Browser
$this->database = $database;
// Init window
$this->gtk = new \GtkWindow;
$this->gtk = new GtkWindow;
$this->gtk->set_size_request(
$this::WIDTH,
@ -69,8 +72,8 @@ class Browser @@ -69,8 +72,8 @@ class Browser
$this->gtk->connect(
'configure-event',
function(
\GtkWindow $window,
// \GdkEvent $event
GtkWindow $window,
// GdkEvent $event
) {
// @TODO render data wordwrap by $window->get_size()
}

10
src/Entity/Browser/Container.php

@ -4,11 +4,15 @@ declare(strict_types=1); @@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser;
use \GtkBox;
use \GtkOrientation;
use \Yggverse\Yoda\Entity\Browser;
class Container
{
public \GtkBox $gtk;
// GTK
public GtkBox $gtk;
// Dependencies
public Browser $browser;
@ -23,8 +27,8 @@ class Container @@ -23,8 +27,8 @@ class Container
$this->browser = $browser;
// Init container
$this->gtk = new \GtkBox(
\GtkOrientation::VERTICAL
$this->gtk = new GtkBox(
GtkOrientation::VERTICAL
);
// Init tab

7
src/Entity/Browser/Header.php

@ -4,11 +4,14 @@ declare(strict_types=1); @@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser;
use \GtkHeaderBar;
use \Yggverse\Yoda\Entity\Browser;
class Header
{
public \GtkHeaderBar $gtk;
// GTK
public GtkHeaderBar $gtk;
// Dependencies
public Browser $browser;
@ -28,7 +31,7 @@ class Header @@ -28,7 +31,7 @@ class Header
$this->browser = $browser;
// Init header
$this->gtk = new \GtkHeaderBar;
$this->gtk = new GtkHeaderBar;
$this->gtk->set_show_close_button(
$this::ACTIONS

5
src/Entity/Browser/History.php

@ -4,10 +4,13 @@ declare(strict_types=1); @@ -4,10 +4,13 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser;
use \GtkWindow;
use \Yggverse\Yoda\Entity\Browser;
class History
{
// GTK
public \GtkWindow $gtk;
// Dependencies
@ -29,7 +32,7 @@ class History @@ -29,7 +32,7 @@ class History
$this->browser = $browser;
// Init window
$this->gtk = new \GtkWindow;
$this->gtk = new GtkWindow;
$this->gtk->set_size_request(
$this::WIDTH,

10
src/Entity/Browser/History/Container.php

@ -4,11 +4,15 @@ declare(strict_types=1); @@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History;
use \GtkBox;
use \GtkOrientation;
use \Yggverse\Yoda\Entity\Browser\History;
class Container
{
public \GtkBox $gtk;
// GTK
public GtkBox $gtk;
// Dependencies
public History $history;
@ -24,8 +28,8 @@ class Container @@ -24,8 +28,8 @@ class Container
$this->history = $history;
// Init container
$this->gtk = new \GtkBox(
\GtkOrientation::VERTICAL
$this->gtk = new GtkBox(
GtkOrientation::VERTICAL
);
// Init navbar

7
src/Entity/Browser/History/Container/Content.php

@ -4,11 +4,14 @@ declare(strict_types=1); @@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container;
use \GtkScrolledWindow;
use \Yggverse\Yoda\Entity\Browser\History\Container;
class Content
{
public \GtkScrolledWindow $gtk;
// GTK
public GtkScrolledWindow $gtk;
// Dependencies
public Container $container;
@ -27,7 +30,7 @@ class Content @@ -27,7 +30,7 @@ class Content
$this->container = $container;
// Init container
$this->gtk = new \GtkScrolledWindow;
$this->gtk = new GtkScrolledWindow;
$this->gtk->set_margin_start(
$this::MARGIN

20
src/Entity/Browser/History/Container/Content/Table.php

@ -4,11 +4,15 @@ declare(strict_types=1); @@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Content;
use \GtkCellRendererText;
use \GtkTreeView;
use \GtkTreeViewColumn;
use \Yggverse\Yoda\Entity\Browser\History\Container\Content;
class Table
{
public \GtkTreeView $gtk;
public GtkTreeView $gtk;
// Dependencies
public Content $content;
@ -28,30 +32,30 @@ class Table @@ -28,30 +32,30 @@ class Table
$this->content = $content;
// Init tree view
$this->gtk = new \GtkTreeView;
$this->gtk = new GtkTreeView;
$this->gtk->append_column(
new \GtkTreeViewColumn(
new GtkTreeViewColumn(
$this::TIME,
new \GtkCellRendererText(),
new GtkCellRendererText(),
'text',
1
)
);
$this->gtk->append_column(
new \GtkTreeViewColumn(
new GtkTreeViewColumn(
$this::URL,
new \GtkCellRendererText(),
new GtkCellRendererText(),
'text',
2
)
);
$this->gtk->append_column(
new \GtkTreeViewColumn(
new GtkTreeViewColumn(
$this::TITLE,
new \GtkCellRendererText(),
new GtkCellRendererText(),
'text',
3
)

15
src/Entity/Browser/History/Container/Content/Table/Data.php

@ -4,11 +4,14 @@ declare(strict_types=1); @@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Content\Table;
use \GObject;
use \GtkListStore;
use \Yggverse\Yoda\Entity\Browser\History\Container\Content\Table;
class Data
{
public \GtkListStore $gtk;
public GtkListStore $gtk;
// Dependencies
public Table $table;
@ -23,11 +26,11 @@ class Data @@ -23,11 +26,11 @@ class Data
$this->table = $table;
// Init tree view
$this->gtk = new \GtkListStore(
\GObject::TYPE_INT,
\GObject::TYPE_STRING,
\GObject::TYPE_STRING,
\GObject::TYPE_STRING
$this->gtk = new GtkListStore(
GObject::TYPE_INT,
GObject::TYPE_STRING,
GObject::TYPE_STRING,
GObject::TYPE_STRING
);
}

7
src/Entity/Browser/History/Container/Content/Viewport.php

@ -4,11 +4,14 @@ declare(strict_types=1); @@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Content;
use \GtkViewport;
use \Yggverse\Yoda\Entity\Browser\History\Container\Content;
class Viewport
{
public \GtkViewport $gtk;
// GTK
public GtkViewport $gtk;
// Dependencies
public Content $content;
@ -20,7 +23,7 @@ class Viewport @@ -20,7 +23,7 @@ class Viewport
$this->content = $content;
// Init viewport
$this->gtk = new \GtkViewport;
$this->gtk = new GtkViewport;
// Render
$this->gtk->show();

9
src/Entity/Browser/History/Container/Navbar.php

@ -4,11 +4,14 @@ declare(strict_types=1); @@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container;
use \GtkBox;
use \GtkOrientation;
use \Yggverse\Yoda\Entity\Browser\History\Container;
class Navbar
{
public \GtkBox $gtk;
public GtkBox $gtk;
// Dependencies
public Container $container;
@ -30,8 +33,8 @@ class Navbar @@ -30,8 +33,8 @@ class Navbar
$this->container = $container;
// Init container
$this->gtk = new \GtkBox(
\GtkOrientation::HORIZONTAL
$this->gtk = new GtkBox(
GtkOrientation::HORIZONTAL
);
$this->gtk->set_margin_top(

4
src/Entity/Browser/History/Container/Navbar/Delete.php

@ -4,6 +4,8 @@ declare(strict_types=1); @@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
use \GtkButton;
use \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button;
class Delete extends Button
@ -13,7 +15,7 @@ class Delete extends Button @@ -13,7 +15,7 @@ class Delete extends Button
public const TOOLTIP = 'Delete';
protected function _onCLick(
\GtkButton $entity
GtkButton $entity
): void
{
if ($id = $this->navbar->container->content->table->getSelectedId())

15
src/Entity/Browser/History/Container/Navbar/Filter.php

@ -4,6 +4,9 @@ declare(strict_types=1); @@ -4,6 +4,9 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
use \GdkEvent;
use \GtkEntry;
use \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Entry;
class Filter extends Entry
@ -11,7 +14,7 @@ class Filter extends Entry @@ -11,7 +14,7 @@ class Filter extends Entry
public const PLACEHOLDER = 'Search in history...';
protected function _onActivate(
\GtkEntry $entry
GtkEntry $entry
): void
{
$this->navbar->container->content->search(
@ -20,8 +23,8 @@ class Filter extends Entry @@ -20,8 +23,8 @@ class Filter extends Entry
}
protected function _onKeyRelease(
\GtkEntry $entry,
\GdkEvent $event
GtkEntry $entry,
GdkEvent $event
): void
{
$this->navbar->container->content->search(
@ -30,13 +33,13 @@ class Filter extends Entry @@ -30,13 +33,13 @@ class Filter extends Entry
}
protected function _onChanged(
\GtkEntry $entry
GtkEntry $entry
): void
{}
protected function _onFocusOut(
\GtkEntry $entry,
\GdkEvent $event
GtkEntry $entry,
GdkEvent $event
): void
{}
}

4
src/Entity/Browser/History/Container/Navbar/Open.php

@ -4,6 +4,8 @@ declare(strict_types=1); @@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
use \GtkButton;
use \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button;
class Open extends Button
@ -13,7 +15,7 @@ class Open extends Button @@ -13,7 +15,7 @@ class Open extends Button
public const TOOLTIP = 'Open';
protected function _onCLick(
\GtkButton $entity
GtkButton $entity
): void
{
$this->navbar->container->history->browser->container->tab->append(

6
src/Entity/Browser/History/Header.php

@ -4,9 +4,11 @@ declare(strict_types=1); @@ -4,9 +4,11 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History;
use \GtkHeaderBar;
class Header
{
public \GtkHeaderBar $gtk;
public GtkHeaderBar $gtk;
public const ACTIONS = true;
public const TITLE = 'History - Yoda';
@ -14,7 +16,7 @@ class Header @@ -14,7 +16,7 @@ class Header
public function __construct()
{
$this->gtk = new \GtkHeaderBar;
$this->gtk = new GtkHeaderBar;
$this->gtk->set_show_close_button(
$this::ACTIONS

9
src/Entity/Browser/Menu.php

@ -4,11 +4,14 @@ declare(strict_types=1); @@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser;
use \GtkMenu;
use \GtkSeparatorMenuItem;
use \Yggverse\Yoda\Entity\Browser;
class Menu
{
public \GtkMenu $gtk;
public GtkMenu $gtk;
// Dependencies
public Browser $browser;
@ -26,7 +29,7 @@ class Menu @@ -26,7 +29,7 @@ class Menu
$this->browser = $browser;
// Init menu
$this->gtk = new \GtkMenu;
$this->gtk = new GtkMenu;
// Init file menu item
$this->file = new Menu\File(
@ -57,7 +60,7 @@ class Menu @@ -57,7 +60,7 @@ class Menu
// Add separator
$this->gtk->append(
new \GtkSeparatorMenuItem
new GtkSeparatorMenuItem
);
// Init quit menu item

10
src/Entity/Browser/Menu/File.php

@ -4,11 +4,15 @@ declare(strict_types=1); @@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \GtkMenu;
use \GtkMenuItem;
use \Yggverse\Yoda\Entity\Browser\Menu;
class File
{
public \GtkMenuItem $gtk;
// GTK
public GtkMenuItem $gtk;
// Dependencies
public Menu $menu;
@ -23,12 +27,12 @@ class File @@ -23,12 +27,12 @@ class File
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->gtk = GtkMenuItem::new_with_label(
$this::LABEL
);
// Init submenu container
$file = new \GtkMenu;
$file = new GtkMenu;
// Init tab menu items
$open = new File\Open(

23
src/Entity/Browser/Menu/File/Open.php

@ -4,11 +4,18 @@ declare(strict_types=1); @@ -4,11 +4,18 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu\File;
use \GtkFileChooserAction;
use \GtkFileChooserDialog;
use \GtkFileFilter;
use \GtkMenuItem;
use \GtkResponseType;
use \Yggverse\Yoda\Entity\Browser\Menu\File;
class Open
{
public \GtkMenuItem $gtk;
// GTK
public GtkMenuItem $gtk;
// Dependencies
public File $file;
@ -29,7 +36,7 @@ class Open @@ -29,7 +36,7 @@ class Open
$this->file = $file;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->gtk = GtkMenuItem::new_with_label(
$this::LABEL
);
@ -41,15 +48,15 @@ class Open @@ -41,15 +48,15 @@ class Open
'activate',
function()
{
$dialog = new \GtkFileChooserDialog(
$dialog = new GtkFileChooserDialog(
'Open file',
$this->file->menu->browser->gtk,
\GtkFileChooserAction::OPEN,
GtkFileChooserAction::OPEN,
[
'Cancel',
\GtkResponseType::CANCEL,
GtkResponseType::CANCEL,
'Open',
\GtkResponseType::OK
GtkResponseType::OK
]
);
@ -66,7 +73,7 @@ class Open @@ -66,7 +73,7 @@ class Open
foreach ($this::PATTERN as $pattern => $name)
{
$filter = new \GtkFileFilter;
$filter = new GtkFileFilter;
$filter->set_name(
$name ? $name : $pattern
@ -81,7 +88,7 @@ class Open @@ -81,7 +88,7 @@ class Open
);
}
if (\GtkResponseType::OK == $dialog->run())
if (GtkResponseType::OK == $dialog->run())
{
foreach ($dialog->get_filenames() as $filename)
{

20
src/Entity/Browser/Menu/File/Save.php

@ -4,11 +4,17 @@ declare(strict_types=1); @@ -4,11 +4,17 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu\File;
use \GtkMenuItem;
use \GtkFileChooserDialog;
use \GtkFileChooserAction;
use \GtkResponseType;
use \Yggverse\Yoda\Entity\Browser\Menu\File;
class Save
{
public \GtkMenuItem $gtk;
// GTK
public GtkMenuItem $gtk;
// Dependencies
public File $file;
@ -23,7 +29,7 @@ class Save @@ -23,7 +29,7 @@ class Save
$this->file = $file;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->gtk = GtkMenuItem::new_with_label(
$this::LABEL
);
@ -35,15 +41,15 @@ class Save @@ -35,15 +41,15 @@ class Save
'activate',
function()
{
$dialog = new \GtkFileChooserDialog(
$dialog = new GtkFileChooserDialog(
'Save to file',
$this->file->menu->browser->gtk,
\GtkFileChooserAction::SAVE,
GtkFileChooserAction::SAVE,
[
'Cancel',
\GtkResponseType::CANCEL,
GtkResponseType::CANCEL,
'Save',
\GtkResponseType::APPLY
GtkResponseType::APPLY
]
);
@ -58,7 +64,7 @@ class Save @@ -58,7 +64,7 @@ class Save
true
);
if (\GtkResponseType::APPLY == $dialog->run())
if (GtkResponseType::APPLY == $dialog->run())
{
if ($page = $this->file->menu->browser->container->tab->get())
{

11
src/Entity/Browser/Menu/History.php

@ -4,11 +4,16 @@ declare(strict_types=1); @@ -4,11 +4,16 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \GtkMenuItem;
use \Yggverse\Yoda\Entity\Browser\Menu;
use \Yggverse\Yoda\Entity\Browser\History as Window;
class History
{
public \GtkMenuItem $gtk;
// GTK
public GtkMenuItem $gtk;
// Dependencies
public Menu $menu;
@ -23,7 +28,7 @@ class History @@ -23,7 +28,7 @@ class History
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->gtk = GtkMenuItem::new_with_label(
$this::LABEL
);
@ -35,7 +40,7 @@ class History @@ -35,7 +40,7 @@ class History
'activate',
function()
{
$history = new \Yggverse\Yoda\Entity\Browser\History(
$history = new Window(
$this->menu->browser
);
}

10
src/Entity/Browser/Menu/Quit.php

@ -4,11 +4,15 @@ declare(strict_types=1); @@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \Gtk;
use \GtkMenuItem;
use \Yggverse\Yoda\Entity\Browser\Menu;
class Quit
{
public \GtkMenuItem $gtk;
// GTK
public GtkMenuItem $gtk;
// Dependencies
public Menu $menu;
@ -23,7 +27,7 @@ class Quit @@ -23,7 +27,7 @@ class Quit
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->gtk = GtkMenuItem::new_with_label(
$this::LABEL
);
@ -35,7 +39,7 @@ class Quit @@ -35,7 +39,7 @@ class Quit
'activate',
function()
{
\Gtk::main_quit();
Gtk::main_quit();
}
);
}

10
src/Entity/Browser/Menu/Tab.php

@ -4,11 +4,15 @@ declare(strict_types=1); @@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \GtkMenu;
use \GtkMenuItem;
use \Yggverse\Yoda\Entity\Browser\Menu;
class Tab
{
public \GtkMenuItem $gtk;
// GTK
public GtkMenuItem $gtk;
// Dependencies
public Menu $menu;
@ -27,12 +31,12 @@ class Tab @@ -27,12 +31,12 @@ class Tab
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->gtk = GtkMenuItem::new_with_label(
$this::LABEL
);
// Init submenu container
$tab = new \GtkMenu;
$tab = new GtkMenu;
// Init new tab menu item
$this->add = new Tab\Add(

7
src/Entity/Browser/Menu/Tab/Add.php

@ -4,11 +4,14 @@ declare(strict_types=1); @@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu\Tab;
use \GtkMenuItem;
use \Yggverse\Yoda\Entity\Browser\Menu\Tab;
class Add
{
public \GtkMenuItem $gtk;
// GTK
public GtkMenuItem $gtk;
// Dependencies
public Tab $tab;
@ -24,7 +27,7 @@ class Add @@ -24,7 +27,7 @@ class Add
$this->tab = $tab;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->gtk = GtkMenuItem::new_with_label(
_($this::LABEL)
);

Loading…
Cancel
Save