Signal_emit for other object

my code:
http://pastie.org/300627
Why generated event, in same object, can not be heard in other?
Sorry for my english:)

Cyrill Jakovlev wrote:

my code:
http://pastie.org/300627
Why generated event, in same object, can not be heard in other?
Sorry for my english:)

I think you are missing the “type_register” command.

Here’s the pattern that I’ve used successfully:

class Foo < Gtk::Object
type_register
CHANGED = ‘changed’
signal_new(CHANGED,
GLib::Signal::RUN_FIRST, # flags
nil, # accumulator (XXX: not
supported yet)
nil, # return type (void == nil)
Hash # parameter types: Hash
)

needed to be able to emit the “changed” signal

def signal_do_changed(params)
end

def something_useful

params ||= {}
signal_emit(CHANGED, params)
end
end

class Bar

foo = Foo.new
foo.signal_connect(Foo::CHANGED) {|obj, params|
on_foo_changed(params)}

end

I’ve used this pattern for several widgets and EventBox objects. Just
inherit from correct object. For example: class Foo < Gtk::EventBox

HTH,
Roy

mm… no
I don’t make type_register, because I refined class GLib::Object. In
GLib::Object type_register called before…
Your example can hear signal only inside object. If I call
signal_emit(‘changed’), other instances of class Foo (and all other
objects) wouldn’t know about it.
I want to all object (instance classes extends GLib::Object) can hear
signal, and I find solution: http://pastie.org/301012
signal_emit from button call method from window. How u like this?)

Cyrill Jakovlev wrote:

mm… no
I don’t make type_register, because I refined class GLib::Object. In
GLib::Object type_register called before…
Your example can hear signal only inside object. If I call
signal_emit(‘changed’), other instances of class Foo (and all other
objects) wouldn’t know about it.
I want to all object (instance classes extends GLib::Object) can hear
signal, and I find solution: http://pastie.org/301012
signal_emit from button call method from window. How u like this?)

OK, you are wanting truly global signals. First, I’d suggest removing
the instance signal_connect (line 15) and signal_emit (line 19) in your
example. By removing them, GeneralWindow and ToolsPanel will each
receive only one signal via signal_connect_from_all_objects. So you end
up with a pure global signal concept that is not blurred with normal
signal handling.

Also I’d suggest adding a signal_disconnect_from_all_objects method to
Glib::Object. I’d suspect that you could run into problems deleting and
garbage collecting objects without it.

Part of me likes the global signal pattern, while another part of me has
concerns that the pattern can be abused leading to some difficult to
debug problems.

Thanks for sharing.

Have fun,
Roy