Connecting external signal handlers to a encapsulated TreeSelection


I have an annoying problem:
I have a widget which has a private TreeSelection member. I consider it an implementation detail so I didn't make it public. However, I now want to connect an external signal handler to the signal_changed signal emitted by the TreeSelection object.

Thus I need a function like this:

class MyWidget
    Glib::SignalProxy0<void>& signal_selection_changed() {
        return m_sel_ref->signal_changed();
    Glib::RefPtr<Gtk::TreeSelection> m_sel_ref;

// in some other source file from class Foo I need to connect
// to this signal:

my_widget.signal_selection_changed().connect( sigc::mem_fun( foo_obj, &Foo::on_mywidget_selection_changed ) );

However, this sort of breaks the encapsulation of the widget class.
Is there any cleaner solution?

PS: Why do all the signal_xyz function return the SignalProxy objects by value? Wouldn't I call connect on a temporary then?

Glib::SignalProxy0<void> 	signal_changed ()

No reference returned, but a copy.

Matthias Kaeppler

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]