Skip to content

Commit 456d8f6

Browse files
committed
win32: system tray icon, new images and settings hight
1 parent 581954f commit 456d8f6

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

-3.55 KB
Loading

images/win32-taskmanager-menu.png

-12.7 KB
Loading

internal/ui/settings.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (u *UIManager) ShowSettings(cfg *config.Config, onSave func(*config.Config)
4242
if float32(screenW) < winW {
4343
winW = float32(screenW) * 0.9
4444
}
45-
winH := float32(screenH) * 0.55
45+
winH := float32(screenH) * 0.40
4646
win.Resize(fyne.NewSize(winW, winH))
4747

4848
state := &settingsState{
@@ -303,7 +303,7 @@ func (u *UIManager) ShowSettings(cfg *config.Config, onSave func(*config.Config)
303303
dialog.ShowError(fmt.Errorf("city name is required to search"), win)
304304
return
305305
}
306-
306+
307307
apiKey := strings.TrimSpace(apiKeyEntry.Text)
308308
if apiKey == "" {
309309
dialog.ShowError(fmt.Errorf("API Key is required in the settings above to search via OWM"), win)
@@ -326,12 +326,12 @@ func (u *UIManager) ShowSettings(cfg *config.Config, onSave func(*config.Config)
326326
return
327327
}
328328
defer resp.Body.Close()
329-
329+
330330
if resp.StatusCode != http.StatusOK {
331331
fyne.Do(func() { dialog.ShowError(fmt.Errorf("search API error: %d", resp.StatusCode), win) })
332332
return
333333
}
334-
334+
335335
body, err := io.ReadAll(resp.Body)
336336
if err != nil {
337337
fyne.Do(func() { dialog.ShowError(fmt.Errorf("read error: %v", err), win) })
@@ -349,12 +349,12 @@ func (u *UIManager) ShowSettings(cfg *config.Config, onSave func(*config.Config)
349349
fyne.Do(func() { dialog.ShowError(fmt.Errorf("failed to parse search response: %v", err), win) })
350350
return
351351
}
352-
352+
353353
if len(results) == 0 {
354354
fyne.Do(func() { dialog.ShowError(fmt.Errorf("no city found matching '%s'", searchName), win) })
355355
return
356356
}
357-
357+
358358
res := results[0]
359359
region := res.Country
360360
if res.State != "" {

internal/ui/tray.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package ui
22

33
import (
44
"log"
5+
"weatherwidget/assets"
56

67
"fyne.io/fyne/v2"
78
"fyne.io/fyne/v2/driver/desktop"
8-
"fyne.io/fyne/v2/theme"
99
)
1010

1111
// SetupSystemTray configures the system tray icon and menu.
@@ -23,8 +23,13 @@ func (u *UIManager) SetupSystemTray(appDataDir string, onSettings func(), onExit
2323
return
2424
}
2525

26-
// Using a Fyne default vector icon to test if the tray is capable of rendering at all.
27-
res := theme.SettingsIcon()
26+
// Load the tray icon from embedded assets.
27+
iconData, err := assets.Icons.ReadFile("icons/clear_tray.png")
28+
if err != nil {
29+
log.Printf("warning: failed to load tray icon: %v, continuing without custom icon", err)
30+
return
31+
}
32+
res := fyne.NewStaticResource("clear_tray.png", iconData)
2833
u.app.SetIcon(res)
2934
desk.SetSystemTrayIcon(res)
3035

0 commit comments

Comments
 (0)