… | |
… | |
7 | use Glib::Object::Subclass |
7 | use Glib::Object::Subclass |
8 | Gtk2::Frame; |
8 | Gtk2::Frame; |
9 | |
9 | |
10 | sub new { |
10 | sub new { |
11 | my ($self, %arg) = @_; |
11 | my ($self, %arg) = @_; |
|
|
12 | |
12 | $self = $self->Glib::Object::new; |
13 | $self = $self->Glib::Object::new; |
13 | $self->{$_} = delete $arg{$_} for keys %arg; |
14 | $self->{$_} = delete $arg{$_} for keys %arg; |
14 | |
15 | |
15 | $self->signal_connect (destroy => sub { |
16 | $self->signal_connect (destroy => sub { |
16 | delete $::config->{rooms}{$self->{channel}}; |
17 | delete $::config->{rooms}{$self->{channel}}; |
… | |
… | |
26 | |
27 | |
27 | $self->add (my $hbox = new Gtk2::HBox); |
28 | $self->add (my $hbox = new Gtk2::HBox); |
28 | |
29 | |
29 | $hbox->pack_start ((my $vbox = new Gtk2::VBox), 1, 1, 0); |
30 | $hbox->pack_start ((my $vbox = new Gtk2::VBox), 1, 1, 0); |
30 | |
31 | |
31 | $vbox->add ($self->{chat} = new chat); |
32 | $vbox->add ($self->{chat} = new chat app => $self->{app}); |
32 | |
33 | |
33 | $self->{chat}->signal_connect(command => sub { |
34 | $self->{chat}->signal_connect (command => sub { |
34 | my ($chat, $cmd, $arg) = @_; |
35 | my ($chat, $cmd, $arg) = @_; |
35 | $self->{app}->do_command ($chat, $cmd, $arg, userlist => $self->{userlist}, room => $self); |
36 | $self->{app}->do_command ($chat, $cmd, $arg, userlist => $self->{userlist}, room => $self); |
36 | }); |
37 | }); |
37 | |
38 | |
38 | $hbox->pack_start ((my $vbox = new Gtk2::VBox), 0, 1, 0); |
39 | $hbox->pack_start ((my $vbox = new Gtk2::VBox), 0, 1, 0); |
… | |
… | |
42 | |
43 | |
43 | $vbox->pack_start ((my $button = new_with_label Gtk2::Button "New Game"), 0, 1, 0); |
44 | $vbox->pack_start ((my $button = new_with_label Gtk2::Button "New Game"), 0, 1, 0); |
44 | $button->signal_connect (clicked => sub { $self->new_game }); |
45 | $button->signal_connect (clicked => sub { $self->new_game }); |
45 | |
46 | |
46 | $vbox->pack_start ((my $sw = new Gtk2::ScrolledWindow), 1, 1, 0); |
47 | $vbox->pack_start ((my $sw = new Gtk2::ScrolledWindow), 1, 1, 0); |
47 | $sw->set_policy("automatic", "always"); |
48 | $sw->set_policy ("automatic", "always"); |
48 | |
49 | |
49 | $sw->add ($self->{userlist} = new userlist); |
50 | $sw->add ($self->{userlist} = new userlist); |
50 | |
51 | |
51 | $self; |
52 | $self; |
52 | } |
53 | } |
53 | |
54 | |
54 | sub FINALIZE_INSTANCE { print "FIN room\n" } # never called MEMLEAK #d#TODO# |
55 | sub FINALIZE_INSTANCE { print "FIN room\n" } # never called MEMLEAK #d#TODO# |
55 | |
56 | |
56 | sub part { |
57 | sub part { |
57 | my ($self) = @_; |
58 | my ($self) = @_; |
|
|
59 | |
|
|
60 | $self->hide; |
58 | $self->SUPER::part; |
61 | $self->SUPER::part; |
59 | |
|
|
60 | $self->hide_all; |
|
|
61 | } |
62 | } |
62 | |
63 | |
63 | sub inject_msg_room { |
64 | sub inject_msg_room { |
64 | my ($self, $msg) = @_; |
65 | my ($self, $msg) = @_; |
65 | |
66 | |
66 | # secret typoe ;-) |
67 | # secret typoe ;-) |
67 | $self->{chat}->append_text ("\n<header><user>" . (util::toxml $msg->{name}) |
68 | $self->{chat}->append_text ("\n<user>" . (util::toxml $msg->{name}) |
68 | . "</user>: </header>" . (util::toxml $msg->{message})); |
69 | . "</user>: " . (util::toxml $msg->{message})); |
69 | } |
70 | } |
70 | |
71 | |
71 | sub event_update_users { |
72 | sub event_update_users { |
72 | my ($self, $add, $update, $remove) = @_; |
73 | my ($self, $add, $update, $remove) = @_; |
73 | |
74 | |