From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?B?5a6L5paH5q2m?= Subject: Re: [PATCH] profiles: Add 'hicolor' and 'HighContrast' icon theme hooks. Date: Mon, 11 May 2015 15:55:57 +0800 Message-ID: <87oalr5z02.fsf@gmail.com> References: <1431147336-4274-1-git-send-email-iyzsong@gmail.com> <877fsixrmg.fsf@gmail.com> <87wq0hg7td.fsf@gnu.org> <87twvlghfk.fsf@gmail.com> <87lhgwcijv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YriYi-0004sP-HJ for guix-devel@gnu.org; Mon, 11 May 2015 03:55:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YriYg-0005aL-TQ for guix-devel@gnu.org; Mon, 11 May 2015 03:55:28 -0400 In-Reply-To: <87lhgwcijv.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: [...] > That makes sense. I guess we=E2=80=99re 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: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-profiles-Add-hicolor-and-HighContrast-icon-theme-hoo.patch Content-Transfer-Encoding: quoted-printable >From 94065c2b415b0b52a5617d381e1b7fac19ee9f45 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?=3DE5=3DAE=3D8B=3DE6=3D96=3D87=3DE6=3DAD=3DA6?=3D Date: Sat, 9 May 2015 12:45:39 +0800 Subject: [PATCH] profiles: Add 'hicolor' and 'HighContrast' icon theme hook= s. * 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 =C2=A9 2013 Nikita Karetnikov ;;; Copyright =C2=A9 2014 Alex Kost ;;; Copyright =C2=A9 2015 Mark H Weaver +;;; Copyright =C2=A9 2015 Sou Bunnbu ;;; ;;; This file is part of GNU Guix. ;;; @@ -573,12 +574,78 @@ MANIFEST. Single-file bundles are required by progra= ms such as Git and Lynx." #:modules '((guix build utils)) #:local-build? #t)) =20 +(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 ENTR= Y, 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 en= tries, +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-the= me") + 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"))) =20 (define* (profile-derivation manifest #:key --=20 2.2.1 --=-=-= Content-Type: text/plain Please give comments and feedback, TIA! --=-=-=--