From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SWFXL-0000QZ-5N for garchives@archives.gentoo.org; Sun, 20 May 2012 23:27:43 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A8D4AE0991; Sun, 20 May 2012 23:27:21 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 24653E078D for ; Sun, 20 May 2012 23:26:39 +0000 (UTC) Received: from [192.168.4.5] (blfd-4d083bea.pool.mediaWays.net [77.8.59.234]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: hasufell) by smtp.gentoo.org (Postfix) with ESMTPSA id 30C8F1B4006 for ; Sun, 20 May 2012 23:26:37 +0000 (UTC) Message-ID: <4FB97D1D.9070004@gentoo.org> Date: Mon, 21 May 2012 01:24:13 +0200 From: hasufell User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120502 Thunderbird/10.0.4 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] enhancement for doicon/newicon in eutils.eclass X-Enigmail-Version: 1.3.5 Content-Type: multipart/mixed; boundary="------------080602080702030903050501" X-Archives-Salt: bf11c02e-947e-404c-8949-c8e5e47fd516 X-Archives-Hash: 7e23a113d5d9db563f3f56f19a8dd8ba This is a multi-part message in MIME format. --------------080602080702030903050501 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I want support for installing icons into the appropriate directories which are under /usr/share/icons/... and not just pixmaps. proposal attached + diff This should not break existing ebuilds. Tested a bit and open for review now. --------------080602080702030903050501 Content-Type: text/plain; name="eutils-doicon-newicon.eclass" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="eutils-doicon-newicon.eclass" # @FUNCTION: doicon # @USAGE: doicon [options] # @DESCRIPTION: # Install icon into the icon directory /usr/share/icons or into # /usr/share/pixmaps if "--size" is not set. # This is useful in conjunction with creating desktop/menu files. # # @CODE # options: # -s, --size # !!! must specify to install into /usr/share/icons/... !!! # size of the icon, like 48 or 48x48 # supported icon sizes are: # 16 22 24 32 36 48 64 72 96 128 192 256 scalable # -c, --context # defaults to "apps" # -t, --theme # defaults to "hicolor" # # icons: list of icons # @CODE # # example 1: # doicon foobar.png fuqbar.svg # results in: insinto /usr/share/pixmaps ; doins foobar.png fuqbar.svg # # example 2: # doicon -s 48 foobar.png fuqbar.svg # results in: insinto /usr/share/icons/hicolor/48x48/apps ; doins foobar.png fuqbar.svg # doicon() { ( # wrap the env here so that the 'insinto' call # doesn't corrupt the env of the caller local size dir i ret local context=apps local theme=hicolor while [[ $# -gt 0 ]] ; do case ${1} in -s|--size) case ${2} in 16|22|24|32|36|48|64|72|96|128|192|256) size=${2}x${2};; 16x16|22x22|24x24|32x32|36x36|48x48|64x64|72x72|96x96|128x128|192x192|256x256) size=${2};; scalable) size=scalable;; *) eqawarn "${2} is an unsupported icon size!" ((++ret));; esac shift 2;; -t|--theme) theme=${2} shift 2;; -c|--context) context=${2} shift 2;; *) if [[ -z ${size} ]] ; then dir=/usr/share/pixmaps else dir=/usr/share/icons/${theme}/${size}/${context} fi insinto "${dir}" if [[ -f ${1} ]] ; then doins "${1}" ((ret+=$?)) elif [[ -d ${1} ]] ; then for i in "${1}"/*.{png,svg} ; do doins "${i}" ((ret+=$?)) done else eqawarn "${1} is not a valid file/directory!" ((++ret)) fi shift 1 ;; esac done exit ${ret} ) } # @FUNCTION: newicon # @USAGE: newicon [options] # @DESCRIPTION: # Like doicon, install the specified icon as newname. # # example 1: # newicon foobar.png NEWNAME.png # results in: insinto /usr/share/pixmaps ; newins foobar.png NEWNAME.png # # example 2: # newicon -s 48 foobar.png NEWNAME.png # results in: insinto /usr/share/icons/hicolor/48x48/apps ; newins foobar.png NEWNAME.png # newicon() { ( # wrap the env here so that the 'insinto' call # doesn't corrupt the env of the caller local size dir ret local context=apps local theme=hicolor while [[ $# -gt 0 ]] ; do case ${1} in -s|--size) case ${2} in 16|22|24|32|36|48|64|72|96|128|192|256) size=${2}x${2};; 16x16|22x22|24x24|32x32|36x36|48x48|64x64|72x72|96x96|128x128|192x192|256x256) size=${2};; scalable) size=scalable;; *) eqawarn "${2} is an unsupported icon size!" ((++ret));; esac shift 2;; -t|--theme) theme=${2} shift 2;; -c|--context) context=${2} shift 2;; *) break ;; esac done if [[ -z ${size} ]] ; then dir=/usr/share/pixmaps else dir=/usr/share/icons/${theme}/${size}/${context} fi insinto "${dir}" newins "$@" ((ret+=$?)) exit ${ret} ) } --------------080602080702030903050501 Content-Type: text/x-patch; name="eutils.eclass.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="eutils.eclass.diff" --- eclass/eutils.eclass +++ eclass/eutils.eclass @@ -945,43 +945,150 @@ } # @FUNCTION: doicon -# @USAGE: +# @USAGE: doicon [options] # @DESCRIPTION: -# Install the list of icons into the icon directory (/usr/share/pixmaps). +# Install icon into the icon directory /usr/share/icons or into +# /usr/share/pixmaps if "--size" is not set. # This is useful in conjunction with creating desktop/menu files. +# +# @CODE +# options: +# -s, --size +# !!! must specify to install into /usr/share/icons/... !!! +# size of the icon, like 48 or 48x48 +# supported icon sizes are: +# 16 22 24 32 36 48 64 72 96 128 192 256 scalable +# -c, --context +# defaults to "apps" +# -t, --theme +# defaults to "hicolor" +# +# icons: list of icons +# @CODE +# +# example 1: +# doicon foobar.png fuqbar.svg +# results in: insinto /usr/share/pixmaps ; doins foobar.png fuqbar.svg +# +# example 2: +# doicon -s 48 foobar.png fuqbar.svg +# results in: insinto /usr/share/icons/hicolor/48x48/apps ; doins foobar.png fuqbar.svg +# doicon() { ( # wrap the env here so that the 'insinto' call # doesn't corrupt the env of the caller - local i j ret - insinto /usr/share/pixmaps - for i in "$@" ; do - if [[ -f ${i} ]] ; then - doins "${i}" - ((ret+=$?)) - elif [[ -d ${i} ]] ; then - for j in "${i}"/*.png ; do - doins "${j}" + local size dir i ret + local context=apps + local theme=hicolor + + while [[ $# -gt 0 ]] ; do + case ${1} in + -s|--size) + case ${2} in + 16|22|24|32|36|48|64|72|96|128|192|256) + size=${2}x${2};; + 16x16|22x22|24x24|32x32|36x36|48x48|64x64|72x72|96x96|128x128|192x192|256x256) + size=${2};; + scalable) + size=scalable;; + *) + eqawarn "${2} is an unsupported icon size!" + ((++ret));; + esac + shift 2;; + -t|--theme) + theme=${2} + shift 2;; + -c|--context) + context=${2} + shift 2;; + *) + if [[ -z ${size} ]] ; then + dir=/usr/share/pixmaps + else + dir=/usr/share/icons/${theme}/${size}/${context} + fi + + insinto "${dir}" + + if [[ -f ${1} ]] ; then + doins "${1}" ((ret+=$?)) - done - else - ((++ret)) - fi + elif [[ -d ${1} ]] ; then + for i in "${1}"/*.{png,svg} ; do + doins "${i}" + ((ret+=$?)) + done + else + eqawarn "${1} is not a valid file/directory!" + ((++ret)) + fi + shift 1 ;; + esac done exit ${ret} ) } # @FUNCTION: newicon -# @USAGE: +# @USAGE: newicon [options] # @DESCRIPTION: -# Like all other new* functions, install the specified icon as newname. +# Like doicon, install the specified icon as newname. +# +# example 1: +# newicon foobar.png NEWNAME.png +# results in: insinto /usr/share/pixmaps ; newins foobar.png NEWNAME.png +# +# example 2: +# newicon -s 48 foobar.png NEWNAME.png +# results in: insinto /usr/share/icons/hicolor/48x48/apps ; newins foobar.png NEWNAME.png +# newicon() { ( # wrap the env here so that the 'insinto' call # doesn't corrupt the env of the caller - insinto /usr/share/pixmaps + local size dir ret + local context=apps + local theme=hicolor + + while [[ $# -gt 0 ]] ; do + case ${1} in + -s|--size) + case ${2} in + 16|22|24|32|36|48|64|72|96|128|192|256) + size=${2}x${2};; + 16x16|22x22|24x24|32x32|36x36|48x48|64x64|72x72|96x96|128x128|192x192|256x256) + size=${2};; + scalable) + size=scalable;; + *) + eqawarn "${2} is an unsupported icon size!" + ((++ret));; + esac + shift 2;; + -t|--theme) + theme=${2} + shift 2;; + -c|--context) + context=${2} + shift 2;; + *) + break ;; + esac + done + + if [[ -z ${size} ]] ; then + dir=/usr/share/pixmaps + else + dir=/usr/share/icons/${theme}/${size}/${context} + fi + + insinto "${dir}" newins "$@" + ((ret+=$?)) + + exit ${ret} ) } --------------080602080702030903050501--