How to pass data to class created with Gtk::Builder::get_widget_derived()?



Hi all,

In the example given here:

  https://developer.gnome.org/gtkmm-tutorial/stable/sec-builder-using-derived-widgets.html.en

A call to Gtk::Builder::get_widget_derived() is used to create an
instance of the derived dialog class.  The class then sets up the
widgets in its constructor.

However from the example it's unclear how, in a more complex program,
you would access data external to the class from within that
constructor.

For instance the example simply attaches an event handler to a button,
but in my situation I want to populate a ListBox with values stored in
a data structure loaded earlier in the application.

Normally I would pass the data structure as an extra parameter in the
constructor, so the constructor can access the information it needs to
set up the widgets appropriately.  However
Gtk::Builder::get_widget_derived() seems to require a fixed constructor
form, so I can't supply any additional information to the constructor.

How is this situation typically handled?  Is there a best-practice for
this scenario?

Many thanks,
Adam.




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