-
Notifications
You must be signed in to change notification settings - Fork 1
/
preferences.go
122 lines (105 loc) · 3.67 KB
/
preferences.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Copyright (c) 2013-2021 Utkan Güngördü <[email protected]>
* Copyright (c) 2021-2024 Piotr Grabowski
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gomicsv
import (
"log"
"strconv"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
)
func (app *App) preferencesInit() {
_, err := app.W.PreferencesDialog.AddButton("_OK", gtk.RESPONSE_ACCEPT)
checkDialogAddButtonErr(err)
app.W.BackgroundColorButton.Connect("color-set", func(self *glib.Object) {
chooser := >k.ColorChooser{
Object: self,
}
app.setBackgroundColor(NewColorFromGdkRGBA(chooser.GetRGBA()))
})
app.W.PagesToSkipSpinButton.SetRange(1, 100)
app.W.PagesToSkipSpinButton.SetIncrements(1, 10)
app.W.PagesToSkipSpinButton.SetValue(float64(app.Config.NSkip))
app.W.PagesToSkipSpinButton.Connect("value-changed", func(self *gtk.SpinButton) {
app.Config.NSkip = int(self.GetValue())
})
app.W.InterpolationComboBoxText.Connect("changed", func(self *gtk.ComboBoxText) {
app.setInterpolation(self.GetActive())
})
app.W.RememberRecentCheckButton.Connect("toggled", func(self *gtk.CheckButton) {
app.setRememberRecent(self.GetActive())
})
app.W.RememberPositionCheckButton.Connect("toggled", func(self *gtk.CheckButton) {
app.setRememberPosition(self.GetActive())
app.W.RememberPositionHTTPCheckButton.SetSensitive(self.GetActive())
if !self.GetActive() {
app.W.RememberPositionHTTPCheckButton.SetActive(false)
}
})
app.W.RememberPositionHTTPCheckButton.Connect("toggled", func(self *gtk.CheckButton) {
app.setRememberPositionHTTP(self.GetActive())
})
app.W.OneWideCheckButton.Connect("toggled", func(self *gtk.CheckButton) {
app.setOneWide(self.GetActive())
})
app.W.SmartScrollCheckButton.Connect("toggled", func(self *gtk.CheckButton) {
app.setSmartScroll(self.GetActive())
})
app.W.EmbeddedOrientationCheckButton.Connect("toggled", func(self *gtk.CheckButton) {
app.setEmbeddedOrientation(self.GetActive())
})
app.W.HideIdleCursorCheckButton.Connect("toggled", func(self *gtk.CheckButton) {
app.setHideIdleCursor(self.GetActive())
})
app.W.KamiteEnabledCheckButton.Connect("toggled", func(self *gtk.CheckButton) {
app.setKamiteEnabled(self.GetActive())
app.W.KamitePortContainer.SetSensitive(self.GetActive())
})
app.W.KamitePortEntry.Connect("insert-text", func(self *gtk.Entry, text string) {
// Allow only digits
for _, c := range text {
if c < '0' || c > '9' {
self.StopEmission("insert-text")
return
}
}
})
app.W.KamitePortEntry.Connect("changed", func(self *gtk.Entry) {
text, err := self.GetText()
if err != nil {
log.Panicf("getting Kamite port entry text: %v", err)
}
if text == "" {
// POLISH: Restore default value
return
}
port, err := strconv.Atoi(text)
if err != nil {
log.Panicf("parsing Kamite port entry as int: %v", err)
}
app.setKamitePort(port)
})
}
func (app *App) preferencesDialogRun() {
app.S.Cursor.ForceVisible = true
res := gtk.ResponseType(app.W.PreferencesDialog.Run())
app.W.PreferencesDialog.Hide()
if res == gtk.RESPONSE_ACCEPT {
app.saveConfig()
}
app.S.Cursor.ForceVisible = false
}