Skip to content

Commit ec07a0c

Browse files
committed
Merge pull request #56 from rcook/p-rcook-issue-55
Fixes #55: Add Mac OS X application initialization to enable support …
2 parents 581aeda + 9de1d06 commit ec07a0c

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

GUI/App.hs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{-# LANGUAGE CPP #-}
2+
3+
-------------------------------------------------------------------------------
4+
-- | Module : GUI.App
5+
--
6+
-- Platform-specific application functionality
7+
-------------------------------------------------------------------------------
8+
9+
module GUI.App (initApp) where
10+
11+
-- Imports for GTK
12+
import qualified Graphics.UI.Gtk as Gtk
13+
14+
-- Mac OS X-specific GTK imports
15+
#if defined(darwin_HOST_OS)
16+
import qualified Graphics.UI.Gtk.OSX as OSX
17+
#endif
18+
19+
-------------------------------------------------------------------------------
20+
21+
#if defined(darwin_HOST_OS)
22+
23+
-- | Initialize application
24+
-- Perform Mac OS X-specific application initialization
25+
initApp :: IO ()
26+
initApp = do
27+
app <- OSX.applicationNew
28+
menuBar <- Gtk.menuBarNew
29+
OSX.applicationSetMenuBar app menuBar
30+
OSX.applicationReady app
31+
32+
#else
33+
34+
-- | Initialize application
35+
-- Perform application initialization for non-Mac OS X platforms
36+
initApp :: IO ()
37+
initApp = return ()
38+
39+
#endif

GUI/Main.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Data.Maybe
2121
import Paths_threadscope
2222

2323
-- Imports for ThreadScope
24+
import qualified GUI.App as App
2425
import qualified GUI.MainWindow as MainWindow
2526
import GUI.Types
2627
import Events.HECs hiding (Event)
@@ -445,6 +446,8 @@ runGUI :: Maybe (Either FilePath String) -> IO ()
445446
runGUI initialTrace = do
446447
Gtk.initGUI
447448

449+
App.initApp
450+
448451
uiEnv <- constructUI
449452

450453
let post = postEvent (eventQueue uiEnv)

threadscope.cabal

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ Executable threadscope
4848
deepseq >= 1.1,
4949
text,
5050
time >= 1.1
51+
if os(osx)
52+
build-depends: gtk-mac-integration
53+
5154
Extensions: RecordWildCards, NamedFieldPuns, BangPatterns, PatternGuards
5255
Other-Modules: Events.HECs,
5356
Events.EventDuration,
@@ -56,6 +59,7 @@ Executable threadscope
5659
Events.SparkStats,
5760
Events.SparkTree,
5861
Events.TestEvents,
62+
GUI.App,
5963
GUI.Main,
6064
GUI.MainWindow,
6165
GUI.EventsView,

0 commit comments

Comments
 (0)