diff --git a/leksah.cabal b/leksah.cabal index 3af667ca..3fcba365 100644 --- a/leksah.cabal +++ b/leksah.cabal @@ -63,6 +63,7 @@ data-files: pics/ide_error_next.png pics/ide_error_prev.png pics/ide_function.png + pics/ide_git.png pics/ide_instance.png pics/ide_konstructor.png pics/ide_make.png diff --git a/pics/ide_git.png b/pics/ide_git.png new file mode 100644 index 00000000..a506d170 Binary files /dev/null and b/pics/ide_git.png differ diff --git a/src/IDE/Command.hs b/src/IDE/Command.hs index bb6776e5..29fad8ff 100644 --- a/src/IDE/Command.hs +++ b/src/IDE/Command.hs @@ -717,7 +717,7 @@ newIcons = catch (do "ide_debug", "ide_step", "ide_local", "ide_module", "ide_continue", "ide_rebuild_meta", "ide_empty","ide_source_local", "ide_js", "ide_folder", "ide_source_folder", "ide_cabal_file", "ide_package", "ide_component", "ide_source_dependency", "ide_error", - "ide_warning", "ide_suggestion" ] + "ide_warning", "ide_suggestion", "ide_git" ] iconFactoryAddDefault iconFactory) (\(e :: SomeException) -> getDataDir >>= \dataDir -> throwIDE (T.pack $ printf (__ "Can't load icons from %s %s") dataDir (show e))) where diff --git a/src/IDE/Pane/Workspace.hs b/src/IDE/Pane/Workspace.hs index 58cc5085..226b4b39 100644 --- a/src/IDE/Pane/Workspace.hs +++ b/src/IDE/Pane/Workspace.hs @@ -125,6 +125,7 @@ import Data.GI.Gtk.ModelView.CustomStore import Data.Int (Int32) import Data.GI.Gtk.ModelView.Types (treePathGetIndices', treePathNewFromIndices') +import VCSWrapper.Git as Git -- | The data for a single record in the Workspace Pane @@ -160,8 +161,8 @@ toMarkup record pkg = do mbActivePackage <- readIDE activePack mbActiveComponent <- readIDE activeExe - return . size $ case record of - (PackageRecord p) -> + case record of + (PackageRecord p) -> return $ let active = Just pkg == mbActivePackage pkgText = (if active then bold else id) (packageIdentifierToString (ipdPackageId p)) @@ -172,24 +173,28 @@ toMarkup record pkg = do else "" pkgDir = gray . T.pack $ ipdPackageDir p in (pkgText <> " " <> componentText <> " " <> pkgDir) - (FileRecord f) -> T.pack $ takeFileName f - (DirRecord f _) | ipdPackageDir pkg == f -> "Files" - | otherwise -> T.pack $ last (splitDirectories f) - AddSourcesRecord -> "Source Dependencies" + (FileRecord f) -> return $ T.pack $ takeFileName f + (DirRecord f _) + | ipdPackageDir pkg == f -> return $ "Files" + | otherwise -> return $ T.pack $ last (splitDirectories f) + AddSourcesRecord -> return $ "Source Dependencies" (AddSourceRecord p) -> do let pkgText = packageIdentifierToString (ipdPackageId p) - dirText = gray (T.pack (ipdPackageDir p)) - pkgText <> " " <> dirText - ComponentsRecord -> "Components" + let dirText = gray (T.pack (ipdPackageDir p)) + return $ pkgText <> " " <> dirText + ComponentsRecord -> return $ "Components" (ComponentRecord comp) -> do let active = Just pkg == mbActivePackage && (mbActiveComponent == Nothing && comp == "library" || Just comp == mbActiveComponent) - (if active then bold else id) comp - GitRecord -> "Git" + return $ (if active then bold else id) comp GitRecord -> do - bold ("Git" ++ getBranch) + let dir = ipdPackageDir pkg + let conf = Git.makeConfig (Just dir) Nothing Nothing + liftIO $ Git.runVcs conf $ do + (branch,_) <- localBranches -- TODO What if there is no branch? + return branch where bold str = "" <> str <> "" italic str = "" <> str <> "" @@ -210,6 +215,7 @@ toIcon record = case record of ComponentsRecord -> "ide_component" AddSourcesRecord -> "ide_source_dependency" AddSourceRecord _ -> "ide_package" + GitRecord -> "ide_git" _ -> ""