Skip to content

Commit e108ce4

Browse files
pengfeixxdeepin-bot[bot]
authored andcommitted
fix: Process for adapting v25 command line to set grub background
Process for adapting v25 command line to set grub background Log: Process for adapting v25 command line to set grub background pms: BUG-353671
1 parent 450f773 commit e108ce4

2 files changed

Lines changed: 18 additions & 31 deletions

File tree

adjust-grub-theme/adjust_grub_theme_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,16 @@ func (s *su) TestGetFallbackDir() {
183183
func (s *su) TestSetBackground() {
184184
defer func() {
185185
_ = os.RemoveAll(filepath.Join("testdata/deepin", "background.jpg"))
186+
_ = os.RemoveAll(filepath.Join("testdata/deepin", "background_in_theme.jpg"))
186187
_ = os.RemoveAll(filepath.Join("testdata/deepin", "background_source"))
187188
_ = os.RemoveAll(filepath.Join("testdata/deepin-fallback", "background.jpg"))
189+
_ = os.RemoveAll(filepath.Join("testdata/deepin-fallback", "background_in_theme.jpg"))
188190
}()
189-
filenamePrefix := "menu"
190191
setBackground("testdata/deepin/background.origin.jpg")
191-
for _, name := range items {
192-
fileName := strings.Join([]string{filenamePrefix, "_", name, ".png"}, "")
193-
fileNamePath := filepath.Join("testdata/deepin", fileName)
194-
assert.FileExists(s.T(), fileNamePath)
195-
_ = os.RemoveAll(fileNamePath)
196-
}
197-
192+
assert.FileExists(s.T(), filepath.Join("testdata/deepin", "background.jpg"))
193+
assert.FileExists(s.T(), filepath.Join("testdata/deepin", "background_in_theme.jpg"))
194+
assert.FileExists(s.T(), filepath.Join("testdata/deepin-fallback", "background.jpg"))
195+
assert.FileExists(s.T(), filepath.Join("testdata/deepin-fallback", "background_in_theme.jpg"))
198196
}
199197

200198
func (s *su) TestAdjustThemeNormal() {

adjust-grub-theme/main.go

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func setBackground(bgFile string) {
243243
logger.Fatal(err)
244244
}
245245

246-
bgImg, err := loadBackgroundImage()
246+
bgImg, themeBgImg, err := loadV25BackgroundImage()
247247
if err != nil {
248248
logger.Fatal(err)
249249
}
@@ -266,33 +266,22 @@ func setBackground(bgFile string) {
266266
}
267267

268268
themeOutputDir := filepath.Join(optThemeOutputDir, themeNameNormal)
269-
bgImg, err = adjustBackground(themeOutputDir, bgImg)
269+
err = saveJpeg(bgImg, filepath.Join(themeOutputDir, "background.jpg"))
270270
if err != nil {
271271
logger.Fatal(err)
272272
}
273-
274-
themeTxtFile := filepath.Join(themeOutputDir, "theme.txt")
275-
theme, err := tt.ParseThemeFile(themeTxtFile)
276-
if err != nil {
277-
logger.Warning(err)
278-
return
279-
}
280-
281-
var bmComp *tt.Component
282-
for _, comp := range theme.Components {
283-
if comp.Type == tt.ComponentTypeBootMenu {
284-
bmComp = comp
285-
break
273+
if themeBgImg != nil {
274+
err = saveJpeg(themeBgImg, filepath.Join(themeOutputDir, "background_in_theme.jpg"))
275+
if err != nil {
276+
logger.Fatal(err)
277+
}
278+
} else {
279+
_, err = copyFile(filepath.Join(themeOutputDir, "background.jpg"),
280+
filepath.Join(themeOutputDir, "background_in_theme.jpg"))
281+
if err != nil {
282+
logger.Fatal(err)
286283
}
287284
}
288-
if bmComp == nil {
289-
logger.Warning("not found boot_menu component")
290-
return
291-
}
292-
293-
convertPropRel2Abs(bmComp, "left", orientationHorizontal)
294-
convertPropRel2Abs(bmComp, "top", orientationVertical)
295-
adjustBootMenuPixmapStyle(themeOutputDir, bmComp, bgImg)
296285
}
297286

298287
func adjustTheme() {

0 commit comments

Comments
 (0)