ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/bin/kgsueme
(Generate patch)

Comparing kgsueme/bin/kgsueme (file contents):
Revision 1.3 by pcg, Wed May 28 22:26:25 2003 UTC vs.
Revision 1.4 by pcg, Wed May 28 23:40:41 2003 UTC

137 137
138 KGS::Listener::Debug->new->listen($self->{conn}); #d# debug only :) 138 KGS::Listener::Debug->new->listen($self->{conn}); #d# debug only :)
139 139
140 $self->listen($self->{conn}); 140 $self->listen($self->{conn});
141 141
142 $self->{roomlist} = new roomlist conn => $self->{conn};
143
142 $self->{window} = new Gtk::Window 'toplevel'; 144 $self->{window} = new Gtk::Window 'toplevel';
143 $self->{window}->set_title('kgsueme'); 145 $self->{window}->set_title('kgsueme');
144 ::state $self->{window}, "main::window", undef, window_size => [400, 100]; 146 ::state $self->{window}, "main::window", undef, window_size => [400, 100];
145 $self->{window}->signal_connect(delete_event => sub { main_quit Gtk }); 147 $self->{window}->signal_connect(delete_event => sub { main_quit Gtk });
146 148
147 $self->{window}->add(my $vbox = new Gtk::VBox); 149 $self->{window}->add(my $vbox = new Gtk::VBox);
148 150
149 $vbox->pack_start(($self->{buttonbox} = new Gtk::HButtonBox), 0, 1, 0); 151 $vbox->pack_start(($buttonbox = new Gtk::HButtonBox), 0, 1, 0);
152 $buttonbox->set_spacing(0);
150 153
151 my $button = sub { 154 my $button = sub {
152 $self->{buttonbox}->add(my $button = new Gtk::Button $_[0]); 155 $buttonbox->add(my $button = new Gtk::Button $_[0]);
153 signal_connect $button clicked => $_[1]; 156 signal_connect $button clicked => $_[1];
154 }; 157 };
155 158
156 $button->("Login", sub { 159 $button->("Login", sub { $self->login; });
157 $self->login; 160 $button->("Roomlist", sub { $self->{roomlist}->show; });
158 });
159 $button->("Roomlist", sub {
160 $self->{roomlist} ||= new roomlist conn => $self->{conn};
161 $self->{roomlist}->show;
162 });
163 $button->("Save Config & Layout", sub { ::save_state }); 161 $button->("Save Config & Layout", sub { ::save_state });
162 $button->("Quit", sub { main_quit Gtk });
164 163
165 $vbox->pack_start((my $hbox = new Gtk::HBox), 0, 1, 0); 164 $vbox->pack_start((my $hbox = new Gtk::HBox), 0, 1, 0);
166 165
167 $hbox->add(new Gtk::Label "Login"); 166 $hbox->add(new Gtk::Label "Login");
168 167
218 my ($self, $msg) = @_; 217 my ($self, $msg) = @_;
219 218
220 ::status("login", "logged in as '$self->{conn}{name}' with status '$msg->{result}'"); 219 ::status("login", "logged in as '$self->{conn}{name}' with status '$msg->{result}'");
221 $::config->{login} = $self->{conn}{name}; 220 $::config->{login} = $self->{conn}{name};
222 221
223 $self->{window}->show_all; 222 if ($msg->{success}) {
223 for (keys %{$::config->{rooms}}) {
224 $self->{roomlist}->join_room($_);
225 }
226 }
227
228 warn PApp::Util::dumpval($::config);
224} 229}
225 230
226sub event_disconnect { } 231sub event_disconnect { }
227 232
228############################################################################# 233#############################################################################
254 ::state $self->{roomlist}, "roomlist::roomlist", undef, clist_column_widths => [20, 200]; 259 ::state $self->{roomlist}, "roomlist::roomlist", undef, clist_column_widths => [20, 200];
255 260
256 $self->{roomlist}->signal_connect(select_row => sub { 261 $self->{roomlist}->signal_connect(select_row => sub {
257 my $room = $self->{roomlist}->get_row_data($_[1]) 262 my $room = $self->{roomlist}->get_row_data($_[1])
258 or return; 263 or return;
259 $self->{room}{$room->{channel}} ||= new room %$room, conn => $self->{conn}, users => {};
260 $self->{room}{$room->{channel}}->join;
261 $self->{roomlist}->unselect_all; 264 $self->{roomlist}->unselect_all;
265 $self->join_room($room->{channel});
262 }); 266 });
263 267
264 $self; 268 $self;
269}
270
271sub join_room {
272 my ($self, $channel) = @_;
273
274 $self->{room}{$channel} ||= room->new(channel => $channel, conn => $self->{conn}, users => {});
275 $self->{room}{$channel}->join;
265} 276}
266 277
267sub show { 278sub show {
268 my ($self, $msg) = @_; 279 my ($self, $msg) = @_;
269 280
415 426
416sub part { 427sub part {
417 my ($self) = @_; 428 my ($self) = @_;
418 $self->SUPER::part; 429 $self->SUPER::part;
419 430
431 delete $::config->{rooms}{$self->{channel}};
420 $self->{window}->hide_all; 432 $self->{window}->hide_all;
421 $self->event_update; 433 $self->event_update;
422 $self->event_update_games; 434 $self->event_update_games;
435}
436
437sub event_join {
438 my ($self) = @_;
439 $self->SUPER::event_join;
440
441 $::config->{rooms}{$self->{channel}} = 1;
423} 442}
424 443
425sub event_update_roominfo { 444sub event_update_roominfo {
426 my ($self) = @_; 445 my ($self) = @_;
427 446

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines