summaryrefslogtreecommitdiff
path: root/lib/LDFM/DialogController.pm
blob: 7cd7807a738a2262e381d01acfe980b00aa1c02f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package LDFM::DialogController; 
use utf8;
use warnings;
use strict;
use base 'Gtk2::GladeXML::Simple';
use Path::Class;
 
our $VERSION = '0.01';
 
sub new {
    my ($class,%params)=@_;
 
    my $glade_file=dir($params{glade_dir})->file('ldfm-dialog.glade');
    my $self=$class->SUPER::new($glade_file);
 
    $self->{domanda}->set_text($params{domanda});
 
    $self->{risposta}->set_text($params{risposta}||'');
 
    return $self;
}
 
sub run {
    my ($self)=@_;
 
    $self->{dialog}->set_default_response('ok');
 
    my $response=$self->{dialog}->run();
 
    if ($response eq 'ok') {
        my $data=$self->{risposta}->get_text();
        $self->{dialog}->destroy();
 
        return $data;
    }
    else {
        $self->{dialog}->destroy();
 
        return;
    }
}
 
1;