XML-STX

 view release on metacpan or  search on metacpan

stxview.pl  view on Meta::CPAN


    my $subtree = new Gtk::Tree();

    $item->remove_subtree();
    $item->set_subtree( $subtree );
    $item->signal_connect( 'expand', \&expandTree, $subtree );
}


# Called whenever an item is clicked
sub selectItem {
    my ( $widget, $o ) = @_;

    $list->clear();
    
    if (ref $o eq 'XML::STX::Stylesheet') {
	$list->append('STYLESHEET', '');
	my @name = split("/", $o->{URI});
	$list->append('- principal module file:', $name[-1]);

	$list->append('', '');
	$list->append('Stylesheet options', '');
	$list->append('- stxpath-default-namespace:', 
		      $o->{Options}->{'stxpath-default-namespace'}->[-1]);
	$list->append('- output-encoding:',
		      $o->{Options}->{'output-encoding'});

	_groupProperties($o->{dGroup}, 'Default group options');

    } elsif (ref $o eq 'XML::STX::Group') {
	$list->append('GROUP', '');
	$list->append('- name:', exists $o->{name} ? $o->{name} : '#anonymous');

	_groupProperties($o, 'Group options');

    } elsif (ref $o eq 'XML::STX::Template' && exists $o->{name}) {
	$list->append('PROCEDURE', '');
	$list->append('- name:', $o->{name});

	_templateProperties($o);

    } else {
	$list->append('TEMPLATE', '');
	$list->append('- match pattern:', $o->{pattern});
	$list->append('- priority:', 
		      $o->{eff_p} == 10 ? join('|',@{$o->{priority}}) : $o->{eff_p});

	_templateProperties($o);
    }

}


sub _groupProperties {
    my ($g, $label) = @_;

    $list->append('', '');
    $list->append($label, '');
    $list->append('- pass-through:', 
		  $pass_through->{$g->{Options}->{'pass-through'}});
    $list->append('- recognize-cdata:', 
		  $yn->{$g->{Options}->{'recognize-cdata'}});
    $list->append('- strip-space:', 
		  $yn->{$g->{Options}->{'strip-space'}});
    
    $list->append('', '');
    $list->append('Visible templates', '');
    
    my @pc1 = sort {$a <=> $b} map($_->{tid}, @{$g->{pc1}}, @{$g->{pc1A}});
    $list->append('- precedence category 1:', join(',', @pc1));
    my @pc2 = sort {$a <=> $b} map($_->{tid}, @{$g->{pc2}}, @{$g->{pc2A}});
    $list->append('- precedence category 2:', join(',', @pc2));
    my @pc3 = sort {$a <=> $b} map($_->{tid}, @{$g->{pc3}}, @{$g->{pc3A}});
    $list->append('- precedence category 3:', join(',', @pc3));

    $list->append('', '');
    $list->append('Visible procedures', '');
    
    @pc1 = sort keys %{$g->{pc1P}};
    $list->append('- precedence category 1:', join(',', @pc1));
    @pc2 = sort keys %{$g->{pc2P}};
    $list->append('- precedence category 2:', join(',', @pc2));
    @pc3 = sort keys %{$g->{pc3P}};
    $list->append('- precedence category 3:', join(',', @pc3));

    $list->append('', '');
    $list->append('Group variables and buffers', '');
    
    my @v = map('$' . $_, sort keys %{$g->{vars}->[-1]});
    $list->append('- variables:', join(',', @v));
    my @b = sort keys %{$g->{bufs}->[-1]};
    $list->append('- buffers:', join(',', @b));
}


sub _templateProperties {
    my $t = shift;

    $list->append('', '');
    $list->append('Properties', '');
    $list->append('- visibility:', $visibility->{$t->{visibility}});
    $list->append('- public:', $yn->{$t->{public}});
    $list->append('- new scope:', $yn->{$t->{'new-scope'}});
}


# Open a stylesheet file
sub openSheet {

    # Create a new file selection widget
    my $dialog = new Gtk::FileSelection( "File Selection" );
    $dialog->signal_connect( "destroy", sub { $dialog->destroy(); } );
    $dialog->hide_fileop_buttons();

    # Connect the ok_button to file_ok_sel function
    $dialog->ok_button->signal_connect( "clicked", \&fileOK, $dialog );

    # Connect the cancel_button to destroy the widget
    $dialog->cancel_button->signal_connect( "clicked",
					    sub { $dialog->destroy(); } );

    $dialog->show();



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