mirror of
https://gitlab.com/sheaf/metabrush.git
synced 2024-11-05 14:53:37 +00:00
58 lines
1.3 KiB
Haskell
58 lines
1.3 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE TypeApplications #-}
|
|
|
|
module Main
|
|
( main )
|
|
where
|
|
|
|
-- base
|
|
import Control.Monad
|
|
( void )
|
|
import System.Exit
|
|
( ExitCode(..), exitSuccess, exitWith )
|
|
import GHC.Conc
|
|
( getNumProcessors, setNumCapabilities )
|
|
|
|
-- 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 = 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 )
|