1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-gtk.git synced 2024-12-23 12:46:45 +00:00
cchat-gtk/internal/gts/css.go

38 lines
760 B
Go
Raw Normal View History

2020-06-06 00:47:28 +00:00
package gts
import (
"github.com/diamondburned/cchat-gtk/internal/log"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/gtk"
"github.com/pkg/errors"
)
var cssRepos = map[string]*gtk.CssProvider{}
func getDefaultScreen() *gdk.Screen {
d, _ := gdk.DisplayGetDefault()
s, _ := d.GetDefaultScreen()
return s
}
func loadProviders(screen *gdk.Screen) {
for file, repo := range cssRepos {
gtk.AddProviderForScreen(
screen, repo,
uint(gtk.STYLE_PROVIDER_PRIORITY_APPLICATION),
)
// mark as done
delete(cssRepos, file)
}
}
2020-07-16 05:41:21 +00:00
func LoadCSS(name, css string) {
prov, _ := gtk.CssProviderNew()
if err := prov.LoadFromData(css); err != nil {
log.Error(errors.Wrap(err, "Failed to parse CSS in "+name))
return
2020-06-06 00:47:28 +00:00
}
2020-07-16 05:41:21 +00:00
cssRepos[name] = prov
2020-06-06 00:47:28 +00:00
}