Blog Post #0099: A Special Request

Ferhat Kurtulmuş aferust at gmail.com
Thu Jan 23 09:27:45 UTC 2020


On Wednesday, 22 January 2020 at 21:26:40 UTC, Ron Tarrant wrote:
> On Wednesday, 22 January 2020 at 09:18:51 UTC, Ferhat Kurtulmuş 
> wrote:
>
>> Another useful tutorial would be something using bindProperty 
>> and/or bindPropertyWithClosures. Once I used bindProperty with 
>> vala, but I think there is no any example to do it with gtkd.
>
> I found a bindProperty() function in gobject/ObjectG.d. Is this 
> what you're referring to?

Yes that one. Let me define a use case. We have a button spawning 
a thread doing some time consuming job (we can use 
Thread.sleep(5.seconds)). I want this button disabled so that 
user cannot spawn another thread while the first one is on duty. 
In the same time, we show a spinner while job is running. After 
completion, we want to set button enabled and to make the spinner 
invisible. Instead of setting properties of button and spinner 
separately, we can bind disabled property of the button and 
visible property of the spinner each other. In vala, we can use 
something like (pseudo code):

"this" may refer to a self pointer to an instance of derived 
spinner class:

this.bind_property("customWorkingProperty", somebutton, 
"sensitive", BindingFlags.INVERT_BOOLEAN);

bool customWorkingProperty() will be responsible for showing and 
hiding the spinner.




More information about the Digitalmars-d-learn mailing list