summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakclock
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/drakclock')
-rwxr-xr-xperl-install/standalone/drakclock65
1 files changed, 40 insertions, 25 deletions
diff --git a/perl-install/standalone/drakclock b/perl-install/standalone/drakclock
index a1dd5b5f5..a71e695ae 100755
--- a/perl-install/standalone/drakclock
+++ b/perl-install/standalone/drakclock
@@ -17,10 +17,11 @@ my $radius;
my ($dRadians_hour, $dRadians_min, $dRadians_sec);
my $Radian;
my $timer;
-my ($midx, $midy);
my $first = 1;
my $its_reset = 0;
+$ugtk2::wm_icon = "/usr/share/mcc/themes/default/time-mdk.png";
+
#my $conffile = '/etc/sysconfig/ntpclock';
my $ntpfile = '/etc/ntp.conf';
my $ntpdlock = '/var/lock/subsys/ntpd';
@@ -66,16 +67,12 @@ my $mode = 0;
my (undef, undef, $h_old, $old_day, $old_month, $old_year) = localtime(time());
-my @image_size = (300, 300);
+my @image_size = (200, 200);
$my_win->{window}->add(gtkpack_(gtkset_border_width(Gtk2::VBox->new, $::isEmbedded ? 0 : 5),
1, gtkpack_(Gtk2::HBox->new,
1, gtkpack_(Gtk2::VBox->new,
0, $calendar,
- 0, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Timezone")), 'etched_in'),
- gtkpack__(gtkset_border_width(Gtk2::VBox->new, 5),
- $label_timezone,
- $button_time)),
1, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Network Time Protocol")), 'etched_in'),
gtkpack_(gtkset_border_width(Gtk2::VBox->new, 5),
0, Gtk2::Label->new(N("Your computer can synchronize its clock\n with a remote time server using NTP")),
@@ -101,12 +98,17 @@ $my_win->{window}->add(gtkpack_(gtkset_border_width(Gtk2::VBox->new, $::isEmbedd
0, my $spinner_m = Gtk2::SpinButton->new($adjm, 0, 0),
0, my $spinner_s = Gtk2::SpinButton->new($adjs, 0, 0),
),
+ 1, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Timezone")), 'etched_in'),
+ gtkpack__(gtkset_border_width(Gtk2::VBox->new, 5),
+ $label_timezone,
+ $button_time)),
),
),
0, create_okcancel(my $w =
{
cancel_clicked => sub { ugtk2->exit(0) },
ok_clicked => sub {
+ my $need_date = 1;
if ($check_ntp->get_active) {
my $choosed_serv = $combo_ntpserver->entry->get_text;
$choosed_serv =~ s/(\S+)\s*(.*)$/$1/;
@@ -115,20 +117,28 @@ $my_win->{window}->add(gtkpack_(gtkset_border_width(Gtk2::VBox->new, $::isEmbedd
system("service ntpd stop");
#verify that we have a valid hostname (thx sam)
$choosed_serv =~ s/[^-a-zA-Z0-9.]//g;
- system("/usr/sbin/ntpdate", $choosed_serv);
- system("service ntpd start");
+ if (!system("/usr/sbin/ntpdate", $choosed_serv)) {
+ update_time(); #- get the new time before updating the hwclock
+ system("service ntpd start");
+ $need_date = 0
+ } else {
+ warn_dialog(N("Error"), N("Could not synchronize with %s.", $choosed_serv));
+ return
+ }
} else {
if (-e $ntpdlock) {
- system("service ntpd stop");
- system("/sbin/chkconfig --level 35 ntpd off");
- }
- }
- my ($year, $month, $day) = $calendar->get_date;
- $month++;
- my ($hour, $min, $sec) = ($adjh->get_value, $adjm->get_value, $adjs->get_value);
- system("date " .
- join('', map { print_it0($_) } ($month, $day, $hour, $min, $year)) . '.' . print_it0($sec));
- -e '/sbin/hwclock' and system('/sbin/hwclock --systohc');
+ system("service ntpd stop");
+ system("/sbin/chkconfig --level 35 ntpd off");
+ }
+ }
+ if ($need_date) {
+ my ($year, $month, $day) = $calendar->get_date;
+ $month++;
+ my ($hour, $min, $sec) = ($adjh->get_value, $adjm->get_value, $adjs->get_value);
+ system("date " .
+ join('', map { print_it0($_) } ($month, $day, $hour, $min, $year)) . '.' . print_it0($sec));
+ }
+ -e '/sbin/hwclock' and system('/sbin/hwclock --systohc');
system("dcop kicker Panel restart") if $ENV{DESKTOP} eq 'kde';
ugtk2->exit(0);
},
@@ -138,8 +148,6 @@ $my_win->{window}->add(gtkpack_(gtkset_border_width(Gtk2::VBox->new, $::isEmbedd
$its_reset = 1;
$timer = Glib::Timeout->add(120, \&update_time);
Repaint($drawing_area, 1);
- $calendar->select_month($old_month, $old_year);
- $calendar->select_day($old_day);
$button_reset->set_sensitive(0);
$its_reset = 0;
} ]
@@ -191,8 +199,6 @@ $spinner_s->signal_connect(activate => \&spinned);
$spinner_s->signal_connect(scroll_event => \&spinned);
$spinner_s->signal_connect(button_release_event => \&spinned);
-$my_win->{window}->show_all;
-
gtkflush();
my $is24 = $h_old > 12;
@@ -203,6 +209,8 @@ $button_reset->set_sensitive(0);
$timer = Glib::Timeout->add(120, \&update_time);
$drawing_area->show;
+$my_win->{window}->show_all;
+my ($midx, $midy) = ($drawing_area->allocation->width/2, $drawing_area->allocation->height/2);
$my_win->main;
ugtk2->exit(0);
@@ -216,7 +224,7 @@ sub install_ntp() {
$my_win->{window}->set_sensitive(0);
if (warn_dialog(N("Warning"), N("We need to install ntp package\n to enable Network Time Protocol
-Do you want to install ntp ?"))) {
+Do you want to install ntp?"))) {
$in->do_pkgs->install('ntp');
} else {
ntp_widget_state(0);
@@ -228,6 +236,13 @@ sub get_server() {
[ map { "$_ ($servs->{$_})" } sort keys %$servs ]
}
sub update_time() {
+ my (undef, undef, undef, $mday, $mon, $year) = localtime(time());
+ $year += 1900;
+ my $old_its_reset = $its_reset;
+ $its_reset = 1;
+ $calendar->select_day($mday);
+ $calendar->select_month($mon, $year);
+ $its_reset = $old_its_reset;
Repaint($drawing_area, 1);
};
@@ -308,7 +323,7 @@ sub time_to_rad {
sub Repaint {
my ($drawing_area, $o_update_time) = @_;
- my ($sec, $min, $hour) = localtime(time());
+ my ($sec,$min,$hour) = localtime(time());
time_to_rad($sec, $min, $hour) if $o_update_time;
my ($width, $height) = ($drawing_area->allocation->width, $drawing_area->allocation->height);
my $dRadians_hour_real = $dRadians_hour + $dRadians_min / 12;
@@ -352,7 +367,7 @@ sub DrawHour {
my ($pixmap, $gc, $midx, $midy, $dRadians, $dec) = @_;
$pixmap->draw_polygon($gc, 1, $midx+$dec - 5/100 * $radius * sin($dRadians), $midy+$dec + 5/100 * $radius * cos($dRadians),
$midx+$dec - 5/100 * $radius * sin($dRadians+$PI/2), $midy+$dec + 5/100 * $radius * cos($dRadians+$PI/2),
- $midx+$dec + 7/10 * $radius * sin($dRadians), $midy+$dec - 7/10 * $radius * cos($dRadians),
+ $midx+$dec + 6/10 * $radius * sin($dRadians), $midy+$dec - 6/10 * $radius * cos($dRadians),
$midx+$dec + 5/100 * $radius * sin($dRadians+$PI/2), $midy+$dec - 5/100 * $radius * cos($dRadians+$PI/2)
);
}