Net-ICal

 view release on metacpan or  search on metacpan

examples/gtk_todo.pl  view on Meta::CPAN

	$dte_dtstart->signal_connect ("date_changed", \&changeTodo, "dtstart", $todo);
	$dte_dtstart->signal_connect ("time_changed", \&changeTodo, "dtstart", $todo);


	my $label_dtstart = new Gtk::Label ("Start Date");
	

	# a close button. 
	my $button_close = new Gtk::Button("Close");
	$button_close->signal_connect("clicked", \&saveTodo, $todo, $row, $clist, $dialog);

	# pack everything together in order.
	$dialog->vbox->pack_start($label_summary, $true, $true, 0);
	$dialog->vbox->pack_start($entry_summary, $true, $true, 0);
	$dialog->vbox->pack_start($label_dtstart, $true, $true, 0);
	$dialog->vbox->pack_start($dte_dtstart, $true, $true, 0);
	
	$dialog->action_area->pack_start($button_close, $true, $true, 5);


	# display the widgets.
	$entry_summary->show();
	$label_summary->show();
	$dte_dtstart->show();
	$label_dtstart->show();
	
	$button_close->show();

	$dialog->show();
}


### callback whenever we change a value in the TodoDetail box. 
sub changeTodo {
	#use Data::Dumper; print Dumper $_[1];

	my ($entry, $item, $todo) = @_;
	# $item is the name of a field in the todo. 

	# TODO: document this usage a bit better. all the properties of
	# the todos are actually methods. 
	
	if ($item eq "dtstart") {
		
		# the DateEdit widget returns a number of seconds since 1/1/1970.
		# onvert this to an array so we can make it a Net::ICal::Time.
		my @parsed_date = gmtime($entry->get_date());
		$todo->dtstart( new Net::ICal::Time ( @parsed_date ) );

	} else {
		$todo->$item( $entry->get_text() );
	}	

	#print "set temp value for  todo summary to " . $todo->summary . "\n";
}



### callback to save our changes back to the main calendar and the main window. 
sub saveTodo {
	my ($entry, $todo, $row, $clist, $popup) = @_;
	
	$cal->todos->[$row] = $todo;
	$clist->set_text($row, 0, $todo->summary);
	$clist->set_text($row, 1, scalar $todo->dtstart->as_localtime );
	$popup->destroy();
}



( run in 1.638 second using v1.01-cache-2.11-cpan-364913b4093 )