ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/user.pl
Revision: 1.3
Committed: Fri Jul 25 17:57:13 2003 UTC (20 years, 10 months ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 package user;
2
3 use List::Util;
4
5 use base KGS::Listener::User;
6 use base gtk::widget;
7
8 sub new {
9 my $self = shift;
10 $self = $self->SUPER::new(@_);
11
12 $self->listen($self->{conn});
13
14 $self->send (notify_add => name => $self->{name});
15
16 $self->{window} = new Gtk2::Window 'toplevel';
17 $self->{window}->set_title("KGS User $self->{name}");
18 gtk::state $self->{window}, "user::window", undef, window_size => [400, 300];
19
20 $self->{window}->signal_connect(delete_event => sub { $self->destroy; 1 });
21
22 my $notebook = new Gtk2::Notebook;
23
24 $notebook->signal_connect (switch_page => sub {
25 my ($notebook, undef, $page) = @_;
26
27 $self->userinfo if $page == 1;
28 $self->game_record if $page == 2;
29 $self->usergraph if $page == 3;
30 });
31
32 $self->{window}->add ($notebook);
33
34 $notebook->append_page (($self->{chat} = new chat), (new_with_mnemonic Gtk2::Label "_Chat"));
35
36 $self->{page_userinfo} = new Gtk2::Table 3, 5, 0;
37
38 $notebook->append_page ($self->{page_userinfo}, (new_with_mnemonic Gtk2::Label "_Info"));
39
40 $self->{page_record} = new Gtk2::VBox;
41
42 $notebook->append_page ($self->{page_record}, (new_with_mnemonic Gtk2::Label "_Record"));
43
44 $self->{page_graph} = new Gtk2::Curve;
45
46 $notebook->append_page ($self->{page_graph}, (new_with_mnemonic Gtk2::Label "_Graph"));
47
48 $self;
49 }
50
51 sub join {
52 my ($self) = @_;
53
54 $self->{window}->show_all;
55 }
56
57 sub event_userinfo {
58 my ($self) = @_;
59
60 my $ui = $self->{page_userinfo};
61
62 $ui->attach_defaults ((new Gtk2::Label "Name"), 0, 1, 0, 1);
63 $ui->attach_defaults ((new Gtk2::Label "Email"), 0, 1, 1, 2);
64 $ui->attach_defaults ((new Gtk2::Label "Registered"), 0, 1, 2, 3);
65 $ui->attach_defaults ((new Gtk2::Label "Last Login"), 0, 1, 3, 4);
66
67 $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{realname}), 1, 2, 0, 1);
68 $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{email}), 1, 2, 1, 2);
69 $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{regdate}), 1, 2, 2, 3);
70 $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{lastlogin}), 1, 2, 3, 4);
71
72 if ($self->{userinfo}{user}->has_pic) {
73 $self->{app}->userpic ($self->{name}, sub {
74 if ($_[0]) {
75 $ui->attach_defaults ((gtk::image_from_data $_[0]), 2, 3, 0, 4);
76 $ui->show_all;
77 }
78 });
79 }
80
81 $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{info}), 0, 2, 4, 5);
82
83 $ui->show_all;
84 }
85
86 sub event_game_record {
87 my ($self) = @_;
88 }
89
90 sub event_usergraph {
91 my ($self) = @_;
92
93 my $graph = $self->{usergraph};
94
95 my $curve = $self->{page_graph};
96
97 if (@$graph) {
98 $curve->set_range (0, (scalar @graph) - 1, (List::Util::min @$graph) - 1, (List::Util::max @$graph) + 1);
99 $curve->set_vector (@$graph);
100 }
101 }
102
103 sub event_msg {
104 my ($self) = @_;
105 }
106
107 sub destroy {
108 my ($self) = @_;
109
110 $self->send (notify_del => name => $self->{name});
111
112 $self->SUPER::destroy;
113 }
114
115 1;
116