On Tue, May 24, 2022 at 11:40:49PM +0200, Jeanette C. wrote: > [...] > Consider this: An application with a toggle button (on/off), some load from > file button and a class holding one bvoolean value connect to the on/off > button. The class could look like this: > class Data > { > public: > Data(bool value): its_value(value) {} > ~Data() {} > void set(bool value) { its_value = value; } > bool get() const { return its_value; } > private: > bool its_value; > }; > > The button is connected to a Data object, via a signal, so its set(bool) > function is called. > > The load function will load a value from a file. > > How would you normally reflect that on GUI? What's the method to not > only set the Data object value, but also the corresponding button state? > What's the current practise to make this two-way connection? Combine > both button and object in a wrapper? Have some other kind of signal? > Simple change button state in every place the Data object is changed? > > As stated above: even an old resource or documentation for a limited UI > library will do, as long as the method shines through with little > overhead and without anything like QML or a UI builder.
Hi For Gtk, perhaps this answer to a similar question might be helpful: https://discourse.gnome.org/t/declarative-state-driven-views-for-gtk/9966 The recommendation is to use GObject.bind_property(). https://docs.gtk.org/gobject/method.Object.bind_property.html This can provide one or two way binding between data and UI objects as long as they both inherit from GObject. Regards -- Tim Orford _______________________________________________ Linux-audio-dev mailing list Linux-audio-dev@lists.linuxaudio.org https://lists.linuxaudio.org/listinfo/linux-audio-dev