-
Notifications
You must be signed in to change notification settings - Fork 78
/
colors.go
87 lines (80 loc) · 2.44 KB
/
colors.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
package gui
import (
"os"
"strings"
)
type colorSet struct {
rosterPeerBackground string
rosterPeerOfflineForeground string
rosterPeerOnlineForeground string
rosterGroupBackground string
rosterAccountOnlineBackground string
rosterAccountOfflineBackground string
conversationOutgoingUserForeground string
conversationIncomingUserForeground string
conversationOutgoingTextForeground string
conversationIncomingTextForeground string
conversationStatusTextForeground string
}
var themeVariant string
func (u *gtkUI) isDarkThemeVariant() bool {
if themeVariant != "" {
return themeVariant == "dark"
}
themeVariant = "light"
gtkTheme := os.Getenv("GTK_THEME")
if gtkTheme != "" {
toks := strings.Split(gtkTheme, ":")
variant := toks[len(toks)-1:][0]
if variant == "dark" {
themeVariant = variant
return true
}
}
settings, err := g.gtk.SettingsGetDefault()
if err != nil {
panic(err)
}
prefDark, _ := settings.GetProperty("gtk-application-prefer-dark-theme")
if prefDark == true {
themeVariant = "dark"
return true
}
return false
}
func (u *gtkUI) currentColorSet() colorSet {
if u.isDarkThemeVariant() {
return u.defaultDarkColorSet()
}
return u.defaultLightColorSet()
}
func (u *gtkUI) defaultLightColorSet() colorSet {
return colorSet{
rosterPeerBackground: "#ffffff",
rosterPeerOfflineForeground: "#aaaaaa",
rosterPeerOnlineForeground: "#000000",
rosterGroupBackground: "#e9e7f3",
rosterAccountOnlineBackground: "#918caa",
rosterAccountOfflineBackground: "#d5d3de",
conversationOutgoingUserForeground: "#3465a4",
conversationIncomingUserForeground: "#a40000",
conversationOutgoingTextForeground: "#555753",
conversationIncomingTextForeground: "#000000",
conversationStatusTextForeground: "#4e9a06",
}
}
func (u *gtkUI) defaultDarkColorSet() colorSet {
return colorSet{
rosterPeerBackground: "#7f7f7f",
rosterPeerOfflineForeground: "#aaaaaa",
rosterPeerOnlineForeground: "#e5e5e5",
rosterGroupBackground: "#b8b6bf",
rosterAccountOnlineBackground: "#d5d3de",
rosterAccountOfflineBackground: "#918caa",
conversationOutgoingUserForeground: "#3465a4",
conversationIncomingUserForeground: "#a40000",
conversationOutgoingTextForeground: "#f3f3f3",
conversationIncomingTextForeground: "#7f7f7f",
conversationStatusTextForeground: "#4e9a06",
}
}