• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fyne-io / fyne / 12939465541

23 Jan 2025 10:43PM UTC coverage: 59.122% (+0.08%) from 59.043%
12939465541

Pull #5434

github

andydotxyz
Updating missed test file change
Pull Request #5434: Adding scrolling to TextGrid and a new Append method too

234 of 273 new or added lines in 1 file covered. (85.71%)

351 existing lines in 14 files now uncovered.

24921 of 42152 relevant lines covered (59.12%)

781.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/data/binding/preference.go
1
// auto-generated
2
// **** THIS FILE IS AUTO-GENERATED, PLEASE DO NOT EDIT IT **** //
3

4
package binding
5

6
import (
7
        "sync/atomic"
8

9
        "fyne.io/fyne/v2"
10
)
11

12
const keyTypeMismatchError = "A previous preference binding exists with different type for key: "
13

14
type prefBoundBool struct {
15
        base
1✔
16
        key   string
1✔
UNCOV
17
        p     fyne.Preferences
×
UNCOV
18
        cache atomic.Pointer[bool]
×
19
}
20

1✔
21
// BindPreferenceBool returns a bindable bool value that is managed by the application preferences.
1✔
22
// Changes to this value will be saved to application storage and when the app starts the previous values will be read.
1✔
23
//
1✔
24
// Since: 2.0
1✔
25
func BindPreferenceBool(key string, p fyne.Preferences) Bool {
1✔
26
        binds := prefBinds.getBindings(p)
27
        if binds != nil {
28
                if listen, ok := binds.Load(key); listen != nil && ok {
5✔
29
                        if l, ok := listen.(Bool); ok {
5✔
30
                                return l
5✔
31
                        }
5✔
32
                        fyne.LogError(keyTypeMismatchError+key, nil)
33
                }
34
        }
35

36
        listen := &prefBoundBool{key: key, p: p}
37
        binds = prefBinds.ensurePreferencesAttached(p)
38
        binds.Store(key, listen)
39
        return listen
40
}
41

1✔
42
func (b *prefBoundBool) Get() (bool, error) {
1✔
UNCOV
43
        cache := b.p.Bool(b.key)
×
UNCOV
44
        b.cache.Store(&cache)
×
45
        return cache, nil
46
}
1✔
47

1✔
48
func (b *prefBoundBool) Set(v bool) error {
1✔
49
        b.p.SetBool(b.key, v)
1✔
50

1✔
51
        b.lock.RLock()
1✔
52
        defer b.lock.RUnlock()
53
        b.trigger()
54
        return nil
4✔
55
}
4✔
56

4✔
57
func (b *prefBoundBool) checkForChange() {
4✔
58
        val := b.cache.Load()
59
        if val != nil && b.p.Bool(b.key) == *val {
60
                return
61
        }
62
        b.trigger()
63
}
64

65
func (b *prefBoundBool) replaceProvider(p fyne.Preferences) {
66
        b.p = p
67
}
101✔
68

200✔
69
type prefBoundFloat struct {
99✔
70
        base
99✔
71
        key   string
72
        p     fyne.Preferences
2✔
73
        cache atomic.Pointer[float64]
2✔
74
}
2✔
75

2✔
76
// BindPreferenceFloat returns a bindable float64 value that is managed by the application preferences.
2✔
77
// Changes to this value will be saved to application storage and when the app starts the previous values will be read.
2✔
78
//
79
// Since: 2.0
80
func BindPreferenceFloat(key string, p fyne.Preferences) Float {
9✔
81
        binds := prefBinds.getBindings(p)
9✔
82
        if binds != nil {
9✔
83
                if listen, ok := binds.Load(key); listen != nil && ok {
9✔
84
                        if l, ok := listen.(Float); ok {
85
                                return l
86
                        }
87
                        fyne.LogError(keyTypeMismatchError+key, nil)
88
                }
89
        }
90

91
        listen := &prefBoundFloat{key: key, p: p}
92
        binds = prefBinds.ensurePreferencesAttached(p)
93
        binds.Store(key, listen)
5✔
94
        return listen
8✔
95
}
3✔
96

3✔
97
func (b *prefBoundFloat) Get() (float64, error) {
98
        cache := b.p.Float(b.key)
2✔
99
        b.cache.Store(&cache)
2✔
100
        return cache, nil
2✔
101
}
2✔
102

