background-stipple on TextBuffer



Hi, Is it possible to set a background-stipple as a
background on a text widget?
I can set this stipple up with no warnings, but it dosn't
seem to have any visible effect. The red tag seems to
work OK, but the background-stipple dosn't work.

Does it have something to do with the $colormap setup?

#!/usr/bin/perl
use warnings;
use strict;
use Gtk2 -init;

# Copy the entire file into a string (str)
my $str;
my $file = shift || $0;
open( TEST, "< $file" ) or die "Cannot open test.txt\n";
while (<TEST>) { $str .= $_;}
close TEST;
 
my $window = Gtk2::Window->new;

# a simple xpm for stipple
my @z_xpm = (
'20 3 2 1',
'       c None',
'+      c #1A1A1A',
'+ + + + + + + + + + ',
'+ + + + + + + + + + ',
'+ + + + + + + + + + ',);

#my $colormap = Gtk2::Gdk::Colormap->get_system;
my $colormap = $window->get_default_colormap;

my $pixmap =  Gtk2::Gdk::Pixmap->colormap_create_from_xpm_d 
                    (undef, $colormap, undef, @z_xpm );

# Create a textbuffer to contain that string
my $textbuffer = Gtk2::TextBuffer->new();
$textbuffer->set_text($str);

my $zmap = $textbuffer->create_tag('zmap', 'background-stipple' => $pixmap  );
my $rmap = $textbuffer->create_tag('rmap', 'background' => 'red'  );

$textbuffer->insert_with_tags_by_name 
     ($textbuffer->get_start_iter,"\nYADDA YADDA\n",'rmap');
$textbuffer->insert_with_tags_by_name 
    ($textbuffer->get_start_iter,"No stipple here\nYADDA\nYADDA\n",'zmap');

# Create a textview using that textbuffer
my $textview = Gtk2::TextView->new_with_buffer($textbuffer);

# Add the textview to a scrolledwindow
my $scrolledwindow = Gtk2::ScrolledWindow->new( undef, undef );
$scrolledwindow->add($textview);

$window->signal_connect( destroy => sub { Gtk2->main_quit; } );
$window->add($scrolledwindow);
$window->set_default_size( 500, 400 );
$window->show_all;
Gtk2->main;
__END__
########################################################################

Thanks


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]