summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/Install/AutoStart.hs1
-rw-r--r--Assistant/Install/Menu.hs1
-rw-r--r--Build/DesktopFile.hs21
-rw-r--r--Build/InstallDesktopFile.hs2
-rw-r--r--Utility/FreeDesktop.hs21
-rw-r--r--debian/changelog6
-rw-r--r--doc/favicon.pngbin0 -> 714 bytes
7 files changed, 45 insertions, 7 deletions
diff --git a/Assistant/Install/AutoStart.hs b/Assistant/Install/AutoStart.hs
index 13b4bc7ab..b03d20224 100644
--- a/Assistant/Install/AutoStart.hs
+++ b/Assistant/Install/AutoStart.hs
@@ -35,4 +35,5 @@ fdoAutostart command = genDesktopEntry
"Autostart"
False
(command ++ " assistant --autostart")
+ Nothing
[]
diff --git a/Assistant/Install/Menu.hs b/Assistant/Install/Menu.hs
index cb9b76ba6..940a2b32c 100644
--- a/Assistant/Install/Menu.hs
+++ b/Assistant/Install/Menu.hs
@@ -27,4 +27,5 @@ fdoDesktopMenu command = genDesktopEntry
"Track and sync the files in your Git Annex"
False
(command ++ " webapp")
+ (Just "git-annex") -- icon base name
["Network", "FileTransfer"]
diff --git a/Build/DesktopFile.hs b/Build/DesktopFile.hs
index 3c6816e60..55a22352a 100644
--- a/Build/DesktopFile.hs
+++ b/Build/DesktopFile.hs
@@ -1,4 +1,4 @@
-{- Generating and installing a desktop menu entry file
+{- Generating and installing a desktop menu entry file and icon,
- and a desktop autostart file. (And OSX equivilants.)
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
@@ -28,6 +28,7 @@ import System.Posix.Files
#endif
import System.FilePath
import Data.Maybe
+import System.IO
systemwideInstall :: IO Bool
#ifndef mingw32_HOST_OS
@@ -48,14 +49,28 @@ inDestDir f = do
writeFDODesktop :: FilePath -> IO ()
writeFDODesktop command = do
- datadir <- ifM systemwideInstall ( return systemDataDir, userDataDir )
+ systemwide <- systemwideInstall
+
+ datadir <- if systemwide then return systemDataDir else userDataDir
installMenu command
=<< inDestDir (desktopMenuFilePath "git-annex" datadir)
- configdir <- ifM systemwideInstall ( return systemConfigDir, userConfigDir )
+ installIcon "doc/logo.svg" =<< inDestDir
+ =<< iconFilePath "git-annex.svg" "scalable" systemwide
+ installIcon "doc/favicon.png" =<< inDestDir
+ =<< iconFilePath "git-annex.png" "16x16" systemwide
+
+ configdir <- if systemwide then return systemConfigDir else userConfigDir
installAutoStart command
=<< inDestDir (autoStartPath "git-annex" configdir)
+installIcon :: FilePath -> FilePath -> IO ()
+installIcon src dest = do
+ createDirectoryIfMissing True (parentDir dest)
+ withBinaryFile src ReadMode $ \hin ->
+ withBinaryFile dest WriteMode $ \hout ->
+ hGetContents hin >>= hPutStr hout
+
writeOSXDesktop :: FilePath -> IO ()
writeOSXDesktop command = do
installAutoStart command =<< inDestDir =<< ifM systemwideInstall
diff --git a/Build/InstallDesktopFile.hs b/Build/InstallDesktopFile.hs
index f168f1b9b..c8a3f07f5 100644
--- a/Build/InstallDesktopFile.hs
+++ b/Build/InstallDesktopFile.hs
@@ -1,4 +1,4 @@
-{- Generating and installing a desktop menu entry file
+{- Generating and installing a desktop menu entry file and icon,
- and a desktop autostart file. (And OSX equivilants.)
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
diff --git a/Utility/FreeDesktop.hs b/Utility/FreeDesktop.hs
index e3ced6d74..6338948d2 100644
--- a/Utility/FreeDesktop.hs
+++ b/Utility/FreeDesktop.hs
@@ -3,6 +3,7 @@
- http://standards.freedesktop.org/basedir-spec/latest/
- http://standards.freedesktop.org/desktop-entry-spec/latest/
- http://standards.freedesktop.org/menu-spec/latest/
+ - http://standards.freedesktop.org/icon-theme-spec/latest/
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
@@ -16,6 +17,7 @@ module Utility.FreeDesktop (
writeDesktopMenuFile,
desktopMenuFilePath,
autoStartPath,
+ iconFilePath,
systemDataDir,
systemConfigDir,
userDataDir,
@@ -34,6 +36,7 @@ import System.Directory
import System.FilePath
import Data.List
import Data.String.Utils
+import Data.Maybe
import Control.Applicative
type DesktopEntry = [(Key, Value)]
@@ -54,18 +57,19 @@ toString (ListV l)
where
escapesemi = join "\\;" . split ";"
-genDesktopEntry :: String -> String -> Bool -> FilePath -> [String] -> DesktopEntry
-genDesktopEntry name comment terminal program categories =
+genDesktopEntry :: String -> String -> Bool -> FilePath -> Maybe String -> [String] -> DesktopEntry
+genDesktopEntry name comment terminal program icon categories = catMaybes
[ item "Type" StringV "Application"
, item "Version" NumericV 1.0
, item "Name" StringV name
, item "Comment" StringV comment
, item "Terminal" BoolV terminal
, item "Exec" StringV program
+ , maybe Nothing (item "Icon" StringV) icon
, item "Categories" ListV (map StringV categories)
]
where
- item x c y = (x, c y)
+ item x c y = Just (x, c y)
buildDesktopMenuFile :: DesktopEntry -> String
buildDesktopMenuFile d = unlines ("[Desktop Entry]" : map keyvalue d) ++ "\n"
@@ -89,6 +93,17 @@ autoStartPath :: String -> FilePath -> FilePath
autoStartPath basename configdir =
configdir </> "autostart" </> desktopfile basename
+{- Path to use for an icon file.
+ - The resolution is something like "48x48" or "scalable". -}
+iconFilePath :: FilePath -> String -> Bool -> IO FilePath
+iconFilePath file resolution systemwide
+ | systemwide = return $ systemDataDir </> "icons" </> subpath
+ | otherwise = do
+ home <- myHomeDir
+ return $ home </> ".icons" </> subpath
+ where
+ subpath = "hicolor" </> resolution </> "apps" </> file
+
desktopfile :: FilePath -> FilePath
desktopfile f = f ++ ".desktop"
diff --git a/debian/changelog b/debian/changelog
index ad7a5976e..6a5d2af55 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+git-annex (4.20130710) UNRELEASED; urgency=low
+
+ * Install XDG desktop icon files.
+
+ -- Joey Hess <joeyh@debian.org> Tue, 09 Jul 2013 19:17:13 -0400
+
git-annex (4.20130709) unstable; urgency=low
* --all: New switch that makes git-annex operate on all data stored
diff --git a/doc/favicon.png b/doc/favicon.png
new file mode 100644
index 000000000..1efbebdd7
--- /dev/null
+++ b/doc/favicon.png
Binary files differ