diff options
-rwxr-xr-x | clock.pl | 118 |
1 files changed, 59 insertions, 59 deletions
@@ -22,26 +22,17 @@ my $type; my $timer; my ($midx, $midy); my $first = 1; -my $is24; -my $h_old; -my ($old_year, $old_month, $old_day); my $its_reset = 0; my $my_win = ugtk2->new('print_launcher'); $my_win->{rwindow}->set_title(N("DrakClock")) unless $::isEmbedded; -$my_win->{window}->add(my $vbox = Gtk2::VBox->new(0,0)); $my_win->{window}->signal_connect(delete_event => sub { ugtk2->exit(0) }); -my $hbox = Gtk2::HBox->new(0,0); -$vbox->pack_start($hbox, 1, 1, 0); -my $vbox1 = Gtk2::VBox->new(0,0); -$hbox->pack_start($vbox1, 1, 1, 0); + my $calendar = Gtk2::Calendar->new; -$vbox1->pack_start($calendar, 1, 1, 0); $calendar->signal_connect($_ => \&cal_changed) foreach 'month-changed', 'day-selected', 'day-selected-double-click', 'prev-month', 'next-month', 'prev-year', 'next-year'; my $button_time = Gtk2::Button->new(N("Time Zone")); -$vbox1->pack_start($button_time, 0, 1, 10); $button_time->signal_connect(clicked => sub { local $::isEmbedded = 0; # to prevent sub window embedding $in->{timezone} = {}; @@ -55,12 +46,61 @@ $button_time->signal_connect(clicked => sub { $in->{timezone}{timezone} = $timezone; } }); -my $vbox2 = Gtk2::VBox->new(0,0); -my $pressed; -$hbox->pack_start($vbox2, 1, 1, 0); + my $drawing_area = Gtk2::DrawingArea->new; + +my $adj_h = Gtk2::Adjustment->new(0.0, 0.0, 23.0, 1.0, 5.0, 0.0); +my $adj_m = Gtk2::Adjustment->new(0.0, 0.0, 59.0, 1.0, 5.0, 0.0); +my $adj_s = Gtk2::Adjustment->new(0.0, 0.0, 59.0, 1.0, 5.0, 0.0); + +my $button_reset; + +my (undef, undef, $h_old, $old_day, $old_month, $old_year) = localtime(time()); + +$my_win->{window}->add(gtkpack_(Gtk2::VBox->new(0,0), + 1, gtkpack_(Gtk2::HBox->new(0,0), + 1, gtkpack_(Gtk2::VBox->new(0,0), + 1, $calendar, + 0, $button_time, + ), + 1, gtkpack_(Gtk2::VBox->new(0,0), + 1, $drawing_area, + 0, gtkpack_(Gtk2::HBox->new(1,0), + 0, Gtk2::HBox->new(1,0), + 0, my $spinner_h = Gtk2::SpinButton->new($adj_h, 0, 0), + 0, my $spinner_m = Gtk2::SpinButton->new($adj_m, 0, 0), + 0, my $spinner_s = Gtk2::SpinButton->new($adj_s, 0, 0), + ), + ), + ), + 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'end'), + gtksignal_connect(Gtk2::Button->new(N("OK")), + clicked => sub { + my ($year, $month, $day) = $calendar->get_date; + $month++; + my ($hour, $min, $sec) = ($adj_h->get_value, $adj_m->get_value, $adj_s->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); + }), + gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => sub { ugtk2->exit(0) }), + $button_reset = gtksignal_connect(Gtk2::Button->new(N("Reset")), clicked => sub { + $its_reset = 1; + $timer = Gtk2->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; + }) + ) + ) + ); + +my $pressed; $drawing_area->size(300,300); -$vbox2->pack_start($drawing_area, 1, 1, 0); $drawing_area->set_events([ 'button_press_mask', 'button_release_mask', "pointer_motion_mask" ]); $drawing_area->signal_connect(expose_event => \&expose_event); $drawing_area->signal_connect(realize => \&configure_event); @@ -68,71 +108,31 @@ $drawing_area->signal_connect(button_press_event => sub { $pressed = 1 }); $drawing_area->signal_connect(button_release_event => sub { $first = 1; $pressed = 0 }); $drawing_area->signal_connect(motion_notify_event => \&motion_event); -my $hbox11 = Gtk2::HBox->new(1,0); -$vbox2->pack_start($hbox11, 0, 0, 10); -my $hbox2 = Gtk2::HBox->new(1,0); -$hbox11->pack_start($hbox2, 0, 0, 0); -my $adj_h = Gtk2::Adjustment->new(0.0, 0.0, 23.0, 1.0, 5.0, 0.0); -my $spinner_h = Gtk2::SpinButton->new($adj_h, 0, 0); -$hbox2->pack_start($spinner_h, 0, 0, 0); $spinner_h->set_wrap(1); $spinner_h->signal_connect(activate => \&spinned); $spinner_h->signal_connect(button_release_event => \&spinned); $spinner_h->signal_connect(changed => \&changed); -my $adj_m = Gtk2::Adjustment->new(0.0, 0.0, 59.0, 1.0, 5.0, 0.0); -my $spinner_m = Gtk2::SpinButton->new($adj_m, 0, 0); -$hbox2->pack_start($spinner_m, 0, 0, 0); + $spinner_m->set_wrap(1); $spinner_m->signal_connect(activate => \&spinned); $spinner_m->signal_connect(button_release_event => \&spinned); -my $adj_s = Gtk2::Adjustment->new(0.0, 0.0, 59.0, 1.0, 5.0, 0.0); -my $spinner_s = Gtk2::SpinButton->new($adj_s, 0, 0); -$hbox2->pack_start($spinner_s, 0, 0, 0); + $spinner_s->set_wrap(1); $spinner_s->signal_connect(activate => \&spinned); $spinner_s->signal_connect(button_release_event => \&spinned); -my $bbox = Gtk2::HButtonBox->new; -$bbox->set_layout('end'); -$vbox->pack_start($bbox, 0, 0, 5); -$bbox->add(gtksignal_connect(Gtk2::Button->new(N("OK")), - clicked => sub { - my ($year, $month, $day) = $calendar->get_date; - $month++; - my ($hour, $min, $sec) = ($adj_h->get_value, $adj_m->get_value, $adj_s->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); - })); -$bbox->add(gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => sub { ugtk2->exit(0) })); -my $button_reset; -$button_reset = gtksignal_connect(Gtk2::Button->new(N("Reset")), clicked => sub { - $its_reset = 1; - $timer = Gtk2->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; - }); - -$bbox->add($button_reset); - $my_win->{window}->show_all; gtkflush(); -$calendar->realize; -(undef, undef, $h_old, $old_day, $old_month, $old_year) = localtime(time()); -$is24 = $h_old > 12; + +my $is24 = $h_old > 12; $old_year += 1900; $calendar->select_month($old_month, $old_year); $calendar->select_day($old_day); $button_reset->set_sensitive(0); $timer = Gtk2->timeout_add(120, \&update_time); -#$drawing_area->show; +$drawing_area->show; $my_win->main; ugtk2->exit(0); |