ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Util.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Util.pm (file contents):
Revision 1.2 by elmex, Fri Apr 7 16:29:19 2006 UTC vs.
Revision 1.4 by elmex, Fri Apr 7 16:36:44 2006 UTC

5 my ($file) = @_; 5 my ($file) = @_;
6 6
7 open CFG, $file 7 open CFG, $file
8 or return; 8 or return;
9 9
10 local $/;
10 $::CFG = eval join '', <CFG>; 11 $::CFG = eval <CFG>;
11 12
12 close CFG; 13 close CFG;
13} 14}
14 15
15sub write_cfg { 16sub write_cfg {
39 $cfg->{$key} = $ent->get_text; 40 $cfg->{$key} = $ent->get_text;
40 }); 41 });
41} 42}
42 43
43sub run_config_dialog { 44sub run_config_dialog {
44 Gtk2->init; 45 my (%events) = @_;
45 46
46 my $w = Gtk2::Window->new; 47 my $w = Gtk2::Window->new;
47 48
48 my @cfg = ( 49 my @cfg = (
49 [qw/Width width/], 50 [qw/Width width/],
50 [qw/Height height/], 51 [qw/Height height/],
52 [qw/Host host/],
53 [qw/Port port/],
54 [qw/Username user/],
55 [qw/Password password/],
51 ); 56 );
52 57
53 my $cfg = {}; 58 my $cfg = {};
54 59
55 $w->add (my $vb = Gtk2::VBox->new); 60 $w->add (my $vb = Gtk2::VBox->new);
65 $cb->signal_connect (clicked => sub { 70 $cb->signal_connect (clicked => sub {
66 for (keys %$cfg) { 71 for (keys %$cfg) {
67 $::CFG->{$_} = $cfg->{$_} 72 $::CFG->{$_} = $cfg->{$_}
68 if $_ ne '_i'; 73 if $_ ne '_i';
69 } 74 }
70 $w->destroy 75 });
76 $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5);
77 $cb->signal_connect (clicked => sub {
78 for (keys %$cfg) {
79 $::CFG->{$_} = $cfg->{$_}
80 if $_ ne '_i';
81 }
82 my $cb = $events{login} || sub {};
83 $cb->($::CFG->{user}, $::CFG->{password});
84 });
85 $hb->pack_start (my $cb = Gtk2::Button->new ("logout"), 1, 1, 5);
86 $cb->signal_connect (clicked => sub {
87 my $cb = $events{login} || sub {};
88 $cb->();
71 }); 89 });
72 90
73 $w->show_all; 91 $w->show_all;
74 92
75 $w->signal_connect (destroy => sub { Gtk2->main_quit }); 93 $w->signal_connect (destroy => sub { Gtk2->main_quit });
76 Gtk2->main;
77} 94}
78 95
791; 961;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines