mirror of
https://gitlab.com/sheaf/metabrush.git
synced 2024-11-05 23:03:38 +00:00
61 lines
1.3 KiB
Haskell
61 lines
1.3 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Main
|
|
( main )
|
|
where
|
|
|
|
-- base
|
|
import Control.Monad
|
|
( void )
|
|
import System.Exit
|
|
( ExitCode(..), exitSuccess, exitWith )
|
|
import GHC.Conc
|
|
( getNumProcessors, setNumCapabilities )
|
|
|
|
-- code-page
|
|
import System.IO.CodePage
|
|
( withCP65001 )
|
|
|
|
-- gi-gio
|
|
import qualified GI.Gio as GIO
|
|
|
|
-- gi-gobject
|
|
import qualified GI.GObject as GObject
|
|
|
|
-- gi-gtk
|
|
import qualified GI.Gtk as GTK
|
|
|
|
-- MetaBrush
|
|
import MetaBrush.Application
|
|
( runApplication )
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
main :: IO ()
|
|
main = withCP65001 do
|
|
|
|
procs <- getNumProcessors
|
|
let
|
|
caps :: Int
|
|
caps
|
|
| procs >= 6
|
|
= procs - 2
|
|
| procs >= 2
|
|
= procs - 1
|
|
| otherwise
|
|
= procs
|
|
setNumCapabilities caps
|
|
|
|
---------------------------------------------------------
|
|
-- Run GTK application
|
|
|
|
application <- GTK.applicationNew ( Just "com.calligraphy.MetaBrush" ) [ GIO.ApplicationFlagsNonUnique ]
|
|
GIO.applicationRegister application ( Nothing @GIO.Cancellable )
|
|
void $ GIO.onApplicationActivate application ( runApplication application )
|
|
exitCode <- GIO.applicationRun application Nothing
|
|
GObject.objectUnref application
|
|
|
|
case exitCode of
|
|
0 -> exitSuccess
|
|
_ -> exitWith ( ExitFailure $ fromIntegral exitCode )
|