Gtk2-Ex-ICal-Recur
view release on metacpan or search on metacpan
lib/Gtk2/Ex/ICal/Recur.pm view on Meta::CPAN
use Gtk2::Ex::CalendarButton;
###########################################################
# There are four public methods. The rest are all private #
###########################################################
sub new {
my ($class) = @_;
my $self = {};
$self->{freqspinbutton} = Gtk2::SpinButton->new_with_range(1,100,1);
$self->{freqcombobox} = Gtk2::ComboBox->new_text();
$self->{recurrencepatterntable} = Gtk2::Table->new(1,1,FALSE);
$self->{recurbox}->{hbox} = undef;
$self->{recurbox}->{buttons} = undef;
$self->{freqchoices} = [
{ 'label' => 'Year(s)' , 'code' => 'yearly' },
{ 'label' => 'Month(s)', 'code' => 'monthly' },
{ 'label' => 'Week(s)' , 'code' => 'weekly' },
{ 'label' => 'Day(s)' , 'code' => 'daily' },
];
$self->{exceptionslist} = undef;
lib/Gtk2/Ex/ICal/Recur.pm view on Meta::CPAN
sub set_model {
my ($self, $model) = @_;
$self->{model} = $model;
$self->{recurbox}->{hbox} = undef;
my $temphash = $self->controller(0, 0);
$self->{recurbox}->{hbox}->[0]->[0] = $self->create_box(0,0,$temphash);
$self->packbox();
$self->{freqspinbutton}->set_value($model->{interval});
my $mapped = { 'yearly' => 0, 'monthly' => 1, 'weekly' => 2, 'daily' => 3 };
$self->{freqcombobox}->set_active($mapped->{$model->{freq}});
if ($model->{freq} eq 'yearly') {
if ($model->{bymonth}) {
$self->set_month_of_the_year($model, 0);
if ($model->{bymonthday}) {
$self->set_month_day_by_day($model, 1);
} elsif ($model->{byday}) {
$self->set_month_day_by_week($model, 1);
}
} elsif ($model->{byyearday}) {
$self->set_day_of_the_year($model, 0);
lib/Gtk2/Ex/ICal/Recur.pm view on Meta::CPAN
$datehash->{year},
$datehash->{month},
$datehash->{day},
];
return $datearray;
}
sub get_model {
my ($self) = @_;
my $model;
my $freqcombochoice = $self->{freqchoices}->[$self->{freqcombobox}->get_active()]->{'code'};
$model->{freq} = $freqcombochoice;
$model->{interval} = $self->{freqspinbutton}->get_value;
foreach my $level (@{$self->{recurbox}->{buttons}}) {
my $i = 0;
foreach my $count (@$level) {
my $type = $count->{type};
my $code = $count->{code};
$model->{$type}->[$i++] = $code;
}
}
lib/Gtk2/Ex/ICal/Recur.pm view on Meta::CPAN
'Oct',
'Nov',
'Dec',
];
}
sub get_widget {
my ($self) = @_;
foreach my $choice (@{$self->{freqchoices}}) {
$self->{freqcombobox}->append_text($choice->{'label'});
}
my $freqhbox = Gtk2::HBox->new(FALSE);
$freqhbox->pack_start(Gtk2::Label->new('Occurs every'), FALSE, FALSE, 0);
$freqhbox->pack_start($self->{freqspinbutton}, FALSE, FALSE, 0);
$freqhbox->pack_start($self->{freqcombobox}, FALSE, FALSE, 0);
$self->{freqcombobox}->signal_connect('changed' =>
sub {
$self->{recurbox}->{hbox} = undef;
$self->{recurbox}->{buttons} = undef;
my $temphash = $self->controller(0, 0);
$self->{recurbox}->{hbox}->[0]->[0] = $self->create_box(0,0,$temphash);
$self->packbox();
}
);
my $scroll = Gtk2::ScrolledWindow->new;
$scroll->add_with_viewport($self->{recurrencepatterntable});
lib/Gtk2/Ex/ICal/Recur.pm view on Meta::CPAN
$self->nextbuttonclicked($level, $i);
}
}
}
sub controller {
my ($self, $level, $count) = @_;
my $temphash = undef;
if ($level == 0) {
my $freqcombochoice = $self->{freqchoices}->[$self->{freqcombobox}->get_active()]->{'code'};
if ($freqcombochoice eq 'yearly') {
$temphash = $self->month_or_day_of_the_year($level,$count);
} elsif ($freqcombochoice eq 'monthly') {
$temphash = $self->day_of_the_month($level,$count);
} elsif ($freqcombochoice eq 'weekly') {
$temphash = $self->day_of_the_week($level,$count);
} elsif ($freqcombochoice eq 'daily') {
}
} elsif ($level == 1) {
my $parent = $self->{recurbox}->{buttons}->[$level-1]->[0]->{type};
( run in 2.717 seconds using v1.01-cache-2.11-cpan-8dfa8b56332 )