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