Skip to content

Commit 79b571b

Browse files
committed
Merge pull request #5 from leksah/master
Migrate from String to Text
2 parents 2e69c95 + d192e64 commit 79b571b

23 files changed

+232
-144
lines changed

.travis.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
language: haskell
1+
env:
2+
- GHCVER=7.4.1
3+
- GHCVER=7.4.2
4+
- GHCVER=7.6.3
5+
- GHCVER=7.8.3
6+
27
before_install:
8+
- sudo add-apt-repository -y ppa:hvr/ghc
39
- sudo apt-get update -qq
4-
- sudo apt-get --no-install-recommends install libgtksourceview-3.0-dev alex happy
5-
- cabal install Cabal
6-
- cabal install cabal-install
7-
- PATH="$HOME/.cabal/bin:$PATH" cabal install gtk2hs-buildtools
10+
- sudo apt-get --no-install-recommends install libgtk2.0-dev libgtk-3-dev
11+
- sudo apt-get install cabal-install-1.20 ghc-$GHCVER
12+
- export PATH=$HOME/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/1.20/bin:$PATH
13+
- cabal update
14+
- |
15+
if [ $GHCVER = "head" ] || [ ${GHCVER%.*} = "7.8" ]; then
16+
sudo apt-get install happy-1.19.3 alex-3.1.3
17+
export PATH=/opt/alex/3.1.3/bin:/opt/happy/1.19.3/bin:$PATH
18+
else
19+
sudo apt-get install happy alex
20+
fi
21+
822
install:
9-
- PATH="$HOME/.cabal/bin:$PATH" cabal install cabal-meta cabal-src
23+
- cabal install Cabal
24+
- cabal install gtk2hs-buildtools
25+
1026
script:
11-
- PATH="$HOME/.cabal/bin:$PATH" cabal-meta install --force-reinstalls
27+
- cabal install
28+
1229
notifications:
1330
irc:
1431
channels: "irc.freenode.net#leksah"
32+
skip_join: true
1533
email: true

vcsgui/src/VCSGui/Common/Commit.hs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE OverloadedStrings #-}
12
-----------------------------------------------------------------------------
23
--
34
-- Module : Main
@@ -30,6 +31,8 @@ import Control.Monad
3031
import Control.Monad.Reader
3132
import Data.Maybe
3233
import Paths_vcsgui(getDataFileName)
34+
import qualified Data.Text as T (unpack, pack)
35+
import Data.Text (Text)
3336

3437
--
3538
-- glade path and object accessors
@@ -47,7 +50,7 @@ accessorActTxtViewMsg = "txtViewMsg"
4750
--
4851

4952
-- | This function will be called after the ok action is called.
50-
type OkCallBack = String -- ^ Commit message as specified in the GUI.
53+
type OkCallBack = Text -- ^ Commit message as specified in the GUI.
5154
-> [FilePath] -- ^ List of 'FilePath's of the files that were selected.
5255
-> [Option] -- ^ options (this is currently not implemented i.e. '[]' is passed)
5356
-> Wrapper.Ctx ()
@@ -66,8 +69,8 @@ data CommitGUI = CommitGUI {
6669
}
6770

6871
-- | Represents a file which can be selected for commiting.
69-
data SCFile = GITSCFile Bool FilePath String |
70-
SVNSCFile Bool FilePath String Bool
72+
data SCFile = GITSCFile Bool FilePath Text |
73+
SVNSCFile Bool FilePath Text Bool
7174
deriving (Show)
7275

7376
-- | Return 'True' if the 'SCFile' is flagged as selected.
@@ -81,7 +84,7 @@ filePath (GITSCFile _ fp _ ) = fp
8184
filePath (SVNSCFile _ fp _ _) = fp
8285

8386
-- | Return the status of this file.
84-
status :: SCFile -> String
87+
status :: SCFile -> Text
8588
status (GITSCFile _ _ s) = s
8689
status (SVNSCFile _ _ s _) = s
8790

@@ -92,7 +95,7 @@ isLocked _ = False
9295

9396

9497
-- | Options to the 'OkCallBack'.
95-
type Option = String
98+
type Option = Text
9699

97100

