Created
July 13, 2013 06:35
-
-
Save Timbus/5989671 to your computer and use it in GitHub Desktop.
Currently working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class My::Model { | |
use GTKBind::Model; | |
attach 'text' => ( | |
to => [ 'entry', 'label' ], | |
default => 'derp', | |
); | |
attach 'reset_active' => ( | |
to => { id => 'resetbutton', property => 'sensitive' }, | |
default => 0, | |
depends => 'text', | |
calculate => sub { | |
my $self = shift; | |
my $val = shift; #In this case, it's always 'text'. | |
return $self->$val ne $self->default($val); | |
} | |
); | |
} | |
class My::Controller { | |
use GTKBind::Controller; | |
on 'resetbutton', 'clicked' => sub { | |
my $self = shift; | |
$self->model->reset('text'); | |
}; | |
watch 'reset_active' => sub { | |
say "reset_active changed"; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment