Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions adjust-grub-theme/adjust_grub_theme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,16 @@ func (s *su) TestGetFallbackDir() {
func (s *su) TestSetBackground() {
defer func() {
_ = os.RemoveAll(filepath.Join("testdata/deepin", "background.jpg"))
_ = os.RemoveAll(filepath.Join("testdata/deepin", "background_in_theme.jpg"))
_ = os.RemoveAll(filepath.Join("testdata/deepin", "background_source"))
_ = os.RemoveAll(filepath.Join("testdata/deepin-fallback", "background.jpg"))
_ = os.RemoveAll(filepath.Join("testdata/deepin-fallback", "background_in_theme.jpg"))
}()
filenamePrefix := "menu"
setBackground("testdata/deepin/background.origin.jpg")
for _, name := range items {
fileName := strings.Join([]string{filenamePrefix, "_", name, ".png"}, "")
fileNamePath := filepath.Join("testdata/deepin", fileName)
assert.FileExists(s.T(), fileNamePath)
_ = os.RemoveAll(fileNamePath)
}

assert.FileExists(s.T(), filepath.Join("testdata/deepin", "background.jpg"))
assert.FileExists(s.T(), filepath.Join("testdata/deepin", "background_in_theme.jpg"))
assert.FileExists(s.T(), filepath.Join("testdata/deepin-fallback", "background.jpg"))
assert.FileExists(s.T(), filepath.Join("testdata/deepin-fallback", "background_in_theme.jpg"))
}

func (s *su) TestAdjustThemeNormal() {
Expand Down
35 changes: 12 additions & 23 deletions adjust-grub-theme/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func setBackground(bgFile string) {
logger.Fatal(err)
}

bgImg, err := loadBackgroundImage()
bgImg, themeBgImg, err := loadV25BackgroundImage()
if err != nil {
logger.Fatal(err)
}
Expand All @@ -266,33 +266,22 @@ func setBackground(bgFile string) {
}

themeOutputDir := filepath.Join(optThemeOutputDir, themeNameNormal)
bgImg, err = adjustBackground(themeOutputDir, bgImg)
err = saveJpeg(bgImg, filepath.Join(themeOutputDir, "background.jpg"))
if err != nil {
logger.Fatal(err)
}

themeTxtFile := filepath.Join(themeOutputDir, "theme.txt")
theme, err := tt.ParseThemeFile(themeTxtFile)
if err != nil {
logger.Warning(err)
return
}

var bmComp *tt.Component
for _, comp := range theme.Components {
if comp.Type == tt.ComponentTypeBootMenu {
bmComp = comp
break
if themeBgImg != nil {
err = saveJpeg(themeBgImg, filepath.Join(themeOutputDir, "background_in_theme.jpg"))
if err != nil {
logger.Fatal(err)
}
} else {
_, err = copyFile(filepath.Join(themeOutputDir, "background.jpg"),
filepath.Join(themeOutputDir, "background_in_theme.jpg"))
if err != nil {
logger.Fatal(err)
}
}
if bmComp == nil {
logger.Warning("not found boot_menu component")
return
}

convertPropRel2Abs(bmComp, "left", orientationHorizontal)
convertPropRel2Abs(bmComp, "top", orientationVertical)
adjustBootMenuPixmapStyle(themeOutputDir, bmComp, bgImg)
}

func adjustTheme() {
Expand Down
Loading