package Padre::Plugin::My;

use 5.008;
use strict;
use warnings;
use Padre::Config::Constants qw( $PADRE_CONFIG_DIR );
use Padre::Wx                  ();
use Padre::Plugin              ();
use Padre;
use Padre::Plugin::Todo::UI;

our $VERSION = '0.29';
use base 'Padre::Plugin';

#####################################################################
# Padre::Plugin Methods

sub padre_interfaces {
	'Padre::Plugin' => 0.24
}

sub plugin_name {
	'Todo';
}

sub menu_plugins_simple {
	my $self = shift;
	return $self->plugin_name => [
		'About' => sub { $self->show_about },
		'Show'  => sub { $self->show_todo },
		# 'Another Menu Entry' => sub { $self->about },
		# 'A Sub-Menu...' => [
		#     'Sub-Menu Entry' => sub { $self->about },
		# ],
	];
}





#####################################################################
# Custom Methods

sub show_about {
	my $self = shift;

	# Locate this plugin
	my $path = File::Spec->catfile(
		$PADRE_CONFIG_DIR,
		qw{ plugins Padre Plugin My.pm }
	);

	# Generate the About dialog
	my $about = Wx::AboutDialogInfo->new;
	$about->SetName("Todo");
	$about->SetDescription( <<"END_MESSAGE" );
Dynamic "To-do" list for Padre
END_MESSAGE

	# Show the About dialog
	Wx::AboutBox( $about );

	return;
}

# XXX This should go into a proper show/hide function
sub show_todo {
	my ($self,$show) = shift;
	$show = 1;
	my $main = Padre->ide->wx->main;
	#$main->right->hide( $main->{todo} );
	if ($main->{todo}) {
		$main->right->hide( $main->{todo} );
	}
	if ($show) {
		#if (! $main->{todo}) {
			$main->{todo} = Padre::Plugin::Todo::UI->new($main);
		#};
		$main->right->show( $main->{todo} );
		$main->{todo}->refresh($main->current);
	} else {
		if ($main->{todo}) {
			$main->right->hide( $main->{todo} );
		}
	};
}

1;

# Copyright 2008-2009 The Padre development team as listed in Padre.pm.
# LICENSE
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl 5 itself.
