From 074ee459619883ea28c88c1c00507a4354365f37 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 18 Dec 2015 14:11:26 +0100 Subject: [PATCH] GTK: allow to start gui with specific directory --- src/GUI/Gtk.hs | 13 ++++++++++++- src/GUI/Gtk/Gui.hs | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/GUI/Gtk.hs b/src/GUI/Gtk.hs index 4a60bf7..552bbb4 100644 --- a/src/GUI/Gtk.hs +++ b/src/GUI/Gtk.hs @@ -4,11 +4,22 @@ module Main where import Graphics.UI.Gtk import GUI.Gtk.Gui +import Safe + ( + headDef + ) +import System.Environment + ( + getArgs + ) + main :: IO () main = do _ <- initGUI - startMainWindow + args <- getArgs + + startMainWindow (headDef "/" args) mainGUI diff --git a/src/GUI/Gtk/Gui.hs b/src/GUI/Gtk/Gui.hs index 42e221e..6858883 100644 --- a/src/GUI/Gtk/Gui.hs +++ b/src/GUI/Gtk/Gui.hs @@ -458,8 +458,8 @@ withErrorDialog io = do -- |Set up the GUI. -startMainWindow :: IO () -startMainWindow = do +startMainWindow :: FilePath -> IO () +startMainWindow startdir = do settings <- newTVarIO (MkFMSettings False True) @@ -469,7 +469,7 @@ startMainWindow = do filePix <- getIcon IFile 24 errorPix <- getIcon IError 24 - fsState <- readPath' "/" >>= newTVarIO + fsState <- readPath' startdir >>= newTVarIO operationBuffer <- newTVarIO (Right None)