| 1 | package Gapp::Label; | ||
| 2 | { | ||
| 3 | $Gapp::Label::VERSION = '0.60'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use Moose; | ||
| 7 | use MooseX::SemiAffordanceAccessor; | ||
| 8 | |||
| 9 | extends 'Gapp::Widget'; | ||
| 10 | |||
| 11 | has '+gclass' => ( | ||
| 12 | default => 'Gtk2::Label', | ||
| 13 | ); | ||
| 14 | |||
| 15 | has 'text' => ( | ||
| 16 | is => 'rw', | ||
| 17 | isa => 'Str', | ||
| 18 | ); | ||
| 19 | |||
| 20 | has 'markup' => ( | ||
| 21 | is => 'rw', | ||
| 22 | isa => 'Str', | ||
| 23 | ); | ||
| 24 | |||
| 25 | sub BUILDARGS { | ||
| 26 | my $class = shift; | ||
| 27 | my %args = @_ == 1 && is_HashRef( $_[0] ) ? %{$_[0]} : @_; | ||
| 28 | |||
| 29 | |||
| 30 | #my %args; | ||
| 31 | #if ( @_ == 1 ) { | ||
| 32 | # if ( is_Str( $_[0] ) ) { | ||
| 33 | # $args{text} = $_[0]; | ||
| 34 | # } | ||
| 35 | # elsif ( is_HashRef( $_[0] ) ) { | ||
| 36 | # %args = %{$_[0]}; | ||
| 37 | # } | ||
| 38 | # else { | ||
| 39 | # $class->meta->throw_error( 'Single parameter to constructor must be a sting a hash reference.' ); | ||
| 40 | # } | ||
| 41 | #} | ||
| 42 | #else { | ||
| 43 | # %args = ( @_ ); | ||
| 44 | #} | ||
| 45 | |||
| 46 | |||
| 47 | #if ( exists $args{markup} ) { | ||
| 48 | # $args{args} = [ $args{markup} ]; | ||
| 49 | # $args{constructor} = 'new_with_markup'; | ||
| 50 | #} | ||
| 51 | #elsif ( exists $args{mnemonic} ) { | ||
| 52 | # $args{args} = [ $args{mnemonic} ]; | ||
| 53 | # $args{constructor} = 'new_with_mnemonic'; | ||
| 54 | #} | ||
| 55 | if ( exists $args{text} ) { | ||
| 56 | $args{args} = [ $args{text} ]; | ||
| 57 | } | ||
| 58 | #delete $args{markup}; | ||
| 59 | #delete $args{mnemonic}; | ||
| 60 | #delete $args{text}; | ||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | for my $att ( qw( angle ellipsize cursor_position max_width_chars mnemonic_keyval pattern selectable selection_bound single_line_mode track_visited_links use_markup use_underline width_chars wrap wrap_mode xalign yalign justify ) ) { | ||
| 65 | $args{properties}{$att} = delete $args{$att} if exists $args{$att}; | ||
| 66 | } | ||
| 67 | |||
| 68 | __PACKAGE__->SUPER::BUILDARGS( %args ); | ||
| 69 | } | ||
| 70 | |||
| 71 | 1; | ||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | __END__ |