Gtk2-Ex-FormFactory

 view release on metacpan or  search on metacpan

lib/Gtk2/Ex/FormFactory.pm  view on Meta::CPAN


sub cleanup {
	my $self = shift;
	
	$self->SUPER::cleanup(@_);
	
	$self->set_gtk_size_groups({});
	$self->set_widgets_by_name({});

	1;
}

sub open {
	my $self = shift;
	my %par = @_;
	my ($hide) = $par{'hide'};

	#-- First build all widgets as implemented in the Widget class
	$self->build();
	
	#-- Now show all widgets, if we shouldn't keep the hided
	$self->show if not $hide;
	
	1;
}

sub build {
	my $self = shift;
	
        return if $self->get_built;
        
	#-- first register all widgets of this FormFactory
	#-- to resolve cross references between Widgets
	#-- during building.
	$self->register_all_widgets($self);
	
	#-- Now call Container's build
	$self->SUPER::build();
	
	1;
}

sub show {
	my $self = shift;
	
	#-- Show all widgets
	foreach my $child ( @{$self->get_content} ) {
		$child->get_gtk_parent_widget->show_all;
	}
	
	#-- And finally connect the changed signals - this need to be
	#-- done *after* showing the widgets. For containers ->show()
	#-- could trigger updates which cause object updates. Since
	#-- ->update() isn't called yet, this would invalidate the 
	#-- object's state.
	$self->connect_signals;
	
	1;
}

sub update {
	my $self = shift;
	$self->update_all;
}

sub ok {
	my $self = shift;

	$self->apply;
	$self->close;
	
	1;
}

sub apply {
	my $self = shift;

	if ( $self->get_sync ) {
		$self->commit_proxy_buffers_all;
	} else {
		$self->apply_changes_all;
	}

	1;
}

sub cancel {
	my $self = shift;
	
	$self->discard_proxy_buffers_all if $self->get_sync;
	$self->close;
	
	1;
}

sub close {
	my $self = shift;

	$_->get_gtk_parent_widget->destroy for @{$self->get_content};

	$self->cleanup;

	1;
}

sub register_all_widgets {
	my $self = shift;
	my ($widget) = @_;
	
	if ( $widget->isa("Gtk2::Ex::FormFactory::Container") ) {
		$self->register_widget($widget);
		foreach my $child ( @{$widget->get_content} ) {
			$self->register_all_widgets($child);
		}
	} else {
		$self->register_widget($widget);
	}
	
	1;
}



( run in 1.173 second using v1.01-cache-2.11-cpan-39bf76dae61 )