Re: Sharing Gtk.Adjustment objects among several Gtk.SpinButton widgets



Hi;

On 14 November 2016 at 17:12, Pozz Pozz <pozzugno gmail com> wrote:

A GtkAdjustment is a "model", whereas the widgets using the adjustment
are the "views". So, if you use the same GtkAdjustment instance, all
widgets will share the same underlying state. This is by design.

If you want to create different widgets with the same adjustment
parameters but not sharing the same state you will have to create
different GtkAdjustment instances — plausibly using a factory method.


Thank you for your answer. My doubt was derived from the following
statements [1]:

        "The GtkAdjustment object does not update the value itself. Instead
it is left up to the
        owner of the GtkAdjustment to control the value."

At first, I thought the value (actual state) was managed (and stored)
directly by the widget, without
changing the value of associated adjustment.
From your words, that sentence says the widgets explicitly change the value
of its adjustment, when needed.

Yes; in a broader sense, the widget using an adjustment is both the
view and the controller of the value.

All a widget does is calling gtk_adjustment_set_value() with the value
desired by the user — through direct manipulation of the UI element,
or programmatically. The adjustment will then notify the widget of the
change, and the widget will update itself to reflect it. This allows
multiple widgets to store and manipulate the adjustment. The value
itself is a property of the GtkAdjustment instance.

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]


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