98101
-- | Display a window to enter a commit message and select files to be commited.
@@ -150,7 +153,7 @@ getSelectedFiles listStore = do
150153
return (selectedFiles)
151154

152155
getTreeViewFromGladeCustomStore :: Builder
153-
-> String
156+
-> Text
154157
-> TreeViewSetter
155158
-> Wrapper.Ctx (H.TreeViewItem SCFile)
156159
getTreeViewFromGladeCustomStore builder name setupListStore = do
@@ -166,9 +169,9 @@ getTreeViewFromGladeCustomStore builder name setupListStore = do
166169
wrapWidget :: GObjectClass objClass =>
167170
Builder
168171
-> (GObject -> objClass)
169-
-> String -> IO (String, objClass)
172+
-> Text -> IO (Text, objClass)
170173
wrapWidget builder cast name = do
171-
putStrLn $ " cast " ++ name
174+
putStrLn $ " cast " ++ T.unpack name
172175
gobj <- builderGetObject builder cast name
173176
return (name, gobj)
174177

vcsgui/src/VCSGui/Common/ConflictsResolved.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE OverloadedStrings #-}
12
-----------------------------------------------------------------------------
23
--
34
-- Module : VCSGui.Common.ConflictsResolved

vcsgui/src/VCSGui/Common/Error.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE OverloadedStrings #-}
12
-----------------------------------------------------------------------------
23
--
34
-- Module : VCSGui.Common.Error
@@ -15,11 +16,12 @@
1516
module VCSGui.Common.Error (
1617
showErrorGUI
1718
) where
18-
import Graphics.UI.Gtk
1919

20+
import Graphics.UI.Gtk
21+
import Data.Text (Text)
2022

2123
-- | Displays a simple window displaying given 'String' as an error message.
22-
showErrorGUI :: String -- ^ Message to display.
24+
showErrorGUI :: Text -- ^ Message to display.
2325
-> IO ()
2426
showErrorGUI msg = do
2527
dialog <- messageDialogNew Nothing [] MessageError ButtonsOk msg

vcsgui/src/VCSGui/Common/ExceptionHandler.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE OverloadedStrings #-}
12
-----------------------------------------------------------------------------
23
--
34
-- Module : VCSGui.Common.ExceptionHandler
@@ -20,6 +21,8 @@ import qualified Control.Exception as Exc
2021

2122
import VCSWrapper.Common
2223
import VCSGui.Common.Error
24+
import qualified Data.Text as T (unwords, unlines)
25+
import Data.Monoid ((<>))
2326

2427

2528
-- | Wraps an IO computation to display an error message if a 'VCSException' occurs.
@@ -30,7 +33,7 @@ defaultVCSExceptionHandler vcsRunner = do
3033
case o of
3134
Left (VCSException exitCode out err repoLocation (cmd:opts)) -> do
3235
putStrLn $ "exception caught"
33-
showErrorGUI $ unlines ["An error occured.", err, "Details:", "command: " ++ cmd, "options: " ++ unwords opts]
36+
showErrorGUI $ T.unlines ["An error occured.", err, "Details:", "command: " <> cmd, "options: " <> T.unwords opts]
3437
Right _ -> do
3538
putStrLn $ "no exception"
3639
return ()

