Jörg Beyer
Jörg Beyer

Reputation: 3671

What is the gtkmm equivalent to g_signal_handlers_block_by_func()?

I need to block signals that I emit (indirectly) myself.

In C one could use g_signal_handlers_block_by_func() and the sister function unblock.

What can I use in C++ gtkmm?

I have a gtkmm dlna player, that emits the changed signal to a Gtk::HScale Widet each second, because it gets (from the outside) a signal that the song that just plays. And then I seek to the position that just where current, which set the song back a split second...

I would like to block my on changes from the seek, because I saw that a C program did that with g_signal_handlers_block_by_func.

Upvotes: 3

Views: 750

Answers (1)

Jörg Beyer
Jörg Beyer

Reputation: 3671

since ptomato asked:

I never realized, that the connect method has a valuable return value:

so if you connect the signals like this:

mywidget_connection = mywidget.signal_value_changed().connect(sigc::mem_fun(*this, &MyClass::on_value_changed ));

In my situation I have 2 ways to change the value: 1.) someone pulls a slider: should update the value and seek 2.) the timer comes along and tells the new position: should update the value but not seek.

then you can block/unblock like this:

mywidget_connection.block();
mywidget.set_value(new_value);
mywidget_connection.unblock();

and this does not emit the changed signal.

Upvotes: 4

Related Questions