Re: subclassed anti-alias canvas, and disappearing text



On Fri, 14 Apr 2006 16:06:15 -0400
zentara <zentara1 sbcglobal net> wrote:

I've made the code text code, the same as in the Gnome2::Canvas demo.
It works when I use the plain subclassed canvas, but when I use
aa=>1 , I get a slew of errors

Pango-CRITICAL **: pango_renderer_draw_layout: assertion `PANGO_IS_RENDERER (renderer)' failed at 
./zz->Gtk-CanvasTest line 215.

I remember reading a post by muppet, about needing a special syntax
when making a subclassed anti-alias canvas, where you need to use
->new(aa=>1)  rather than  ->new_aa.  So I'm thinking that this may be a similar 
problem.


Hello again, I found an answer by simplifying the example to it's simplest
form. 

It seems that when you you sub-class an anti-alias canvas, you cannot do
anything with text until the INIT_INSTANCE is finished. 

In the following example, if you run it , as shown, with no anti-aliasing,
the text appears behind the ellipse. 

If you turn on aa=>1, the text disappears, and an error is issued
 Pango-CRITICAL **: pango_renderer_draw_layout: assertion `PANGO_IS_RENDERER
(renderer)' failed at ./canvas-as-subclassed-objects2a line 62.

If you then uncomment the GLib::Timeout statement, in the INIT_INSTANCE sub,
to let INIT_INSTANCE finish before trying to write the text, it works. 

Now, muppet reported to me privately, that he was not seeing this problem,
on his versions. I'm using the latest announced versions of everything.
c................
glib-2.10.2
gtk+-2.8.17
pango-1.12.1
libgnomecanvas-2.14.0


Perl.........
Glib-1.120 
Gnome2-Canvas-1.002
Gtk2-1.121

Anyways, this brings up an interesting question for me. Is using the
timer hack the only way of launching something from INIT_INSTANCE?

I have a more complex package, where I set a bunch of non-canvas
pspecs, and I need the timer from INIT_INSTANCE to launch a sub
from INIT_INSTANCE on package startup, and have the new values set
properly. If I don't wait for the INIT_INSTANCE to finish first, my extra settings
don't get seen on the first run.  This affects both the aa and non-aa canvas.

Thanks.

###############################################################
#!/usr/bin/perl

package can;
use strict;
use Gtk2;
use Gnome2::Canvas;

use Glib::Object::Subclass
    Gnome2::Canvas::,
    properties => [ ]
    ;

sub INIT_INSTANCE
{
    my $self = shift(@_);

    print "INIT_INSTANCE\n";

#    Glib::Timeout->add (1, sub {
       my $text = Gnome2::Canvas::Item->new($self->root, 'Gnome2::Canvas::Text',
                     font=>'Arial Bold 18',
                     fill_color=>'black',
                     x=>20, y=>20,
                     text=>'hello',
                     );

#           return 0;
#          });

}
1;

##########################################################
package main;
use strict;
use Gtk2 '-init';
use Gnome2::Canvas;

my $window = Gtk2::Window->new();

my $scroller = Gtk2::ScrolledWindow->new();

#my $canvas = can->new( aa=>1 );
my $canvas = can->new();

$scroller->add($canvas);

$window->add($scroller);

my $root = $canvas->root();

my $ellipse = 
Gnome2::Canvas::Item->new($root,'Gnome2::Canvas::Ellipse',
                 x1=>10,y1=>10,x2=>40,y2=>40,
                 fill_color=>'red');

$window->signal_connect('destroy'=>sub { Gtk2->main_quit(); } );

$window->show_all();

Gtk2->main();

__END__








-- 
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]