… | |
… | |
29 | my $notebook = new Gtk2::Notebook; |
29 | my $notebook = new Gtk2::Notebook; |
30 | |
30 | |
31 | $notebook->signal_connect (switch_page => sub { |
31 | $notebook->signal_connect (switch_page => sub { |
32 | my ($notebook, undef, $page) = @_; |
32 | my ($notebook, undef, $page) = @_; |
33 | |
33 | |
34 | $self->userinfo if $page == 1; |
|
|
35 | $self->game_record if $page == 2; |
34 | $self->game_record if $page == 1; |
36 | $self->usergraph if $page == 3; |
35 | $self->usergraph if $page == 2; |
37 | }); |
36 | }); |
38 | |
37 | |
39 | $self->add ($notebook); |
38 | $self->add ($notebook); |
40 | |
39 | |
41 | $self->{chat} = new chat; |
40 | $self->{chat} = new chat; |
42 | $self->{chat}->signal_connect(command => sub { |
41 | $self->{chat}->signal_connect(command => sub { |
43 | my ($chat, $cmd, $arg) = @_; |
42 | my ($chat, $cmd, $arg) = @_; |
44 | $self->{app}->do_command ($chat, $cmd, $arg, user => $self); |
43 | $self->{app}->do_command ($chat, $cmd, $arg, user => $self); |
45 | }); |
44 | }); |
46 | |
45 | |
|
|
46 | $self->{info_inlay} = $self->{chat}->new_switchable_inlay("Info:", sub { $self->draw_info(@_) }, 1); |
|
|
47 | |
47 | $notebook->append_page ($self->{chat}, (new_with_mnemonic Gtk2::Label "_Chat")); |
48 | $notebook->append_page ($self->{chat}, (new_with_mnemonic Gtk2::Label "_Chat")); |
48 | |
|
|
49 | $self->{page_userinfo} = new Gtk2::Table 3, 5, 0; |
|
|
50 | $notebook->append_page ($self->{page_userinfo}, (new_with_mnemonic Gtk2::Label "_Info")); |
|
|
51 | |
49 | |
52 | $self->{page_record} = new Gtk2::ScrolledWindow; |
50 | $self->{page_record} = new Gtk2::ScrolledWindow; |
53 | $self->{page_record}->set_policy ("automatic", "always"); |
51 | $self->{page_record}->set_policy ("automatic", "always"); |
54 | $self->{page_record}->add ($self->{record_list} = Gtk2::SimpleList->new( |
52 | $self->{page_record}->add ($self->{record_list} = Gtk2::SimpleList->new( |
55 | Time => "text", |
53 | Time => "text", |
… | |
… | |
66 | $notebook->append_page ($self->{page_record}, (new_with_mnemonic Gtk2::Label "_Record")); |
64 | $notebook->append_page ($self->{page_record}, (new_with_mnemonic Gtk2::Label "_Record")); |
67 | |
65 | |
68 | $self->{page_graph} = new Gtk2::Curve; |
66 | $self->{page_graph} = new Gtk2::Curve; |
69 | $notebook->append_page ($self->{page_graph}, (new_with_mnemonic Gtk2::Label "_Graph")); |
67 | $notebook->append_page ($self->{page_graph}, (new_with_mnemonic Gtk2::Label "_Graph")); |
70 | |
68 | |
|
|
69 | $self->userinfo; |
71 | |
70 | |
72 | $self; |
71 | $self; |
|
|
72 | } |
|
|
73 | |
|
|
74 | sub draw_info { |
|
|
75 | my ($self, $inlay) = @_; |
|
|
76 | return unless defined $self->{userinfo}; |
|
|
77 | $inlay->append_text("\nRealname: $self->{userinfo}{realname}"); |
|
|
78 | $inlay->append_text("\nEmail: $self->{userinfo}{email}"); |
|
|
79 | my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($_->{userinfo}{regdate}); |
|
|
80 | $inlay->append_text (sprintf ("\nRegistered: %02d.%02d.%02d %02d:%02d", $mday, $mon + 1, $year + 1900, $hour, $min)); |
|
|
81 | ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($self->{userinfo}{lastlogin}); |
|
|
82 | $inlay->append_text (sprintf ("\nLast Login: %02d.%02d.%02d %02d:%02d", $mday, $mon + 1, $year + 1900, $hour, $min)); |
|
|
83 | $inlay->append_text ("\nComment:\n$self->{userinfo}{info}"); |
|
|
84 | $inlay->append_text ("\nPicture:\n"); |
|
|
85 | if ($self->{userinfo}{user}->has_pic) { |
|
|
86 | $self->{app}->userpic ($self->{name}, sub { |
|
|
87 | if ($_[0]) { |
|
|
88 | $inlay->append_widget(gtk::image_from_data $_[0]); |
|
|
89 | } |
|
|
90 | }); |
|
|
91 | } |
73 | } |
92 | } |
74 | |
93 | |
75 | sub join { |
94 | sub join { |
76 | my ($self) = @_; |
95 | my ($self) = @_; |
77 | |
96 | |
… | |
… | |
84 | $self->set_title ("KGS User $self->{name}"); |
103 | $self->set_title ("KGS User $self->{name}"); |
85 | } |
104 | } |
86 | |
105 | |
87 | sub event_userinfo { |
106 | sub event_userinfo { |
88 | my ($self) = @_; |
107 | my ($self) = @_; |
89 | |
108 | $self->{info_inlay}->refresh; |
90 | my $ui = $self->{page_userinfo}; |
|
|
91 | |
|
|
92 | $ui->attach_defaults ((new Gtk2::Label "Name"), 0, 1, 0, 1); |
|
|
93 | $ui->attach_defaults ((new Gtk2::Label "Email"), 0, 1, 1, 2); |
|
|
94 | $ui->attach_defaults ((new Gtk2::Label "Registered"), 0, 1, 2, 3); |
|
|
95 | $ui->attach_defaults ((new Gtk2::Label "Last Login"), 0, 1, 3, 4); |
|
|
96 | |
|
|
97 | $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{realname}), 1, 2, 0, 1); |
|
|
98 | $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{email}), 1, 2, 1, 2); |
|
|
99 | $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{regdate}), 1, 2, 2, 3); |
|
|
100 | $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{lastlogin}), 1, 2, 3, 4); |
|
|
101 | |
|
|
102 | if ($self->{userinfo}{user}->has_pic) { |
|
|
103 | $self->{app}->userpic ($self->{name}, sub { |
|
|
104 | if ($_[0]) { |
|
|
105 | $ui->attach_defaults ((gtk::image_from_data $_[0]), 2, 3, 0, 4); |
|
|
106 | $ui->show_all; |
|
|
107 | } |
|
|
108 | }); |
|
|
109 | } |
|
|
110 | |
|
|
111 | $ui->attach_defaults ((new Gtk2::Label $self->{userinfo}{info}), 0, 2, 4, 5); |
|
|
112 | |
|
|
113 | $ui->show_all; |
|
|
114 | } |
109 | } |
115 | |
110 | |
116 | sub event_game_record { |
111 | sub event_game_record { |
117 | my ($self) = @_; |
112 | my ($self) = @_; |
118 | |
113 | |