Re: Block a signal for a hierarchy of widget
- Date: Thu, 20 Apr 2017 08:27:32 +0100
- From: Paul Davis <paul@xxxxxxxxxxxxxxxxxxxxx>
- Subject: Re: Block a signal for a hierarchy of widget
if (b) is true, then things interested in the model state will ignore the button state itself, and focus on notifications about changes in the model state (e.g. some other variable)
if (a) is true, then changing the state of the button, whether done by the user or programatically because of some internal logic, results in a change in the model state. anything interested in the model state will have connected to the button signals, and will want to know about this change. blocking the signal implies that you are trying to hide a change in the state of the model from other objects/methods who have stated their interest in knowing when it changes - this can hardly be a good thing.
b) the button is merely a view and a controller for the "model" state (i.e. a variable somewhere)
a) the state of the button IS the "model" state
so there are now two possible designs:
GTK makes this tricky because it tends to encourage you to use the button state as the model state (i.e. when checking if the user has "set X to true", you tend to check whether the button is pressed or not, rather than whether some independent value is true or not).
if the button serves both purposes, then its visual state should change whenever the model changes. other aspects of the program should care about the state of the model, not the button's state.
2) to indicate the current state of the "model" (e.g. a variable)
let's take the example of a button. the button may serve one or both of two purposes:1) to provide a target for the user to operate on in order to change the state of some part of the "model" within the program (e.g. the state of some variable) - for example, by clicking/pressing it
On Thu, Apr 20, 2017 at 7:21 AM, Emmanuel Pacaud <emmanuel@xxxxxxxxx> wrote:
Le mer. 19 avril 2017 à 20:57, Paul Davis <paul@xxxxxxxxxxxxxxxxxxxxx> a écrit :
This normally means that you're not using appropriate model-view-controller design.
Could you elaborate a bit ? I fail to see where the design of my application could solve this issue I have with the use of Gtk.
On Wed, Apr 19, 2017 at 2:19 PM, Emmanuel Pacaud <emmanuel@xxxxxxxxx> wrote:
Is there a way to unblock/block the emission of signals for a hierarchy of widgets ?
The reason I'm asking is because of this sort of code I'm using:
It is not very convenient and error prone to register every connected signals and block/unblock them when one want to update some widgets programmatically.
gtk-list mailing list
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list