Add missing GUI action aliases
This commit is contained in:
parent
ec66cb477c
commit
da28294f46
4 changed files with 45 additions and 0 deletions
|
|
@ -57,6 +57,7 @@ func (s *Service) OnStartup(_ context.Context) core.Result {
|
|||
s.Core().Action("clipboard.setText", setText)
|
||||
s.Core().Action("gui.clipboard.write", setText)
|
||||
s.Core().Action("clipboard.setImage", setImage)
|
||||
s.Core().Action("gui.clipboard.writeImage", setImage)
|
||||
s.Core().Action("clipboard.clear", clear)
|
||||
s.Core().Action("gui.clipboard.clear", clear)
|
||||
s.Core().Action("gui.clipboard.read", read)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,14 @@ func (s *Service) OnStartup(_ context.Context) core.Result {
|
|||
}
|
||||
return core.Result{Value: ThemeInfo{IsDark: isDark, Theme: themeName(isDark)}, OK: true}
|
||||
})
|
||||
s.Core().Action("gui.theme.set", func(_ context.Context, opts core.Options) core.Result {
|
||||
t, _ := opts.Get("task").Value.(TaskSetTheme)
|
||||
isDark, err := s.setThemeOverride(t.Theme)
|
||||
if err != nil {
|
||||
return core.Result{Value: err, OK: false}
|
||||
}
|
||||
return core.Result{Value: ThemeInfo{IsDark: isDark, Theme: themeName(isDark)}, OK: true}
|
||||
})
|
||||
|
||||
// Register theme change callback — broadcasts ActionThemeChanged via IPC
|
||||
s.cancelTheme = s.platform.OnThemeChange(func(isDark bool) {
|
||||
|
|
|
|||
|
|
@ -46,18 +46,34 @@ func (s *Service) OnStartup(_ context.Context) core.Result {
|
|||
granted, err := s.platform.RequestPermission()
|
||||
return core.Result{}.New(granted, err)
|
||||
})
|
||||
s.Core().Action("gui.notification.requestPermission", func(_ context.Context, _ core.Options) core.Result {
|
||||
granted, err := s.platform.RequestPermission()
|
||||
return core.Result{}.New(granted, err)
|
||||
})
|
||||
s.Core().Action("notification.revokePermission", func(_ context.Context, _ core.Options) core.Result {
|
||||
return core.Result{Value: nil, OK: true}.New(s.platform.RevokePermission())
|
||||
})
|
||||
s.Core().Action("gui.notification.revokePermission", func(_ context.Context, _ core.Options) core.Result {
|
||||
return core.Result{Value: nil, OK: true}.New(s.platform.RevokePermission())
|
||||
})
|
||||
s.Core().Action("notification.registerCategory", func(_ context.Context, opts core.Options) core.Result {
|
||||
t, _ := opts.Get("task").Value.(TaskRegisterCategory)
|
||||
s.categories[t.Category.ID] = t.Category
|
||||
return core.Result{OK: true}
|
||||
})
|
||||
s.Core().Action("gui.notification.registerCategory", func(_ context.Context, opts core.Options) core.Result {
|
||||
t, _ := opts.Get("task").Value.(TaskRegisterCategory)
|
||||
s.categories[t.Category.ID] = t.Category
|
||||
return core.Result{OK: true}
|
||||
})
|
||||
s.Core().Action("notification.clear", func(_ context.Context, opts core.Options) core.Result {
|
||||
t, _ := opts.Get("task").Value.(TaskClear)
|
||||
return core.Result{Value: nil, OK: true}.New(s.clear(t.ID))
|
||||
})
|
||||
s.Core().Action("gui.notification.clear", func(_ context.Context, opts core.Options) core.Result {
|
||||
t, _ := opts.Get("task").Value.(TaskClear)
|
||||
return core.Result{Value: nil, OK: true}.New(s.clear(t.ID))
|
||||
})
|
||||
s.Core().Action("notification.send", send)
|
||||
s.Core().Action("gui.notification.send", send)
|
||||
return core.Result{OK: true}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,26 @@ func (s *Service) OnStartup(_ context.Context) core.Result {
|
|||
return core.Result{Value: err, OK: false}
|
||||
}
|
||||
})
|
||||
s.Core().Action("gui.tray.showMessage", func(_ context.Context, opts core.Options) core.Result {
|
||||
t := taskShowMessageFromOptions(opts)
|
||||
if err := s.manager.ShowMessage(t.Title, t.Message); err == nil {
|
||||
return core.Result{OK: true}
|
||||
} else {
|
||||
fallback := s.Core().Action("notification.send").Run(context.Background(), core.NewOptions(
|
||||
core.Option{Key: "task", Value: notification.TaskSend{Options: notification.NotificationOptions{
|
||||
Title: t.Title,
|
||||
Message: t.Message,
|
||||
}}},
|
||||
))
|
||||
if fallback.OK {
|
||||
return core.Result{OK: true}
|
||||
}
|
||||
if fallbackErr, ok := fallback.Value.(error); ok {
|
||||
return core.Result{Value: coreerr.E("systray.showMessage", "tray message failed and notification fallback failed", fallbackErr), OK: false}
|
||||
}
|
||||
return core.Result{Value: err, OK: false}
|
||||
}
|
||||
})
|
||||
s.Core().Action("systray.showPanel", func(_ context.Context, _ core.Options) core.Result {
|
||||
// Panel show — deferred (requires WindowHandle integration)
|
||||
return core.Result{OK: true}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue