Problem in subclassing and new signals

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:ininitialize’
from test.rb:23:in new' from test.rb:23:in

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

It took me a while to figure it out also. The only documentation I found
is in the examples :

line 20-22

So you should write :

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

regards

Simon

Am 13.04.2013 12:20, schrieb Simon A.:

It took me a while to figure it out also. The only documentation I found
is in the examples :

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 :slight_smile:

Thanks a lot! detlef