# Problem in subclassing and new signals

**URL:** <https://www.ruby-forum.com/t/problem-in-subclassing-and-new-signals/228199>\
**Category:** Ruby-Gnome 2\
**Created:** [April 13, 2013, 9:53am UTC](https://www.ruby-forum.com/t/problem-in-subclassing-and-new-signals/228199 "2013-04-13T09:53:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [April 13, 2013, 9:53am UTC](https://www.ruby-forum.com/t/problem-in-subclassing-and-new-signals/228199/1 "2013-04-13T09:53:56Z")

</div>

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`’

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

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [April 13, 2013, 12:20pm UTC](https://www.ruby-forum.com/t/problem-in-subclassing-and-new-signals/228199/2 "2013-04-13T12:20:49Z")

</div>

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

> <https://github.com/ruby-gnome/ruby-gnome/blob/master/glib2/sample/type-register2.rb>

line 20-22

So you should write :

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

```

regards

Simon

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [April 13, 2013, 1:48pm UTC](https://www.ruby-forum.com/t/problem-in-subclassing-and-new-signals/228199/3 "2013-04-13T13:48:13Z")

</div>

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 :

> <https://github.com/ruby-gnome/ruby-gnome/blob/main/glib2/sample/type-register2.rb>

> 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
