func (t *Theme) getThemePreview(themeType string) string { var target string switch themeType { case "gtk": target = path.Join("WindowThemes", t.GtkTheme) case "icon": target = path.Join("IconThemes", t.IconTheme) case "cursor": target = path.Join("CursorThemes", t.CursorTheme) } filename := path.Join(os.Getenv("HOME"), userPreviewPath, target+"-preview.png") if dutils.IsFileExist(filename) { return dutils.EncodeURI(filename, dutils.SCHEME_FILE) } filename = path.Join(systemPreviewPath, target+"-preview.png") if dutils.IsFileExist(filename) { return dutils.EncodeURI(filename, dutils.SCHEME_FILE) } return "" }
func getBackgroundInfoList(sysList, userList []PathInfo) []PathInfo { var list []PathInfo for _, dirInfo := range userList { images := getImageList(dirInfo.FilePath) for _, img := range images { var info PathInfo info.BaseName = path.Base(img) info.FilePath = dutils.EncodeURI(img, dutils.SCHEME_FILE) info.FileFlag = dirInfo.FileFlag list = append(list, info) } } for _, dirInfo := range sysList { images := getImageList(dirInfo.FilePath) for _, img := range images { if isBackgroundInInfoList(img, list) { continue } var info PathInfo info.BaseName = path.Base(img) info.FilePath = dutils.EncodeURI(img, dutils.SCHEME_FILE) info.FileFlag = dirInfo.FileFlag list = append(list, info) } } return list }
func (bg *Background) Set(uri string) error { settings := NewGSettings("com.deepin.wrap.gnome.desktop.background") defer Unref(settings) value := settings.GetString(settingsKeyPictureURI) if isBackgroundSame(uri, value) { return nil } if isBackgroundInInfoList(uri, bg.infoList) { settings.SetString(settingsKeyPictureURI, uri) return nil } // cp uri to user wallpapers src := dutils.DecodeURI(uri) if !dutils.IsFileExist(src) { src = defaultBgFile } dir := getUserWallpaper() if len(dir) == 0 { return errUserPict } filename := path.Join(dir, path.Base(src)) err := dutils.CopyFile(src, filename) if err != nil { return err } settings.SetString(settingsKeyPictureURI, dutils.EncodeURI(filename, dutils.SCHEME_FILE)) return nil }
func (greeter *GreeterTheme) GetThumbnail(theme string) string { var thumb string for _, info := range greeter.infoList { if theme == info.BaseName { thumb = path.Join(info.FilePath, "thumb.png") thumb = dutils.EncodeURI(thumb, dutils.SCHEME_FILE) break } } return thumb }
// convert local path to uri, etc "/the/path" -> "file:///the/path" func toUriPath(path string) (uriPath string) { return utils.EncodeURI(path, utils.SCHEME_FILE) }