ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/AttrEdit.pm
Revision: 1.3
Committed: Thu Feb 9 15:45:52 2006 UTC (18 years, 3 months ago) by elmex
Branch: MAIN
Changes since 1.2: +55 -14 lines
Log Message:
improved attribute editor

File Contents

# Content
1 package GCE::AttrEdit;
2
3 =head1 NAME
4
5 GCE::AttrEdit - an edit wiget for attributes
6
7 =cut
8
9 use Gtk2;
10 use Gtk2::Gdk::Keysyms;
11 use Gtk2::SimpleList;
12
13 use Glib::Object::Subclass Gtk2::Notebook;
14
15 use GCE::AttrList;
16
17 use Crossfire;
18
19 sub INIT_INSTANCE {
20 my ($self) = @_;
21
22 my $al = $self->{al} = GCE::AttrList->new (editable => 1, raw => 0);
23 $self->append_page ($al, "obj attrs");
24 $al->set_arch_cb (sub { $self->update_arch (@_) });
25
26 $al = $self->{raw_al} = GCE::AttrList->new (editable => 1);
27 $self->append_page ($al, "raw attrs");
28 $al->set_arch_cb (sub { $self->update_arch (@_) });
29
30 $al = $self->{al_arch} = GCE::AttrList->new (editable => 0);
31 $self->append_page ($al, "arch attrs");
32 $al->set_arch_cb (sub { $self->update_arch (@_) });
33 }
34
35 sub update_arch {
36 my ($self, $arch, $key, $value) = @_;
37
38
39 if ($value ne '') {
40
41 $arch->{$key} = $value;
42
43 } else {
44
45 delete $arch->{$key};
46
47 }
48
49 $self->set_arch ($arch);
50 }
51
52 sub set_arch {
53 my ($self, $arch, $ro) = @_;
54
55 if ($ro) {
56
57 $self->{al}->set (editable => 0);
58 $self->{raw_al}->set (editable => 0);
59
60 } else {
61
62 $self->{al}->set (editable => 1);
63 $self->{raw_al}->set (editable => 1);
64 }
65
66 $self->{al}->set_arch ($arch);
67 $self->{raw_al}->set_arch ($arch);
68 my $al_arch = $Crossfire::ARCH->{$arch->{_name}};
69
70 if ($al_arch) {
71
72 $self->{al_arch}->set_arch ($al_arch);
73
74 } else {
75
76 $self->{al_arch}->set_arch ({ noarch => 'noarch' });
77 }
78 }
79
80
81 =head1 AUTHOR
82
83 Marc Lehmann <schmorp@schmorp.de>
84 http://home.schmorp.de/
85
86 Robin Redeker <elmex@ta-sa.org>
87 http://www.ta-sa.org/
88
89 =cut
90 1;