Skip to content

Commit

Permalink
Locate resources directory starting from path to executable
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed May 13, 2014
1 parent 71d9cb8 commit e69d931
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
22 changes: 15 additions & 7 deletions Dhek/GUI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import Data.Foldable (traverse_)
--------------------------------------------------------------------------------
import Control.Lens ((^.))
import qualified Graphics.UI.Gtk as Gtk
import System.FilePath (joinPath)
import System.FilePath (joinPath, dropFileName)
import System.Environment.Executable (getExecutablePath)

import Debug.Trace (trace)

--------------------------------------------------------------------------------
import Dhek.I18N
Expand Down Expand Up @@ -93,6 +96,10 @@ makeGUI = do
Gtk.FileChooserActionOpen
msgStr

-- Runtime directories
execPath <- getExecutablePath
let resDir = joinPath [dropFileName execPath, "resources"]

-- Menu Bar
mbar <- Gtk.menuBarNew
fmenu <- Gtk.menuNew
Expand All @@ -116,33 +123,33 @@ makeGUI = do

-- Button Next
next <- Gtk.buttonNew
nimg <- Gtk.imageNewFromFile $ joinPath ["resources", "page-next.png"]
nimg <- Gtk.imageNewFromFile $ joinPath [resDir, "page-next.png"]
Gtk.buttonSetImage next nimg

-- Previous Prev
prev <- Gtk.buttonNew
pimg <- Gtk.imageNewFromFile $ joinPath ["resources", "page-previous.png"]
pimg <- Gtk.imageNewFromFile $ joinPath [resDir, "page-previous.png"]
Gtk.buttonSetImage prev pimg

-- Button Zoom out
minus <- Gtk.buttonNew
oimg <- Gtk.imageNewFromFile $ joinPath ["resources", "zoom-out.png"]
oimg <- Gtk.imageNewFromFile $ joinPath [resDir, "zoom-out.png"]
Gtk.buttonSetImage minus oimg

-- Button Zoom in
plus <- Gtk.buttonNew
iimg <- Gtk.imageNewFromFile $ joinPath ["resources", "zoom-in.png"]
iimg <- Gtk.imageNewFromFile $ joinPath [resDir, "zoom-in.png"]
Gtk.buttonSetImage plus iimg

-- Button Draw
drwb <- Gtk.toggleButtonNew
dimg <- Gtk.imageNewFromFile $ joinPath ["resources", "draw.png"]
dimg <- Gtk.imageNewFromFile $ joinPath [resDir, "draw.png"]
Gtk.buttonSetImage drwb dimg
Gtk.toggleButtonSetActive drwb True

-- Button MultiSelection
msb <- Gtk.toggleButtonNew
simg <- Gtk.imageNewFromFile $ joinPath ["resources", "multisel.png"]
simg <- Gtk.imageNewFromFile $ joinPath [resDir, "multisel.png"]
Gtk.buttonSetImage msb simg

-- Toolbar
Expand Down Expand Up @@ -201,6 +208,7 @@ makeGUI = do
atswin <- Gtk.alignmentNew 0 0 1 1
col <- Gtk.treeViewColumnNew
trend <- Gtk.cellRendererTextNew

let mapping r = [Gtk.cellText Gtk.:= r ^. rectName]
Gtk.treeViewColumnSetTitle col $ msgStr $ MsgAreas
Gtk.cellLayoutPackStart col trend False
Expand Down
1 change: 1 addition & 0 deletions dhek.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ executable dhek
, mtl >= 2.1.2
, cairo >= 0.12.4
, filepath >= 1.3.0 && < 1.3.1
, executable-path == 0.0.3
, aeson == 0.7.*
, bytestring >= 0.9.2.1 && < 0.11
, containers >= 0.4.0 && < 0.6
Expand Down
1 change: 1 addition & 0 deletions util/macosx-mkapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mkdir -p "$BUILDDIR/$APPNAME.app/Contents/MacOS/lib"
mkdir -p "$BUILDDIR/$APPNAME.app/Contents/Resources"

cp "$BINPATH" "$BUILDDIR/$APPNAME.app/Contents/MacOS/"
cp -R `dirname $0`/../resources "$BUILDDIR/$APPNAME.app/Contents/MacOS/resources"

echo "Will process dependencies ..."
DEPS=`otool -L "$BUILDDIR/$APPNAME.app/Contents/MacOS/$BINFILE" | grep '.dylib' | grep -v '@' | grep -v '/usr/lib' | awk '{ printf("%s\n", $1); }'`
Expand Down
2 changes: 1 addition & 1 deletion util/win-msys2-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mkdir -p "$DISTDIR/bin"

cp dist/build/dhek/dhek.exe "$DISTDIR/bin/"
cp util/win-dlls/*.dll "$DISTDIR/bin/"
cp -R resources "$DISTDIR/resources"
cp -R resources "$DISTDIR/bin/resources"

cat > "$DISTDIR/dhek.bat" << EOF
start bin\dhek.exe
Expand Down

0 comments on commit e69d931

Please sign in to comment.