From: 宋文武 <iyzsong@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] profiles: Add 'hicolor' and 'HighContrast' icon theme hooks.
Date: Mon, 11 May 2015 15:55:57 +0800 [thread overview]
Message-ID: <87oalr5z02.fsf@gmail.com> (raw)
In-Reply-To: <87lhgwcijv.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 359 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
[...]
> That makes sense. I guess we’re in trouble if there are both GTK+2 and
> GTK+3 packages in use, no?
Well, the 'icon-theme.cache' file compitable.
AFAIK, the code for `gtk-update-icon-cache' is same between GTK+2 and
GTK+3, and it only depends on glib and gdk-pixbuf.
And, here the new patch:
[-- Attachment #2: 0001-profiles-Add-hicolor-and-HighContrast-icon-theme-hoo.patch --]
[-- Type: text/x-patch, Size: 4297 bytes --]
From 94065c2b415b0b52a5617d381e1b7fac19ee9f45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Sat, 9 May 2015 12:45:39 +0800
Subject: [PATCH] profiles: Add 'hicolor' and 'HighContrast' icon theme hooks.
* 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 | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 68 insertions(+), 1 deletion(-)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 11d9bf0..08f05a6 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -573,12 +574,78 @@ 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 (entry-lookup-gtk+ store entry)
+ "Return the GTK+ package or store path referenced by the manifest ENTRY, or
+#f if not referenced."
+ ;; Find GTK+ in a list of packages.
+ (define (by-packages packages)
+ (find (lambda (package)
+ (equal? "gtk+" (package-name package)))
+ packages))
+
+ ;; Find GTK+ in a list of store paths.
+ (define (by-paths paths)
+ (find (lambda (path)
+ (equal? "gtk+"
+ (package-name->name+version
+ (store-path-package-name path))))
+ paths))
+
+ (match (manifest-entry-item entry)
+ ((? package? package)
+ (by-packages (delete-duplicates
+ (map cadr (package-transitive-inputs package)))))
+ ((? string? path)
+ (by-paths (references store path)))))
+
+ (define (manifest-lookup-gtk+ store manifest)
+ "Return the first GTK+ package or store path referenced by MANIFEST entries,
+or #f if not referenced by any entry."
+ (any (cut entry-lookup-gtk+ store <>) (manifest-entries manifest)))
+
+ (lambda (manifest)
+ (define gtk+
+ (with-store store
+ (manifest-lookup-gtk+ store 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 (string-append #$output "/share/icons"))
+ ;; Unions all the icons and update the 'icon-theme.cache'.
+ (union-build destdir icons)
+ (system* update-icon-cache "-t" destdir))))
+
+ ;; Don't run the hook when there's nothing to do.
+ (if gtk+
+ (gexp->derivation (string-append (string-downcase name) "-icon-theme")
+ build
+ #:modules '((guix build utils)
+ (guix build union))
+ #:local-build? #t)
+ #f)))
+
(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
[-- Attachment #3: Type: text/plain, Size: 41 bytes --]
Please give comments and feedback, TIA!
prev parent reply other threads:[~2015-05-11 7:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` 宋文武 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oalr5z02.fsf@gmail.com \
--to=iyzsong@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.