package ZConf::Cron::GUI;

use warnings;
use strict;
use ZConf::Cron;
use ZConf::GUI;
use base 'Error::Helper';

=head1 NAME

ZConf::Cron::GUI - Implements a GUI for ZConf::Cron.

=head1 VERSION

Version 0.1.0


our $VERSION = '0.1.0';


    use ZConf::Cron::GUI;

    my $zcc=$ZConf::Cron->new;
    my $zccg=ZConf::Cron::GUI->new({zccron=>$zcc});

=head1 METHODS

=head2 new

This initializes it.

One arguement is taken and that is a hash value.

=head3 hash values

=head4 zccron

This is a ZConf::Cron object to use. If it is not specified,
a new one will be created.

=head4 zcgui

This is the ZConf::GUI object. If it is not passed, a new one will be created.


sub new{
	my %args;
		%args= %{$_[1]};

	my $self={error=>undef, errorString=>undef};
	bless $self;

	if (!defined($args{zccron})) {
	}else {

	#handles it if initializing ZConf::Runner failed
	if ($self->{zcc}->error) {
		my $errorstring=$self->{zcc}->errorString;
		my $error='Initializing ZConf::Cron failed. error="'.$self->{zcc}->error
		          .'" errorString="'.$self->{zcc}->errorString.'"';
		return $self;		


	if (!defined($args{zcgui})) {
		#initializes the GUI
		if ($self->{gui}->error) {
			my $errorstring=$self->{gui}->errorString;
			my $error='Initializing ZConf::GUI failed. error="'.$self->{gui}->error
				.'" errorString="'.$self->{gui}->errorString.'"';
			return $self;
	}else {


	my @preferred=$self->{gui}->which('ZConf::Cron');

	if (!defined($preferred[0])) {
		$self->{errorString}='No backends located';

	my $toeval='use ZConf::Cron::GUI::'.$preferred[0].';'."\n".
			   '->new({zconf=>$self->{zconf}, useX=>$self->{useX},'.
			   'zcgui=>$self->{gui}, zccron=>$self->{zcc}}); return 1';

	my $er=eval($toeval);
	return $self;

=head2 crontab

This dialog allows crontabs to be edited.

       print "Error!\n";


sub crontab{
	my $self=$_[0];

	if ( ! $self->errorblank ){
		return undef;

	my $returned=$self->{be}->crontab;
	if ($self->{be}->error) {
		$self->{errorString}='Backend errored. error="'.$self->{be}->error.
		                     '" errorString="'.$self->{be}->errorString.'"';

	return $returned;

=head2 dialogs

This returns the available dailogs.


sub dialogs{
	return ('crontab');

=head2 windows

This returns a list of available windows.


sub windows{
	return ();

=head1 DIALOGS


=head1 WINDOWS

At this time, no windows are supported.


=head2 1

This means ZConf errored.

=head2 2

Initializing ZConf::GUI failed.

=head2 3

Initializing ZConf::Cron failed.

=head2 4

Failed to initailize the primary backend.

=head2 5

Backend errored.

=head1 AUTHOR

Zane C. Bowers-Hadley, C<< <vvelox at> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-zconf-runner at>, or through
the web interface at L<>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc ZConf::Cron::GUI

You can also look for information at:

=over 4

=item * RT: CPAN's request tracker


=item * AnnoCPAN: Annotated CPAN documentation


=item * CPAN Ratings


=item * Search CPAN





Copyright 2012 Zane C. Bowers-Hadley, all rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.


1; # End of ZConf::Cron::GUI