FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 05-24-2012, 12:43 AM
hasufell
 
Default enhancement for doicon/newicon in eutils.eclass

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/24/2012 02:30 AM, Mike Frysinger wrote:
> On Wednesday 23 May 2012 20:16:12 hasufell wrote:
>> Thanks, I'v implemented most of that, but your proposal about
>> non-duplicated list in case) has multiple problems. The only
>> cases that actually work with that snippet are:
>> 16x16|22x22|24x24|32x32|36x36|48x48|64x64|72x72|96 x96|scalable.
>> All others will fail (like 128x128 or just 48).
>
> so do: size= if [[ $2 == "scalable" ]] ; then size=$2 elif [[
> ${2%%x*}x${2%%x*} == "$2" ]] ; then size=${2%%x*} case ${size} in
> 16|22|24|32|36|48|64|72|96|128|192|256) ;; *) size= ;; esac fi
> -mike

alright

this would work


-s|--size)
if [[ ${2%%x*}x${2%%x*} == "$2" ]] ; then
size=${2%%x*}
else
size=${2}
fi
case ${size} in
16|22|24|32|36|48|64|72|96|128|192|256)
size=${size}x${size};;
scalable)
;;
*)
eerror "${size} is an unsupported icon size!"
exit 1;;
esac
shift 2;;

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPvYRDAAoJEFpvPKfnPDWz8DgIAIA3T7GLWe N1m+8vfyeaVMXj
7UWyBXEcCU5geYqi5KsuY8/0Mq0e47ER+EH3VU+CrbV+UlDxxbyzsF4cqMRq/Oe+
Zz5CmSv4vjAfOyVe9psChue9PnKQwe/w6sS+L9zBftIzCb8G48Eefiir7lp9p7HO
9M5KkLeJwThDkUfhNUKtbNdIf1clnT1GVNrvcPuuasARN/of4ClQVVRISXKKHZen
9yA4D876CxtyN0jBHn78pRg0kZwSPL3PqucIQjli+usvGONX+L Wuc7uWFJk8hnHI
E9cJrbUvkSJZx07ajEK1maohJBkfZdVWWxCGtZk0T00Kd2Nyy7 o9SFX1hXX3F4I=
=/kaW
-----END PGP SIGNATURE-----
 
Old 05-24-2012, 01:04 AM
hasufell
 
Default enhancement for doicon/newicon in eutils.eclass

On 05/21/2012 01:24 AM, hasufell wrote:
> 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.

next version
# @FUNCTION: _iconins
# @DESCRIPTION:
# function for use in doicon and newicon
_iconins() {
(
# wrap the env here so that the 'insinto' call
# doesn't corrupt the env of the caller
local size dir
local context=apps
local theme=hicolor

while [[ $# -gt 0 ]] ; do
case $1 in
-s|--size)
if [[ ${2%%x*}x${2%%x*} == "$2" ]] ; then
size=${2%%x*}
else
size=${2}
fi
case ${size} in
16|22|24|32|36|48|64|72|96|128|192|256)
size=${size}x${size};;
scalable)
;;
*)
eerror "${size} is an unsupported icon size!"
exit 1;;
esac
shift 2;;
-t|--theme)
theme=${2}
shift 2;;
-c|--context)
context=${2}
shift 2;;
*)
if [[ -z $size ]] ; then
insinto /usr/share/pixmaps
else
insinto /usr/share/icons/${theme}/${size}/${context}
fi

if [[ $function == doicon ]] ; then
if [[ -f $1 ]] ; then
doins "${1}"
elif [[ -d $1 ]] ; then
shopt -s nullglob
doins "${1}"/*.{png,svg}
shopt -u nullglob
else
eerror "${1} is not a valid file/directory!"
exit 1
fi
else
break
fi
shift 1;;
esac
done
if [[ $function == newicon ]] ; then
newins "$@"
fi
) || die
}

# @FUNCTION: doicon
# @USAGE: doicon [options] <icons>
# @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.png
# results in: insinto /usr/share/icons/hicolor/48x48/apps ; doins foobar.png fuqbar.svg
#
doicon() {
local function=$FUNCNAME
_iconins "$@"
}

# @FUNCTION: newicon
# @USAGE: newicon [options] <icon> <newname>
# @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() {
local function=$FUNCNAME
_iconins "$@"
}
 
Old 05-24-2012, 05:53 AM
Michał Górny
 
Default enhancement for doicon/newicon in eutils.eclass

On Thu, 24 May 2012 02:43:47 +0200
hasufell <hasufell@gentoo.org> wrote:

> -s|--size)
> if [[ ${2%%x*}x${2%%x*} == "$2" ]] ; then
> size=${2%%x*}
> else
> size=${2}
> fi
> case ${size} in
> 16|22|24|32|36|48|64|72|96|128|192|256)
> size=${size}x${size};;
> scalable)
> ;;

Not that anyone would care enough to try to understand what magic is
happening there... Please reimplement in Perl.

--
Best regards,
Michał Górny
 

Thread Tools




All times are GMT. The time now is 12:47 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org