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
if opts.attach != nil {
data.Application = opts.attach
} else if i, ok := opts.windowIcon.(string); ok {
}
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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