Using Glib Introspection with GooCanvas-2.0, make a Polyline



Hi,

I'm trying to get a handle on Goject Introspection
with the GooCanvas.

I've managed to get the basic canvas up, and 
an ellipse, but the polyline eludes me.

In Gtk2, you could just pass in an arrayref of
points, but the Gtk3 version expects a 
GooCanvasPoints object.

I can't figure it out. The following code runs error free,
but the polyline does not appear.

The polyline c docs are at:
https://developer.gnome.org/goocanvas/unstable/GooCanvasPolyline.html

Any clues?

Thanks,
zentara

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

Glib::Object::Introspection->setup(basename => 'GooCanvas', 
                      version => '2.0', package => 'Goo');


my $window = Gtk3::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { Gtk2->main_quit; });
$window->set_size_request(640, 600);
$window->set_title("Gtk3 GooCanvas with Perl Gobject Introspection");
$window->signal_connect(destroy => sub { Gtk3->main_quit });

my $swin = Gtk3::ScrolledWindow->new;
$swin->set_shadow_type('in');
$window->add($swin);

my $canvas = Goo::Canvas->new; # Gobject Introspection of Gtk3 Goo version
$canvas->set_size_request(800, 650);
$canvas->set_bounds(0, 0, 1000, 1000);
$swin->add($canvas);
my $root = $canvas->get_root_item();

# first point set
my $pts_ref = [50,50,180,120,90,100,50,50]; 

my $points = Goo::CanvasPoints->new(
             $pts_ref, 
             );

my $line = Goo::CanvasPolyline->new(
       'parent' => $root,
       'close-path' => 0,
       'points' => $points, #in Gtk2 could just use $pts_ref
       'stroke-color' => 'black',
       'line-width' => 3,
    );


my $ellipse = Goo::CanvasEllipse->new(
       'parent' => $root,
       'center-x' => 20,  
       'center-y' => 20,  
       'width'  =>  +60,
       'height' =>  +60,  
       'stroke-color' => 'goldenrod',
       'line-width' => 8,
       'fill-color-rgba' => 0x3cb37180,
    );


$root->translate(200,200);

$window->show_all();
Gtk3->main;
__END__


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