[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

GDK#create_cairo_context not found

Farrel Lifson

7/27/2006 9:48:00 PM

What version of rcairo, and ruby-gnome2 do I need to have
GDK#create_cairo_context? I get the following error

demo.rb:23:in `expose': undefined method `create_cairo_context' for
#<Gdk::Window:0xb724dd28 ptr=0x82bb290> (NoMethodError)
from demo.rb:13:in `initialize'
from demo.rb:74

when trying to run the following sample code:
#!/usr/bin/env ruby

require 'cairo'
require 'gtk2'
include Math

class DemiCercle < Gtk::DrawingArea
attr_accessor :desp
def initialize
super
add_events(Gdk::Event::BUTTON_PRESS_MASK |
Gdk::Event::BUTTON1_MOTION_MASK)
signal_connect "expose_event" do |widget,event|
expose(widget,event)
end # do
signal_connect "button_press_event" do |widget,event|
pressing(widget,event) end
signal_connect "motion_notify_event" do |widget,event|
moving(widget,event) end

@desp = 0.0
end # initialize

def expose(widget,event)
# crÃ(c)er un contexte graphique
context = widget.window.create_cairo_context

context.rectangle(event.area.x, event.area.y,
event.area.width, event.area.height)

context.clip()
draw(context)
return false
end # expose

def draw(context)
rect = allocation()
x = rect.x + rect.width / 2.0
y = rect.y + rect.height / 2.0

radius = [rect.width / 2.0, rect.height / 2.0].min - 5.0

#context.arc(x, y, radius, 0,(1 * PI))
context.arc(x, y, radius, 0 + @desp , (1.0 * PI) + @desp)

context.set_source_rgb(0.7, 0.8, 0.1)
context.fill_preserve()

context.set_source_rgb(0, 0, 0)
context.stroke()
end

def pressing(widget,event)
pressing_x = event.x
end

def moving(widget,event)
if (pressing(widget,event) - event.x) > 1
@desp = @desp + 0.2
else
@desp = @desp - 0.1
end
draw(widget.window.create_cairo_context)
queue_draw()
end
end


Gtk.init
fen = Gtk::Window.new
fen.set_title("Cairo exemple 2")
fen.signal_connect("destroy") { Gtk.main_quit }
figure = DemiCercle.new
fen.add(figure)
fen.show_all

Gtk.main

I have the following libs installed on my Gentoo box:

nicodemus portage # emerge -p rcairo gtk+ ruby-gnome2
Calculating dependencies... done!
[ebuild R ] dev-ruby/rcairo-1.0.0 USE="-examples*"
[ebuild R ] x11-libs/gtk+-2.8.12 USE="-tiff*"
[ebuild R ] dev-ruby/ruby-gnome2-0.14.1

Thank,
Farrel

12 Answers

anne001

7/28/2006 12:48:00 PM

0

do you get the same error in irb when you type
require 'cairo'

cairo has a list and they may be able to help,

If you have trouble with cairo or rcairo, or you have some ideas for
how
it could be improved, please feel free to send a message to the cairo
mailinglist at cairo@cairographics.org , which is archived at

http://cairographics.org/cgi-bin/mailman/list...

a post from
http://lists.freedesktop.org/archives/cairo/2006-April/0...
refers to
Gdk::Drawable::create_cairo_context()

Farrel Lifson

7/28/2006 1:21:00 PM

0

On 28/07/06, anne001 <anne@wjh.harvard.edu> wrote:
> do you get the same error in irb when you type
> require 'cairo'

Nope cairo loads fine. It just seems that the GDK::Drawable object
seems to be missing the create_cairo_context method. According to the
documentation I've read that code should work with GTK 2.8,
Ruby/Gnome2 0.14 and rcairo 1.0 all of which I have installed. I've
recompiled and re-installed everything but that didn't work. I just
want to make sure that I'm using the correct versions or if I'm not
missing some other required library.

Thanks,
Farrel

Masao Mutoh

7/28/2006 4:34:00 PM

0

Hi,

Your sample works on my machine.

I suspect you didn't install Ruby/Cairo devel package.

Check /usr/(local/)lib/ruby/site_ruby/1.8/i686-linux/rb_cairo.h.
If it's not existed, you need to install Ruby/Cairo dev package
first. Then compile Ruby-GNOME2 again.

If you are't be able to fix it,
show me your ruby-gnome2-x.x.x/gtk/mkmf.log.

On Fri, 28 Jul 2006 22:20:50 +0900
"Farrel Lifson" <farrel.lifson@gmail.com> wrote:

> On 28/07/06, anne001 <anne@wjh.harvard.edu> wrote:
> > do you get the same error in irb when you type
> > require 'cairo'
>
> Nope cairo loads fine. It just seems that the GDK::Drawable object
> seems to be missing the create_cairo_context method. According to the
> documentation I've read that code should work with GTK 2.8,
> Ruby/Gnome2 0.14 and rcairo 1.0 all of which I have installed. I've
> recompiled and re-installed everything but that didn't work. I just
> want to make sure that I'm using the correct versions or if I'm not
> missing some other required library.
>
> Thanks,
> Farrel
>
>


--
--
:% Masao Mutoh<mutoh@highway.ne.jp>

Farrel Lifson

7/28/2006 9:25:00 PM

0

On 28/07/06, Masao Mutoh <mutoh@highway.ne.jp> wrote:
> Hi,
>
> Your sample works on my machine.
>
> I suspect you didn't install Ruby/Cairo devel package.
>
> Check /usr/(local/)lib/ruby/site_ruby/1.8/i686-linux/rb_cairo.h.
> If it's not existed, you need to install Ruby/Cairo dev package
> first. Then compile Ruby-GNOME2 again.
>
> If you are't be able to fix it,
> show me your ruby-gnome2-x.x.x/gtk/mkmf.log.
>
Hi,

I solved the problem I had to re-install the ruby/gtk2 bindings after
I had installed rcairo.

Thanks for the help,
Farrel

anne001

7/28/2006 9:25:00 PM

0

With a little help, I managed to compile cairo on my OS X such that irb
can include cairo without error message. So now, I get the same error
message as Farrel

I checked on rb_cairo.h, it is in
/private/opt/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.3.0/rb_cairo.h

The person who helped me with my cairo installed thought that the
problem was with my having an old gnome2, but the darwinport folder
said ruby-gnome2-all-0.15.0. he thought 0.15.0 was alright.

he suggested getting help at
http://lists.sourceforge.net/mailman/listinfo/ruby-gnome...

I found the ruby-gnome2-all-0.15.0/gtk/mkmf.log, I posted it at
visionlab.harvard.edu/Members/Anne/mkmf.log

anne001

7/28/2006 9:53:00 PM

0

So it is an install problem.

I was interested, because I wanted to know if my gnome2 install was ok,
I guess not. I tried recompiling all the rb files, but that did not
change anything for me. glib2, atk, cairo, pango and then gtk, but I
still have the error. Oh well.

Farrel Lifson

7/28/2006 10:23:00 PM

0

On 28/07/06, anne001 <anne@wjh.harvard.edu> wrote:
> So it is an install problem.
>
> I was interested, because I wanted to know if my gnome2 install was ok,
> I guess not. I tried recompiling all the rb files, but that did not
> change anything for me. glib2, atk, cairo, pango and then gtk, but I
> still have the error. Oh well.

It helped me that I built ruby/gtk2 after I had installed rcairo.

Farrel

Masao Mutoh

7/29/2006 2:38:00 AM

0

Hi,

On Sat, 29 Jul 2006 06:30:06 +0900
"anne001" <anne@wjh.harvard.edu> wrote:

> With a little help, I managed t/private/opt/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.3.0o compile cairo on my OS X such that irb
> can include cairo without error message. So now, I get the same error
> message as Farrel
>
> I checked on rb_cairo.h, it is in
> /private/opt/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.3.0/rb_cairo.h
>
> The person who helped me with my cairo installed thought that the
> problem was with my having an old gnome2, but the darwinport folder
> said ruby-gnome2-all-0.15.0. he thought 0.15.0 was alright.
>
> he suggested getting help at
> http://lists.sourceforge.net/mailman/listinfo/ruby-gnome...
>
> I found the ruby-gnome2-all-0.15.0/gtk/mkmf.log, I posted it at
> visionlab.harvard.edu/Members/Anne/mkmf.log

It seems no problem from your mkmf.log.
rb_cairo.h was found in it correctly.

You need to tell us more informations.
1. What is the result of require 'cairo' ?
$ irb
irb(main):001:0> require 'cairo'
=> true

2. Try to remove /private/opt/local/lib/ruby/site_ruby/1.8/.../gtk2.so
once, then,
$ cd ruby-gnome2-x.x.x/gtk
$ make clean
$ ruby extconf.rb >& log.txt
$ make >>& log.txt
$ make install >>& log.txt

Then, if your problem is not fixed, send me your log.txt.

--
:% Masao Mutoh<mutoh@highway.ne.jp>

anne001

7/29/2006 2:42:00 PM

0

> 1. What is the result of require 'cairo' ?
> $ irb
> irb(main):001:0> require 'cairo'
> => true
that is correct

> 2. Try to remove /private/opt/local/lib/ruby/site_ruby/1.8/.../gtk2.so

I can't find such a file with EasyFind. On the web I see references to
/usr/local/lib/ruby/site_ruby/1.8/i386-freebsd4/gtk2.so
site_ruby/1.8/i586-linux-gnu/gtk2.so
site_ruby/1.8/i586-linux/gtk2.so
usr/lib/ruby/1.8/i386-linux/gtk2.so

ls /private/opt/local/lib/ruby/site_ruby/1.8 anne$ ls
#hhp-access2.rb# gtk2 pango.rb
atk.rb gtk2.rb pkg-config.rb
cairo.rb gtkglext.rb powerpc-darwin8.3.0
gconf2.rb gtkhtml2.rb soap
gdk_pixbuf2.rb http-access2 universal-darwin8.0
glib2.rb http-access2.rb web
gnome2.rb http-access2.rb~ web.rb
gnomecanvas2.rb libglade2.rb wsdl
gnomevfs.rb mkmf-gnome2.rb xmlscan

powerpc-darwin8.3.0 has bundles and .h files.

Masao Mutoh

7/29/2006 3:08:00 PM

0

Hi,

On Sat, 29 Jul 2006 23:45:11 +0900
"anne001" <anne@wjh.harvard.edu> wrote:

> > 1. What is the result of require 'cairo' ?
> > $ irb
> > irb(main):001:0> require 'cairo'
> > => true
> that is correct
>
> > 2. Try to remove /private/opt/local/lib/ruby/site_ruby/1.8/.../gtk2.so
>
> I can't find such a file with EasyFind. On the web I see references to

You must have "gtk2.so" anywhere. Find it and remove all of "gtk2.so".
--
:% Masao Mutoh<mutoh@highway.ne.jp>