Fix window icons (macOS).

This commit is contained in:
Nuno Cruces 2022-06-08 23:52:44 +01:00
parent 2bedb36257
commit 3adf86dd39
10 changed files with 26 additions and 12 deletions

View File

@ -10,7 +10,8 @@ func selectColor(opts options) (color.Color, error) {
var data zenutil.Color var data zenutil.Color
if opts.attach != nil { if opts.attach != nil {
data.Application = opts.attach data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok { }
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }

View File

@ -25,6 +25,9 @@ func calendar(text string, opts options) (t time.Time, err error) {
} else { } else {
data.Text = text data.Text = text
} }
if opts.attach != nil {
data.Application = opts.attach
}
if i, ok := opts.windowIcon.(string); ok { if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }

View File

@ -16,7 +16,8 @@ func entry(text string, opts options) (string, error) {
data.Options.Timeout = zenutil.Timeout data.Options.Timeout = zenutil.Timeout
if opts.attach != nil { if opts.attach != nil {
data.Application = opts.attach data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok { }
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }
switch i := opts.icon.(type) { switch i := opts.icon.(type) {

View File

@ -9,7 +9,8 @@ func selectFile(opts options) (string, error) {
data.Options.Location, _ = splitDirAndName(opts.filename) data.Options.Location, _ = splitDirAndName(opts.filename)
if opts.attach != nil { if opts.attach != nil {
data.Application = opts.attach data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok { }
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }
@ -33,7 +34,8 @@ func selectFileMultiple(opts options) ([]string, error) {
data.Separator = zenutil.Separator data.Separator = zenutil.Separator
if opts.attach != nil { if opts.attach != nil {
data.Application = opts.attach data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok { }
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }
@ -55,7 +57,8 @@ func selectFileSave(opts options) (string, error) {
data.Options.Location, data.Options.Name = splitDirAndName(opts.filename) data.Options.Location, data.Options.Name = splitDirAndName(opts.filename)
if opts.attach != nil { if opts.attach != nil {
data.Application = opts.attach data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok { }
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }

View File

@ -27,11 +27,11 @@ var app=Application({{json .Application}})
{{- else}} {{- else}}
var app=Application.currentApplication() var app=Application.currentApplication()
{{- end}} {{- end}}
{{- if .WindowIcon}}{ObjC.import('Cocoa') {{if .WindowIcon}}{ObjC.import('Cocoa')
let nsapp=$.NSApplication.sharedApplication let nsapp=$.NSApplication.sharedApplication
let nsimg=$.NSImage.alloc.initWithContentsOfFile({{json .WindowIcon}}) let nsimg=$.NSImage.alloc.initWithContentsOfFile({{json .WindowIcon}})
nsapp.setActivationPolicy($.NSApplicationActivationPolicyRegular) nsapp.setActivationPolicy($.NSApplicationActivationPolicyRegular)
nsapp.setApplicationIconImage(nsimg)}{{- end}} nsapp.setApplicationIconImage(nsimg)}{{end}}
app.includeStandardAdditions=true app.includeStandardAdditions=true
app.activate() app.activate()
{{- end}} {{- end}}

View File

@ -4,13 +4,13 @@
var app = Application.currentApplication() var app = Application.currentApplication()
{{- end}} {{- end}}
{{- if .WindowIcon}}{ {{if .WindowIcon}}{
ObjC.import('Cocoa') ObjC.import('Cocoa')
let nsapp = $.NSApplication.sharedApplication let nsapp = $.NSApplication.sharedApplication
let nsimg = $.NSImage.alloc.initWithContentsOfFile({{json .WindowIcon}}) let nsimg = $.NSImage.alloc.initWithContentsOfFile({{json .WindowIcon}})
nsapp.setActivationPolicy($.NSApplicationActivationPolicyRegular) nsapp.setActivationPolicy($.NSApplicationActivationPolicyRegular)
nsapp.setApplicationIconImage(nsimg) nsapp.setApplicationIconImage(nsimg)
}{{- end}} }{{end}}
app.includeStandardAdditions = true app.includeStandardAdditions = true
app.activate() app.activate()

View File

@ -24,7 +24,8 @@ func list(text string, items []string, opts options) (string, error) {
data.Options.Empty = !opts.disallowEmpty data.Options.Empty = !opts.disallowEmpty
if opts.attach != nil { if opts.attach != nil {
data.Application = opts.attach data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok { }
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }

View File

@ -12,7 +12,8 @@ func message(kind messageKind, text string, opts options) error {
data.Options.Timeout = zenutil.Timeout data.Options.Timeout = zenutil.Timeout
if opts.attach != nil { if opts.attach != nil {
data.Application = opts.attach data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok { }
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }

View File

@ -19,6 +19,9 @@ func progress(opts options) (ProgressDialog, error) {
if opts.maxValue >= 0 { if opts.maxValue >= 0 {
data.Total = &opts.maxValue data.Total = &opts.maxValue
} }
if opts.attach != nil {
data.Application = opts.attach
}
if i, ok := opts.windowIcon.(string); ok { if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }

View File

@ -20,7 +20,8 @@ func password(opts options) (string, string, error) {
data.Options.Timeout = zenutil.Timeout data.Options.Timeout = zenutil.Timeout
if opts.attach != nil { if opts.attach != nil {
data.Application = opts.attach data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok { }
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i data.WindowIcon = i
} }
switch i := opts.icon.(type) { switch i := opts.icon.(type) {