# Gnomecanvas2 CanvasPolygon error in ruby 1.9

**URL:** <https://www.ruby-forum.com/t/gnomecanvas2-canvaspolygon-error-in-ruby-1-9/224274>\
**Category:** Ruby-Gnome 2\
**Created:** [November 6, 2012, 12:37pm UTC](https://www.ruby-forum.com/t/gnomecanvas2-canvaspolygon-error-in-ruby-1-9/224274 "2012-11-06T12:37:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [November 6, 2012, 12:37pm UTC](https://www.ruby-forum.com/t/gnomecanvas2-canvaspolygon-error-in-ruby-1-9/224274/1 "2012-11-06T12:37:55Z")

</div>

Hi,

i am stuck with a weird error with gnomecanvas please see the example  
below (I know it’s deprecated, but goocanvas binding is missing  
methods).  
The code is working well with ruby 1.8 but in ruby 1.9 i got the error:

test.rb:18:in `set_property': wrong argument type Array (expected Struct) (TypeError) from test.rb:18:in`initialize’  
from test.rb:18:in `new' from test.rb:18:in`’

any idea how i can bypass that ?

thanks,  
david

####################################################################################

#!/usr/bin/ruby

require ‘gtk2’  
require ‘gnomecanvas2’

Gtk.init  
w = Gtk::Window.new  
canvas = Gnome::Canvas.new(true)  
w.add canvas

group = Gnome::CanvasGroup.new(canvas.root,{:x =\> 10.0,:y =\> 10.0})

points = [[20.0, 0.0], [0.0, 20.0], [20.0, 40.0], [40.0, 20.0]]

b= {:points =\> points, :fill\_color\_rgba =\> 0xff000080, :outline\_color  
=\> “black”}  
p b.class

#below is the line where the error occurs  
cp = Gnome::CanvasPolygon.new(group, b)  
w.show\_all

Gtk.main

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [November 6, 2012, 10:37pm UTC](https://www.ruby-forum.com/t/gnomecanvas2-canvaspolygon-error-in-ruby-1-9/224274/2 "2012-11-06T22:37:47Z")

</div>

I understand about needing gnomecanvas. I won’t be able to be able to  
use goocanvas for some time.

I’ll see if I can help out here. Which version of the bindings are you  
using.  
I’m running  
Ruby 1.9.2p320  
Gtk::BINDING\_VERSION [1, 1, 3]  
Gtk::VERSION [2, 10, 4]

I build my own Ruby build W/ Ruby/Gnome bindings. Since gnomecanvas, and  
a few others are not in the most recent release’s, I just grab them out  
of the last build that had them, 0.95.

I have a build script like this

set gnomeTarget = ruby-gnome2-all-1.1.3

rm -rf $gnomeTarget  
tar xf $gnomeTarget.tar.gz

rm -rf ruby-gnome2-all-0.90.5  
tar xf ruby-gnome2-all-0.90.5.tar.gz

#add some old gnome modules in  
cp -rp ruby-gnome2-all-0.90.5/libart $gnomeTarget  
cp -rp ruby-gnome2-all-0.90.5/gnomecanvas $gnomeTarget  
cp -rp ruby-gnome2-all-0.90.5/gnome $gnomeTarget

cd $gnomeTarget  
$instDir/bin/ruby extconf.rb  
make install

Ok, I got off topic here. So I am basically using ruby-gnome2 1.13, with  
the gnomecanvas from 0.95.

Get the bindings version you are using. Try running

require ‘gtk2’  
puts “Gtk::BINDING\_VERSION #{Gtk::BINDING\_VERSION}”  
puts “Gtk::VERSION #{Gtk::VERSION}”

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [November 6, 2012, 10:53pm UTC](https://www.ruby-forum.com/t/gnomecanvas2-canvaspolygon-error-in-ruby-1-9/224274/3 "2012-11-06T22:53:00Z")

</div>

Sorry, I forgot to mention, under my setup, your example is working fine  
on Ruby 1.9.2. If you really need to support older gnomecanvas and  
stuff. I highly recommend not relying on the OS default built in  
ruby(/usr/bin/ruby)

Building your own ruby build is the way to go. Actually, I’d never  
recommend using an OS’s own distribution of Ruby… but that is just me.  
I hate to rely on the OS or distributor to keep up with things when I  
can help it.

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [November 7, 2012, 12:30am UTC](https://www.ruby-forum.com/t/gnomecanvas2-canvaspolygon-error-in-ruby-1-9/224274/4 "2012-11-07T00:30:51Z")

</div>

Hi,

i double checked the lib installed and compiled on my system (ubuntu  
12.10 and ruby-gnome2 from svn), now it’s working well …

#ruby1.8 test.rb  
“RUBY VERSION 1.8.7”  
Gtk::BINDING\_VERSION 113  
Gtk::VERSION 22413

#ruby1.9.3 test.rb  
“RUBY VERSION 1.9.3”  
Gtk::BINDING\_VERSION [1, 1, 3]  
Gtk::VERSION [2, 24, 13]

thanks !  
david

On Tue, Nov 6, 2012 at 10:53 PM, Grant S.
