/[libconf]/libconf/perl-Libconf/GUI/Gtk2.pm
ViewVC logotype

Diff of /libconf/perl-Libconf/GUI/Gtk2.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by dams, Sun Aug 17 14:20:11 2003 UTC revision 1.7 by dams, Mon Aug 18 18:50:22 2003 UTC
# Line 11  use lib qw(/usr/lib/libDrakX); Line 11  use lib qw(/usr/lib/libDrakX);
11  #use interactive;  #use interactive;
12  use common;  use common;
13  use Libconf;  use Libconf;
14    use ugtk2 qw(:helpers :wrappers :create);
15    
16  # public methods  # public methods
17    
# Line 31  sub getBestWidget { Line 32  sub getBestWidget {
32  # @widget_options is optional  # @widget_options is optional
33  sub build_widget {  sub build_widget {
34      my ($data, $data_mapping, @widget_options) = @_;      my ($data, $data_mapping, @widget_options) = @_;
35      my ($type, $type2, $type3, $default) = @{$data}{qw(type type2 type3, default)};      my ($type, $type2, $type3, $default, $values) = @{$data}{qw(type type2 type3 default values)};
36        $data_mapping ||= {};
37  #    print "-- $type\n";  #    print "-- $type\n";
38  #     if ($type eq 'LIST') {  #     if ($type eq 'LIST') {
39  #         defined $type2 or die "ERROR : missing type2 for LIST type. key : $key, malformed template : . " $struct->{libconf}{template_name};  #         defined $type2 or die "ERROR : missing type2 for LIST type. key : $key, malformed template : . " $struct->{libconf}{template_name};
# Line 41  sub build_widget { Line 42  sub build_widget {
42  #         } else {  #         } else {
43  #         }  #         }
44  #     } els  #     } els
45    
46        my $is_combo = 0;
47        print " ------------ \n";
48        use Data::Dumper;
49        Dumper($values) . "\n";
50        if (defined $values) {
51            if (ref($values) eq 'CODE') {
52                $values = &$values();
53            }
54            if (ref($values) eq 'ARRAY') {
55                $is_combo = 1;
56            }
57        }
58    
59      if ($type eq 'BOOLEAN') {      if ($type eq 'BOOLEAN') {
60          $ret = Libconf::GUI::Gtk2::CheckButton->new($default, $data_mapping->{BOOLEAN}, @widget_options);          $ret = Libconf::GUI::Gtk2::CheckButton->new($default, $data_mapping->{BOOLEAN}, @widget_options);
61      } elsif ($type eq 'STRING') {      } elsif ($type eq 'STRING') {
62          $ret = Libconf::GUI::Gtk2::Entry->new();          if ($is_combo) {
63                $ret = gtkcombo_setpopdown_strings(Libconf::GUI::Gtk2::Combo->new($default, $data_mapping->{STRING}, @widget_options),
64                                                   @$values,
65                                                  );
66            } else {
67                $ret = Libconf::GUI::Gtk2::Entry->new();
68            }
69      } else {      } else {
70          $ret = Libconf::GUI::Gtk2::Entry->new();          $ret = Libconf::GUI::Gtk2::Entry->new();
71      }      }
# Line 183  sub create_dialog { Line 204  sub create_dialog {
204      $ret;      $ret;
205  }  }
206    
207    package Libconf::GUI::Gtk2::Combo;
208    
209    use ugtk2 qw(:helpers :wrappers :create);
210    
211    our @ISA = qw(Gtk2::Combo);
212    
213    sub new {
214        my ($class, $default, $data_mapping, @widget_options) = @_;
215        my $self = $class->SUPER::new(@widget_options);
216        $self->{'default_value'} = $default;
217        $self->{'data_mapping'} = $data_mapping;
218        bless $self, $class;
219        return $self;
220    }
221    
222    sub set_value {
223        my ($self, $value) = @_;
224    #    $self->set_data('value', $value);
225    #    $self->{'value'} = $value;
226    #    $self->set_text($value);
227    #    defined $self->{'data_mapping'} and $value = $self->{'data_mapping'}->($value);
228    #    $self->set_active($value);
229    }
230    
231    
232    
233    
234  package Libconf::GUI::Gtk2::CheckButton;  package Libconf::GUI::Gtk2::CheckButton;
235    
236  use ugtk2 qw(:helpers :wrappers :create);  use ugtk2 qw(:helpers :wrappers :create);
# Line 213  sub new { Line 261  sub new {
261      return $self;      return $self;
262  }  }
263    
264  #### TO BE REWORKED  #### TO BE REWORKED, data mapping is bad
265  sub set_default {  sub set_default {
266      my ($self) = @_;      my ($self) = @_;
267      print " - SET DEFAULT \n";      print " - SET DEFAULT \n";

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26