view src/name/blackcap/imageprep/Osdep.kt.mac.osdep @ 25:a495f9ea498b mac-open

Initial attempts to make it respond to MacOS open message (not working).
author David Barts <n5jrn@me.com>
date Sun, 13 Dec 2020 10:29:08 -0800
parents 5fa5d15b4a7b
children
line wrap: on
line source

/*
 * OS-dependent code, Mac version.
 */
package name.blackcap.imageprep

import com.apple.eawt.AboutHandler
import com.apple.eawt.OpenFilesHandler
import com.apple.eawt.PreferencesHandler
import com.apple.eawt.QuitStrategy
import java.util.logging.Level
import java.util.logging.Logger

fun setMacMenus() {
    com.apple.eawt.Application.getApplication().run {
        setAboutHandler(AboutHandler { showAboutDialog() })
        setOpenFileHandler(OpenFilesHandler {
            LOGGER.log(Level.INFO, "got open request")
            for (file in it.files) {
                LOGGER.log(Level.INFO, "opening: ${file.toString()}")
                RotateDialog.makeDialog(file, Application.settingsDialog.maxDimension)
            }
        })
        setPreferencesHandler(
            PreferencesHandler { Application.settingsDialog.setVisible(true) })
        setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS)
    }
}