« blib/lib/Gapp/Meta/Widget/Native/Role/HasStockId.pm
↑ Summary
blib/lib/Gapp/Meta/Widget/Native/Trait/NotebookPage.pm »
| 1 | package Gapp::Meta::Widget::Native::Trait::FromUIManager; | ||
| 2 | { | ||
| 3 | $Gapp::Meta::Widget::Native::Trait::FromUIManager::VERSION = '0.60'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use Moose::Role; | ||
| 7 | use MooseX::SemiAffordanceAccessor; | ||
| 8 | use MooseX::LazyRequire; | ||
| 9 | |||
| 10 | use Gapp::Types qw( GappUIManager ); | ||
| 11 | |||
| 12 | has 'ui' => ( | ||
| 13 | is => 'rw', | ||
| 14 | isa => GappUIManager, | ||
| 15 | coerce => 1, | ||
| 16 | lazy_required => 1, | ||
| 17 | ); | ||
| 18 | |||
| 19 | has 'ui_widget' => ( | ||
| 20 | is => 'rw', | ||
| 21 | isa => 'Str', | ||
| 22 | lazy_required => 1, | ||
| 23 | ); | ||
| 24 | |||
| 25 | around '_construct_gobject' => sub { | ||
| 26 | my ( $orig, $self ) = @_; | ||
| 27 | my $w = $self->ui->gobject->get_widget( $self->ui_widget ); | ||
| 28 | |||
| 29 | if ( ! $w ) { | ||
| 30 | $self->meta->throw_error( | ||
| 31 | q[could not find widget ] . $self->ui_widget . q[ in: ] . | ||
| 32 | ( scalar @{ $self->ui->files } ? | ||
| 33 | join ( ',' , @{ $self->ui->files } ) : | ||
| 34 | '(no files in ui)' ) | ||
| 35 | ) | ||
| 36 | } | ||
| 37 | else { | ||
| 38 | $self->set_gobject( $w ); | ||
| 39 | return $w; | ||
| 40 | } | ||
| 41 | |||
| 42 | }; | ||
| 43 | |||
| 44 | |||
| 45 | package Gapp::Meta::Widget::Custom::Trait::FromUIManager; | ||
| 46 | { | ||
| 47 | $Gapp::Meta::Widget::Custom::Trait::FromUIManager::VERSION = '0.60'; | ||
| 48 | } | ||
| 49 | sub register_implementation { 'Gapp::Meta::Widget::Native::Trait::FromUIManager' }; | ||
| 50 | |||
| 51 | |||
| 52 | 1; |