# Problem with new signals

**URL:** <https://www.ruby-forum.com/t/problem-with-new-signals/228688>\
**Category:** Ruby-Gnome 2\
**Created:** [May 3, 2013, 5:16am UTC](https://www.ruby-forum.com/t/problem-with-new-signals/228688 "2013-05-03T05:16:15Z")\
**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:** [May 3, 2013, 5:16am UTC](https://www.ruby-forum.com/t/problem-with-new-signals/228688/1 "2013-05-03T05:16:15Z")

</div>

Hi,

if I add a signal to a Gtk::Box super() doesn’t work like expected. The  
following code works:

require ‘gtk3’

class MBox \< Gtk::Box  
def initialize  
super(:vertical)  
pack\_start Gtk::Label.new(‘bla1’)  
pack\_start Gtk::Label.new(‘bla2’)  
end  
end

win = Gtk::Window.new  
box = MBox.new  
win.add box  
win.show\_all  
Gtk.main

but if I add a new signal:

require ‘gtk3’

class MBox \< Gtk::Box  
self.type\_register  
self.signal\_new(:value\_changed, GLib::Signal::RUN\_FIRST,  
nil, GLib::Type[‘void’], Float, Float)  
def signal\_do\_value\_changed foo, bla  
end

```
 def initialize
     super(:vertical)
     pack_start Gtk::Label.new('bla1')
     pack_start Gtk::Label.new('bla2')
 end

```

end

win = Gtk::Window.new  
box = MBox.new  
win.add box  
win.show\_all  
Gtk.main

I get this error:

box.rb:13:in `initialize': wrong argument type Symbol (expected Hash) (TypeError) from box.rb:13:in`initialize’  
from box.rb:21:in `new' from box.rb:21:in`’

Line 13 is the line with the super call. What I’m doing wrong?

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:** [May 3, 2013, 1:56pm UTC](https://www.ruby-forum.com/t/problem-with-new-signals/228688/2 "2013-05-03T13:56:50Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] Problem with new signals” on Fri, 03 May 2013  
05:14:38 +0200,  
Detlef R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> if I add a signal to a Gtk::Box super() doesn’t work like  
> expected.

You can’t use super class’s initialize when you use  
type\_register. Because super class’s initialize uses super  
class’s GType not your new GType.

Type\_registered class’s initialize is similar to raw  
g\_object\_new(). You need to set object properties by Hash  
like:

def initialize  
super(:orientation =\> :vertical)  
end

## Thanks,

kou

---

<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:** [May 3, 2013, 6:16pm UTC](https://www.ruby-forum.com/t/problem-with-new-signals/228688/3 "2013-05-03T18:16:50Z")

</div>

Am 03.05.2013 13:56, schrieb Kouhei S.:

> Type\_registered class’s initialize is similar to raw  
> g\_object\_new(). You need to set object properties by Hash  
> like:
> 
> def initialize  
> super(:orientation =\> :vertical)  
> end

OK, that works.

Thanks allot! detlef