vcsgui/src/VCSGui/Common/FilesInConflict.hs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE ScopedTypeVariables #-}
2+
{-# LANGUAGE OverloadedStrings #-}
13
-----------------------------------------------------------------------------
24
--
35
-- Module : VCSGui.Common.FilesInConflict
@@ -28,6 +30,8 @@ import Control.Monad.Trans(liftIO)
2830
import Control.Monad
2931
import Control.Monad.Reader
3032
import Paths_vcsgui(getDataFileName)
33+
import Data.Text (Text)
34+
import qualified Data.Text as T (unpack, pack)
3135

3236
--
3337
-- glade path and object accessors
@@ -93,7 +97,7 @@ showFilesInConflictGUI (Just setUpTreeView) filesInConflict filesToResolveGetter
9397
gui <- loadGUI $ setUpTreeView cwd filesInConflict filesToResolveGetter resolveMarker eMergeToolSetter
9498
mbMergeToolSetter <- case eMergeToolSetter of
9599
Left (Merge.MergeTool path) -> do
96-
liftIO $ H.set (entPath gui) path
100+
liftIO $ H.set (entPath gui) $ T.pack path
97101
return Nothing
98102
Right setter -> return $ Just setter
99103

@@ -111,7 +115,7 @@ showFilesInConflictGUI (Just setUpTreeView) filesInConflict filesToResolveGetter
111115
Nothing -> return ()
112116
Just path -> do
113117
-- update gui
114-
H.set (entPath gui) path
118+
H.set (entPath gui) $ T.pack path
115119
-- call setter
116120
case mbMergeToolSetter of
117121
Nothing -> return ()
@@ -154,7 +158,7 @@ defaultSetUpTreeView mbcwd conflictingFiles filesToResolveGetter resolveMarker e
154158
H.addColumnToTreeView' treeViewItem
155159
renderer
156160
"File"
157-
$ \scf -> [cellText := filePath scf]
161+
$ \scf -> [cellText := T.pack $ filePath scf]
158162

159163
renderer <- cellRendererToggleNew
160164
H.addColumnToTreeView' treeViewItem
@@ -163,7 +167,7 @@ defaultSetUpTreeView mbcwd conflictingFiles filesToResolveGetter resolveMarker e
163167
$ \scf -> [cellToggleActive := isResolved scf]
164168

165169
-- connect select action
166-
on renderer cellToggled $ \columnId -> do
170+
on renderer cellToggled $ \(columnId :: Text) -> do
167171
putStrLn $ "Checkbutton clicked at column " ++ (show columnId)
168172
--TODO only call tool if button is not checked, move this code to being called if a click on row is received
169173
let callTool' = (\path -> Wrapper.runVcs config $ callTool columnId listStore path)
@@ -181,7 +185,7 @@ defaultSetUpTreeView mbcwd conflictingFiles filesToResolveGetter resolveMarker e
181185
Just treeIter <- liftIO $ treeModelGetIterFromString listStore columnId
182186
value <- liftIO $ listStoreGetValue listStore $ listStoreIterToIndex treeIter
183187
filesToResolve <- filesToResolveGetter $ filePath value
184-
resolvedByTool <- liftIO $ Process.exec mbcwd pathToTool filesToResolve
188+
resolvedByTool <- liftIO $ Process.exec mbcwd pathToTool $ map T.pack filesToResolve
185189
let setResolved' = setResolved listStore treeIter value
186190
case resolvedByTool of
187191
False -> ConflictsResolvedGUI.showConflictsResolvedGUI
@@ -203,7 +207,7 @@ defaultSetUpTreeView mbcwd conflictingFiles filesToResolveGetter resolveMarker e
203207
----
204208

205209
getTreeViewFromGladeCustomStore :: Builder
206-
-> String
210+
-> Text
207211
-> (TreeView -> Wrapper.Ctx (ListStore SCFile)) -- ^ fn defining how to setup the liststore
208212
-> Wrapper.Ctx (H.TreeViewItem SCFile)
209213
getTreeViewFromGladeCustomStore builder name setupListStore = do
@@ -219,9 +223,9 @@ getTreeViewFromGladeCustomStore builder name setupListStore = do
219223
wrapWidget :: GObjectClass objClass =>
220224
Builder
221225
-> (GObject -> objClass)
222-
-> String -> IO (String, objClass)
226+
-> Text -> IO (Text, objClass)
223227
wrapWidget builder cast name = do
224-
putStrLn $ " cast " ++ name
228+
putStrLn $ " cast " ++ T.unpack name
225229
gobj <- builderGetObject builder cast name
226230
return (name, gobj)
227231

@@ -244,7 +248,7 @@ setToListStore (store, view) newList = do
244248
-- HELPER
245249

246250
-- | shows a dialog to choose a folder, returns Just FilePath to folder if succesfull, Nothing if cancelled
247-
showFolderChooserDialog :: String -- ^ title of the window
251+
showFolderChooserDialog :: Text -- ^ title of the window
248252
-> Window -- ^ parent window
249253
-> FileChooserAction
250254
-> IO (Maybe FilePath)

0 commit comments

Comments
 (0)