| 1 | package Gapp::Button; | ||
| 2 | { | ||
| 3 | $Gapp::Button::VERSION = '0.60'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use Moose; | ||
| 7 | use MooseX::SemiAffordanceAccessor; | ||
| 8 | |||
| 9 | extends 'Gapp::Widget'; | ||
| 10 | with 'Gapp::Meta::Widget::Native::Role::HasAction'; | ||
| 11 | with 'Gapp::Meta::Widget::Native::Role::HasLabel'; | ||
| 12 | with 'Gapp::Meta::Widget::Native::Role::HasIcon'; | ||
| 13 | with 'Gapp::Meta::Widget::Native::Role::HasIconSize'; | ||
| 14 | with 'Gapp::Meta::Widget::Native::Role::HasImage'; | ||
| 15 | with 'Gapp::Meta::Widget::Native::Role::HasMnemonic'; | ||
| 16 | with 'Gapp::Meta::Widget::Native::Role::HasStockId'; | ||
| 17 | with 'Gapp::Meta::Widget::Native::Role::FormElement'; | ||
| 18 | with 'Gapp::Meta::Widget::Native::Role::CanDefault'; | ||
| 19 | |||
| 20 | has '+gclass' => ( | ||
| 21 | default => 'Gtk2::Button', | ||
| 22 | ); | ||
| 23 | |||
| 24 | has 'response' => ( | ||
| 25 | is => 'rw', | ||
| 26 | isa => 'Str', | ||
| 27 | ); | ||
| 28 | |||
| 29 | sub BUILDARGS { | ||
| 30 | my $class = shift; | ||
| 31 | my %args = @_ == 1 && is_HashRef( $_[0] ) ? %{$_[0]} : @_; | ||
| 32 | |||
| 33 | if ( exists $args{label} && ! $args{args} ) { | ||
| 34 | $args{args} = [ $args{label} ]; | ||
| 35 | $args{constructor} = 'new_with_label'; | ||
| 36 | } | ||
| 37 | |||
| 38 | for my $att ( qw( can_default has_default ) ) { | ||
| 39 | $args{properties}{$att} = delete $args{$att} if exists $args{$att}; | ||
| 40 | } | ||
| 41 | |||
| 42 | __PACKAGE__->SUPER::BUILDARGS( %args ); | ||
| 43 | } | ||
| 44 | |||
| 45 | |||
| 46 | 1; | ||
| 47 | |||
| 48 | |||
| 49 | __END__ |