Forum: Ruby-Gnome 2 Problem in subclassing and new signals

4913bcb685792f601ae9813b4713abb9?d=identicon&s=25 Detlef Reichl (Guest)
on 2013-04-13 09:53
(Received via mailing list)
Hi,

I have a problem with subclassing a widget, when I add new signals to
this widget. See this smal example:



require 'gtk2'

class Box1 < Gtk::VBox
     def initialize data
         super false, 2
     end
end

class Box2 < Gtk::VBox
     type_register
     signal_new(:changed, GLib::Signal::RUN_FIRST,
              nil, GLib::Type['void'], String, Float)
     def signal_do_changed foo, bla
     end


     def initialize data
         super false, 2
     end
end

b1 = Box1.new 'foo'
b2 = Box2.new 'foo'



It throwes the error:

det@datengrab:~/Desktop$ ruby test.rb
test.rb:18:in `initialize': wrong number of arguments (2 for 0..1)
(ArgumentError)
  from test.rb:18:in `initialize'
  from test.rb:23:in `new'
  from test.rb:23:in `<main>'


as long, as I add no new signal to the widget the call to super() works
like expected. With the new signal it fails. Can someone explain to me,
why?

Thanks! detlef
B985bf8029d396259f579c70f809269a?d=identicon&s=25 Simon Arnaud (sarnaud)
on 2013-04-13 12:20
It took me a while to figure it out also. The only documentation I found
is in the examples :
https://github.com/ruby-gnome2/ruby-gnome2/blob/ma...
line 20-22

So you should write :

     def initialize data
         super :homogeneous => false, :spacing => 2
     end

regards

Simon
4913bcb685792f601ae9813b4713abb9?d=identicon&s=25 Detlef Reichl (Guest)
on 2013-04-13 13:48
(Received via mailing list)
Am 13.04.2013 12:20, schrieb Simon Arnaud:
> It took me a while to figure it out also. The only documentation I found
> is in the examples :
>
https://github.com/ruby-gnome2/ruby-gnome2/blob/ma...
> line 20-22
>
> So you should write :
>
>       def initialize data
>           super :homogeneous =>  false, :spacing =>  2
>       end

Ah, I didn't knew that it works this way. Something learned today :-)

Thanks a lot! detlef
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.