ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/InventoryEditor.pm
(Generate patch)

Comparing deliantra/gde/GCE/InventoryEditor.pm (file contents):
Revision 1.7 by elmex, Sun Mar 26 20:42:12 2006 UTC vs.
Revision 1.8 by elmex, Tue Apr 4 13:05:51 2006 UTC

30 $vb->pack_start ($self->{stackbox} = Gtk2::VBox->new, 1, 1, 0); 30 $vb->pack_start ($self->{stackbox} = Gtk2::VBox->new, 1, 1, 0);
31 31
32 $sw->set_policy ('automatic', 'automatic'); 32 $sw->set_policy ('automatic', 'automatic');
33} 33}
34 34
35sub push_inv_hist {
36 my ($self, $arch) = @_;
37 push @{$self->{inv_hist}}, $arch;
38}
39
40sub clear_inv_hist {
41 my ($self) = @_;
42 delete $self->{inv_hist};
43}
44
35sub set_arch { 45sub set_arch {
36 my ($self, $arch, $cb) = @_; 46 my ($self, $arch, $cb) = @_;
37 47
38 $self->{invarch}->remove ($_) for $self->{invarch}->get_children; 48 $self->{invarch}->remove ($_) for $self->{invarch}->get_children;
39 my $pba = new_arch_pb;
40 fill_pb_from_arch ($pba, $arch);
41 my $hb = Gtk2::HBox->new;
42 $hb->pack_start ((new_from_pixbuf Gtk2::Image $pba), 0, 0, 0);
43 $hb->pack_start (my $elemhdl = Gtk2::Button->new ($arch->{_name}), 0, 1, 0);
44 $elemhdl->signal_connect (clicked => sub {
45 $::MAINWIN->update_attr_editor ($arch, $cb);
46 });
47 GCE::DragHelper::set_drag_source (
48 $elemhdl, arch => sub { { arch => $arch } }
49 );
50 49
51 GCE::DragHelper::set_drag_sink ( 50 unless (@{$self->{inv_hist} || []}) {
52 $elemhdl, arch => sub { 51 push @{$self->{inv_hist}}, [$arch, $cb];
53 return unless $_[0]->{arch}; 52 }
54 push @{$arch->{inventory}}, dclone $_[0]->{arch};
55 $cb->() if $cb;
56 $self->set_arch ($arch, $cb)
57 }
58 );
59 53
54 for my $invar (@{$self->{inv_hist}}) {
55 my $pba = new_arch_pb;
56 fill_pb_from_arch ($pba, $invar->[0]);
57 my $hb = Gtk2::HBox->new;
58 $hb->pack_start ((new_from_pixbuf Gtk2::Image $pba), 0, 0, 0);
59 $hb->pack_start (my $elemhdl = Gtk2::Button->new ($invar->[0]->{_name}), 0, 1, 0);
60 $elemhdl->signal_connect (clicked => sub {
61 while (pop @{$self->{inv_hist}} != $invar) { 1 }
62 push @{$self->{inv_hist}}, $invar;
63 $::MAINWIN->{attr_edit}->update ($invar->[0]);
64 });
65 GCE::DragHelper::set_drag_source (
66 $elemhdl, arch => sub { { arch => $invar->[0] } }
67 );
68
69 GCE::DragHelper::set_drag_sink (
70 $elemhdl, arch => sub {
71 return unless $_[0]->{arch};
72 push @{$invar->[0]->{inventory}}, dclone $_[0]->{arch};
73 $cb->() if $cb;
74 $self->set_arch ($invar, $cb)
75 }
76 );
77
60 $self->{invarch}->add ($hb); 78 $self->{invarch}->add ($hb);
79 }
61 80
62 $self->{stackbox}->remove ($_) for $self->{stackbox}->get_children; 81 $self->{stackbox}->remove ($_) for $self->{stackbox}->get_children;
63 82
64 my $inv = $arch->{inventory}; 83 my $inv = $arch->{inventory};
65 my $idx = 0; 84 my $idx = 0;
83 }); 102 });
84 103
85 $hb->pack_start (my $elemhdl = new Gtk2::Button, 0, 0, 0); 104 $hb->pack_start (my $elemhdl = new Gtk2::Button, 0, 0, 0);
86 $elemhdl->add (my $hb2 = Gtk2::HBox->new); 105 $elemhdl->add (my $hb2 = Gtk2::HBox->new);
87 $elemhdl->signal_connect (clicked => sub { 106 $elemhdl->signal_connect (clicked => sub {
107 push @{$self->{inv_hist}}, [$ia, $cb];
88 $::MAINWIN->update_attr_editor ($ia, $cb); 108 $::MAINWIN->{attr_edit}->update ($ia);
89 }); 109 });
90 110
91 $hb2->pack_start (my $img = (new_from_pixbuf Gtk2::Image $pb), 0, 0, 0); 111 $hb2->pack_start (my $img = (new_from_pixbuf Gtk2::Image $pb), 0, 0, 0);
92 $img->set_alignment (0, 0.5); 112 $img->set_alignment (0, 0.5);
93 113

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines