diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-26 21:36:46 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-26 21:36:46 -0400 |
| commit | 098beef9969ae625714de4a23c5899a70a6557ca (patch) | |
| tree | 2957aad1e707be9cba02c45f7f15dce78546d2ac /checkbox.go | |
| parent | 5c002e3d0f0b873d6ca29dfa9e97c09dead54494 (diff) | |
Added Checkbox.SetChecked() and implemented it on GTK+.
Diffstat (limited to 'checkbox.go')
| -rw-r--r-- | checkbox.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/checkbox.go b/checkbox.go index d079e17..934da90 100644 --- a/checkbox.go +++ b/checkbox.go @@ -12,7 +12,7 @@ type Checkbox struct { created bool sysData *sysData initText string - initCheck bool + initCheck bool } // NewCheckbox creates a new checkbox with the specified text. @@ -46,7 +46,19 @@ func (c *Checkbox) Text() string { return c.initText } -// Checked() returns whether or not the checkbox has been checked. +// SetChecked() changes the checked state of the Checkbox. +func (c *Checkbox) SetChecked(checked bool) { + c.lock.Lock() + defer c.lock.Unlock() + + if c.created { + c.sysData.setChecked(checked) + return + } + c.initCheck = checked +} + +// Checked() returns whether or not the Checkbox has been checked. func (c *Checkbox) Checked() bool { c.lock.Lock() defer c.lock.Unlock() @@ -54,7 +66,7 @@ func (c *Checkbox) Checked() bool { if c.created { return c.sysData.isChecked() } - return false + return c.initCheck } func (c *Checkbox) make(window *sysData) error { @@ -66,6 +78,7 @@ func (c *Checkbox) make(window *sysData) error { return err } c.sysData.setText(c.initText) + c.sysData.setChecked(c.initCheck) c.created = true return nil } |