2✔
103
func (b *prefBoundFloat) Set(v float64) error {
2✔
104
        b.p.SetFloat(b.key, v)
105

106
        b.lock.RLock()
3✔
107
        defer b.lock.RUnlock()
3✔
108
        b.trigger()
3✔
109
        return nil
3✔
110
}
111

112
func (b *prefBoundFloat) checkForChange() {
113
        val := b.cache.Load()
114
        if val != nil && b.p.Float(b.key) == *val {
115
                return
116
        }
117
        b.trigger()
118
}
119

120
func (b *prefBoundFloat) replaceProvider(p fyne.Preferences) {
121
        b.p = p
122
}
123

124
type prefBoundInt struct {
125
        base
126
        key   string
127
        p     fyne.Preferences
128
        cache atomic.Pointer[int]
129
}
130

131
// BindPreferenceInt returns a bindable int value that is managed by the application preferences.
132
// Changes to this value will be saved to application storage and when the app starts the previous values will be read.
133
//
134
// Since: 2.0
135
func BindPreferenceInt(key string, p fyne.Preferences) Int {
136
        binds := prefBinds.getBindings(p)
137
        if binds != nil {
138
                if listen, ok := binds.Load(key); listen != nil && ok {
139
                        if l, ok := listen.(Int); ok {
140
                                return l
141
                        }
142
                        fyne.LogError(keyTypeMismatchError+key, nil)
143
                }
144
        }
145

146
        listen := &prefBoundInt{key: key, p: p}
147
        binds = prefBinds.ensurePreferencesAttached(p)
148
        binds.Store(key, listen)
149
        return listen
150
}
151

152
func (b *prefBoundInt) Get() (int, error) {
153
        cache := b.p.Int(b.key)
154
        b.cache.Store(&cache)
155
        return cache, nil
156
}
157

158
func (b *prefBoundInt) Set(v int) error {
159
        b.p.SetInt(b.key, v)
160

161
        b.lock.RLock()
162
        defer b.lock.RUnlock()
163
        b.trigger()
164
        return nil
165
}
166

167
func (b *prefBoundInt) checkForChange() {
168
        val := b.cache.Load()
169
        if val != nil && b.p.Int(b.key) == *val {
170
                return
171
        }
172
        b.trigger()
173
}
174

175
func (b *prefBoundInt) replaceProvider(p fyne.Preferences) {
176
        b.p = p
177
}
178

179
type prefBoundString struct {
180
        base
181
        key   string
182
        p     fyne.Preferences
183
        cache atomic.Pointer[string]
184
}
185

186
// BindPreferenceString returns a bindable string value that is managed by the application preferences.
187
// Changes to this value will be saved to application storage and when the app starts the previous values will be read.
188
//
189
// Since: 2.0
190
func BindPreferenceString(key string, p fyne.Preferences) String {
191
        binds := prefBinds.getBindings(p)
192
        if binds != nil {
193
                if listen, ok := binds.Load(key); listen != nil && ok {
194
                        if l, ok := listen.(String); ok {
195
                                return l
196
                        }
197
                        fyne.LogError(keyTypeMismatchError+key, nil)
198
                }
199
        }
200

201
        listen := &prefBoundString{key: key, p: p}
202
        binds = prefBinds.ensurePreferencesAttached(p)
203
        binds.Store(key, listen)
204
        return listen
205
}
206

207
func (b *prefBoundString) Get() (string, error) {
208
        cache := b.p.String(b.key)
209
        b.cache.Store(&cache)
210
        return cache, nil
211
}
212

213
func (b *prefBoundString) Set(v string) error {
214
        b.p.SetString(b.key, v)
215

216
        b.lock.RLock()
217
        defer b.lock.RUnlock()
218
        b.trigger()
219
        return nil
220
}
221

222
func (b *prefBoundString) checkForChange() {
223
        val := b.cache.Load()
224
        if val != nil && b.p.String(b.key) == *val {
225
                return
226
        }
227
        b.trigger()
228
}
229

230
func (b *prefBoundString) replaceProvider(p fyne.Preferences) {
231
        b.p = p
232
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc