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



2016-11-14 16:39 GMT+01:00 Emmanuele Bassi <ebassi gmail com>:

Hi;

On 14 November 2016 at 15:36, Pozz Pozz <pozzugno gmail com> wrote:
Is it possible to have a single Gtk.Adjustment for several Gtk.SpinButton
widgets? I couldn't understand if the adjustment is only used by
SpinButton
to know the range (and some additional details, such as the page size),
or
the adjustment is used also for the value storage place.

I tried to create two SpinButtons and to set a single adjustment, but it
seems to me changing the value of a SpinButton will change the value of
the
other SpinButton too. So it seems it isn't possible to share one
adjustment
among several widgets.

Of course, I'm supponsing the case of several parameters that have
different values but the same range properties (min, max, page step, ...)

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.


[1] https://developer.gnome.org/gtk3/stable/GtkAdjustment.html


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