unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] profiles: Add 'hicolor' and 'HighContrast' icon theme hooks.
@ 2015-05-09  4:55 宋文武
  2015-05-09  5:11 ` 宋文武
  0 siblings, 1 reply; 6+ messages in thread
From: 宋文武 @ 2015-05-09  4:55 UTC (permalink / raw)
  To: guix-devel

* guix/profiles.scm (gtk-icon-theme-hook): New function.
  (%default-profile-hooks): Add `(gtk-icon-theme-hook "hicolor")' and
  `(gtk-icon-theme-hook "HighContrast")'.
---
 guix/profiles.scm | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/guix/profiles.scm b/guix/profiles.scm
index 11d9bf0..9756685 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -573,12 +573,46 @@ MANIFEST.  Single-file bundles are required by programs such as Git and Lynx."
                     #:modules '((guix build utils))
                     #:local-build? #t))
 
+(define (gtk-icon-theme-hook name)
+  "Return a profile hook that unions all NAME icons from manifest entries and
+rebuilds the 'icon-theme.cache' file for the NAME icon theme."
+  (define gtk+
+    (module-ref (resolve-interface '(gnu packages gtk)) 'gtk+))
+
+  (lambda (manifest)
+    (define build
+      #~(begin
+          (use-modules (guix build utils)
+                       (guix build union))
+          (let* ((icon-dir (lambda (base)
+                             (string-append base "/share/icons/" #$name)))
+                 (destdir  (icon-dir #$output))
+                 (icons    (filter
+                            file-exists?
+                            (map icon-dir '#$(manifest-inputs manifest))))
+                 (update-icon-cache (string-append
+                                     #+gtk+ "/bin/gtk-update-icon-cache")))
+            ;; mkdir -p $out/share/icons
+            (mkdir-p destdir)
+            (rmdir destdir)
+            ;; Unions all the icons and update the 'icon-theme.cache'.
+            (union-build destdir icons)
+            (system* update-icon-cache "-t" destdir))))
+
+    (gexp->derivation (string-append (string-downcase name) "-icon-theme")
+                      build
+                      #:modules '((guix build utils)
+                                  (guix build union))
+                      #:local-build? #t)))
+
 (define %default-profile-hooks
   ;; This is the list of derivation-returning procedures that are called by
   ;; default when making a non-empty profile.
   (list info-dir-file
         ghc-package-cache-file
-        ca-certificate-bundle))
+        ca-certificate-bundle
+        (gtk-icon-theme-hook "hicolor")
+        (gtk-icon-theme-hook "HighContrast")))
 
 (define* (profile-derivation manifest
                              #:key
-- 
2.2.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-11  7:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-09  4:55 [PATCH] profiles: Add 'hicolor' and 'HighContrast' icon theme hooks 宋文武
2015-05-09  5:11 ` 宋文武
2015-05-09 14:10   ` Ludovic Courtès
2015-05-10  4:55     ` 宋文武
2015-05-10 19:57       ` Ludovic Courtès
2015-05-11  7:55         ` 宋文武

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).