Browse Source

draft content area

PHP-GTK3
yggverse 4 months ago
parent
commit
5e0ef1616e
  1. 59
      src/Entity/Browser/Container/Page/Auth.php

59
src/Entity/Browser/Container/Page/Auth.php

@ -8,6 +8,7 @@ use \GtkButtonsType;
use \GtkDialogFlags; use \GtkDialogFlags;
use \GtkMessageDialog; use \GtkMessageDialog;
use \GtkMessageType; use \GtkMessageType;
use \GtkRadioButton;
use \GtkResponseType; use \GtkResponseType;
use \Yggverse\Yoda\Entity\Browser\Container\Page; use \Yggverse\Yoda\Entity\Browser\Container\Page;
@ -21,8 +22,12 @@ class Auth
public Page $page; public Page $page;
// Defaults // Defaults
public const DIALOG_MESSAGE_FORMAT = 'Authorization';
public const DIALOG_DEFAULT_RESPONSE = GtkResponseType::CANCEL; public const DIALOG_DEFAULT_RESPONSE = GtkResponseType::CANCEL;
public const DIALOG_FORMAT_SECONDARY_TEXT = 'Select identity';
public const DIALOG_MESSAGE_FORMAT = 'Authorization';
public const DIALOG_CONTENT_OPTION_LABEL_CREATE = 'Create new for this resource';
public const DIALOG_CONTENT_OPTION_MARGIN = 8;
public const DIALOG_CONTENT_SPACING = 8;
public function __construct( public function __construct(
Page $page, Page $page,
@ -33,6 +38,7 @@ class Auth
public function dialog(): bool public function dialog(): bool
{ {
// Init dialog
$this->gtk = new GtkMessageDialog( $this->gtk = new GtkMessageDialog(
$this->page->container->browser->gtk, $this->page->container->browser->gtk,
GtkDialogFlags::MODAL, GtkDialogFlags::MODAL,
@ -41,10 +47,31 @@ class Auth
_($this::DIALOG_MESSAGE_FORMAT) _($this::DIALOG_MESSAGE_FORMAT)
); );
$this->gtk->format_secondary_text(
_($this::DIALOG_FORMAT_SECONDARY_TEXT)
);
$this->gtk->set_default_response( $this->gtk->set_default_response(
$this::DIALOG_DEFAULT_RESPONSE $this::DIALOG_DEFAULT_RESPONSE
); );
// Init content
$content = $this->gtk->get_content_area();
$content->set_spacing(
$this::DIALOG_CONTENT_SPACING
);
$content->add(
$this->_option(
_($this::DIALOG_CONTENT_OPTION_LABEL_CREATE)
)
);
// Render
$this->gtk->show_all();
// Listen for chose
if (GtkResponseType::OK == $this->gtk->run()) if (GtkResponseType::OK == $this->gtk->run())
{ {
// @TODO // @TODO
@ -58,4 +85,34 @@ class Auth
return false; return false;
} }
private function _option(
string $label,
int $margin = self::DIALOG_CONTENT_OPTION_MARGIN
): GtkRadioButton
{
$option = GtkRadioButton::new_with_label(
$label
);
$option->set_margin_start(
$margin
);
$option->set_margin_start(
$margin
);
$option->set_margin_end(
$margin
);
$option->set_margin_bottom(
$margin
);
// @TODO connect signals?
return $option;
}
} }
Loading…
Cancel
Save