cinnamon-menus-2.8.0/ 0000775 0001750 0001750 00000000000 12610172545 013173 5 ustar maxy maxy cinnamon-menus-2.8.0/config.sub.cdbs-orig 0000775 0001750 0001750 00000105354 12610172545 017036 0 ustar maxy maxy #! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2013-08-10'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support. The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.
# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
$0 [OPTION] ALIAS
Canonicalize a configuration name.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.sub ($timestamp)
Copyright 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help"
exit 1 ;;
*local*)
# First pass through any local machine types.
echo $1
exit ;;
* )
break ;;
esac
done
case $# in
0) echo "$me: missing argument$help" >&2
exit 1;;
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
android-linux)
os=-linux-android
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
then os=`echo $1 | sed 's/.*-/-/'`
else os=; fi
;;
esac
### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work. We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray | -microblaze*)
os=
basic_machine=$1
;;
-bluegene*)
os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
;;
-scout)
;;
-wrs)
os=-vxworks
basic_machine=$1
;;
-chorusos*)
os=-chorusos
basic_machine=$1
;;
-chorusrdb)
os=-chorusrdb
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco6)
os=-sco5v6
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5v6*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*178)
os=-lynxos178
;;
-lynx*5)
os=-lynxos5
;;
-lynx*)
os=-lynxos
;;
-ptx*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
;;
-windowsnt*)
os=`echo $os | sed -e 's/windowsnt/winnt/'`
;;
-psos*)
os=-psos
;;
-mint | -mint[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| aarch64 | aarch64_be \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
| bfin \
| c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64octeon | mips64octeonel \
| mips64orion | mips64orionel \
| mips64r5900 | mips64r5900el \
| mips64vr | mips64vrel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 \
| or1k | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
| rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu \
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| we32k \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
c54x)
basic_machine=tic54x-unknown
;;
c55x)
basic_machine=tic55x-unknown
;;
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
ms1)
basic_machine=mt-unknown
;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
xgate)
basic_machine=$basic_machine-unknown
os=-none
;;
xscaleeb)
basic_machine=armeb-unknown
;;
xscaleel)
basic_machine=armel-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64octeon-* | mips64octeonel-* \
| mips64orion-* | mips64orionel-* \
| mips64r5900-* | mips64r5900el-* \
| mips64vr-* | mips64vrel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
| rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile*-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-* | z80-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=$basic_machine-unknown
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
basic_machine=i386-unknown
os=-bsd
;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
a29khif)
basic_machine=a29k-amd
os=-udi
;;
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
altos | altos3068)
basic_machine=m68k-altos
;;
am29k)
basic_machine=a29k-none
os=-bsd
;;
amd64)
basic_machine=x86_64-pc
;;
amd64-*)
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-unknown
;;
amigaos | amigados)
basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
os=-bsd
;;
aros)
basic_machine=i386-pc
os=-aros
;;
aux)
basic_machine=m68k-apple
os=-aux
;;
balance)
basic_machine=ns32k-sequent
os=-dynix
;;
blackfin)
basic_machine=bfin-unknown
os=-linux
;;
blackfin-*)
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
bluegene*)
basic_machine=powerpc-ibm
os=-cnk
;;
c54x-*)
basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c55x-*)
basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c6x-*)
basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
;;
convex-c2)
basic_machine=c2-convex
os=-bsd
;;
convex-c32)
basic_machine=c32-convex
os=-bsd
;;
convex-c34)
basic_machine=c34-convex
os=-bsd
;;
convex-c38)
basic_machine=c38-convex
os=-bsd
;;
cray | j90)
basic_machine=j90-cray
os=-unicos
;;
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16 | cr16-*)
basic_machine=cr16-unknown
os=-elf
;;
crds | unos)
basic_machine=m68k-crds
;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
crx)
basic_machine=crx-unknown
os=-elf
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
;;
delta88)
basic_machine=m88k-motorola
os=-sysv3
;;
dicos)
basic_machine=i686-pc
os=-dicos
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
;;
dpx2* | dpx2*-bull)
basic_machine=m68k-bull
os=-sysv3
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
;;
elxsi)
basic_machine=elxsi-elxsi
os=-bsd
;;
encore | umax | mmax)
basic_machine=ns32k-encore
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
os=-ose
;;
fx2800)
basic_machine=i860-alliant
;;
genix)
basic_machine=ns32k-ns
;;
gmicro)
basic_machine=tron-gmicro
os=-sysv
;;
go32)
basic_machine=i386-pc
os=-go32
;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
h8300hms)
basic_machine=h8300-hitachi
os=-hms
;;
h8300xray)
basic_machine=h8300-hitachi
os=-xray
;;
h8500hms)
basic_machine=h8500-hitachi
os=-hms
;;
harris)
basic_machine=m88k-harris
os=-sysv3
;;
hp300-*)
basic_machine=m68k-hp
;;
hp300bsd)
basic_machine=m68k-hp
os=-bsd
;;
hp300hpux)
basic_machine=m68k-hp
os=-hpux
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
hp9k6[0-9][0-9] | hp6[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
basic_machine=hppa1.1-hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hppa-next)
os=-nextstep3
;;
hppaosf)
basic_machine=hppa1.1-hp
os=-osf
;;
hppro)
basic_machine=hppa1.1-hp
os=-proelf
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
i386mach)
basic_machine=i386-mach
os=-mach
;;
i386-vsta | vsta)
basic_machine=i386-unknown
os=-vsta
;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
-irix*)
;;
*)
os=-irix4
;;
esac
;;
isi68 | isi)
basic_machine=m68k-isi
os=-sysv
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
m88k-omron*)
basic_machine=m88k-omron
;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
;;
merlin)
basic_machine=ns32k-utek
os=-sysv
;;
microblaze*)
basic_machine=microblaze-xilinx
;;
mingw64)
basic_machine=x86_64-pc
os=-mingw64
;;
mingw32)
basic_machine=i686-pc
os=-mingw32
;;
mingw32ce)
basic_machine=arm-unknown
os=-mingw32ce
;;
miniframe)
basic_machine=m68000-convergent
;;
*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos)
basic_machine=i386-pc
os=-msdos
;;
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i686-pc
os=-msys
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
nacl)
basic_machine=le32-unknown
os=-nacl
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
netbsd386)
basic_machine=i386-unknown
os=-netbsd
;;
netwinder)
basic_machine=armv4l-rebel
os=-linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
;;
news1000)
basic_machine=m68030-sony
os=-newsos
;;
news-3600 | risc-news)
basic_machine=mips-sony
os=-newsos
;;
necv70)
basic_machine=v70-nec
os=-sysv
;;
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep* )
;;
-ns2*)
os=-nextstep2
;;
*)
os=-nextstep3
;;
esac
;;
nh3000)
basic_machine=m68k-harris
os=-cxux
;;
nh[45]000)
basic_machine=m88k-harris
os=-cxux
;;
nindy960)
basic_machine=i960-intel
os=-nindy
;;
mon960)
basic_machine=i960-intel
os=-mon960
;;
nonstopux)
basic_machine=mips-compaq
os=-nonstopux
;;
np1)
basic_machine=np1-gould
;;
neo-tandem)
basic_machine=neo-tandem
;;
nse-tandem)
basic_machine=nse-tandem
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
openrisc | openrisc-*)
basic_machine=or32-unknown
;;
os400)
basic_machine=powerpc-ibm
os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
;;
os68k)
basic_machine=m68k-none
os=-os68k
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
paragon)
basic_machine=i860-intel
os=-osf
;;
parisc)
basic_machine=hppa-unknown
os=-linux
;;
parisc-*)
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
pbd)
basic_machine=sparc-tti
;;
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pc98)
basic_machine=i386-pc
;;
pc98-*)
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc
;;
pentiumii | pentium2 | pentiumiii | pentium3)
basic_machine=i686-pc
;;
pentium4)
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium4-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=power-ibm
;;
ppc | ppcbe) basic_machine=powerpc-unknown
;;
ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
pw32)
basic_machine=i586-unknown
os=-pw32
;;
rdos | rdos64)
basic_machine=x86_64-pc
os=-rdos
;;
rdos32)
basic_machine=i386-pc
os=-rdos
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sde)
basic_machine=mipsisa32-sde
os=-elf
;;
sei)
basic_machine=mips-sei
os=-seiux
;;
sequent)
basic_machine=i386-sequent
;;
sh)
basic_machine=sh-hitachi
os=-hms
;;
sh5el)
basic_machine=sh5le-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
;;
spur)
basic_machine=spur-unknown
;;
st2000)
basic_machine=m68k-tandem
;;
stratus)
basic_machine=i860-stratus
os=-sysv4
;;
strongarm-* | thumb-*)
basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
sun2)
basic_machine=m68000-sun
;;
sun2os3)
basic_machine=m68000-sun
os=-sunos3
;;
sun2os4)
basic_machine=m68000-sun
os=-sunos4
;;
sun3os3)
basic_machine=m68k-sun
os=-sunos3
;;
sun3os4)
basic_machine=m68k-sun
os=-sunos4
;;
sun4os3)
basic_machine=sparc-sun
os=-sunos3
;;
sun4os4)
basic_machine=sparc-sun
os=-sunos4
;;
sun4sol2)
basic_machine=sparc-sun
os=-solaris2
;;
sun3 | sun3-*)
basic_machine=m68k-sun
;;
sun4)
basic_machine=sparc-sun
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
sv1)
basic_machine=sv1-cray
os=-unicos
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
t3e)
basic_machine=alphaev5-cray
os=-unicos
;;
t90)
basic_machine=t90-cray
os=-unicos
;;
tile*)
basic_machine=$basic_machine-unknown
os=-linux-gnu
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
tpf)
basic_machine=s390x-ibm
os=-tpf
;;
udi29k)
basic_machine=a29k-amd
os=-udi
;;
ultra3)
basic_machine=a29k-nyu
os=-sym1
;;
v810 | necv810)
basic_machine=v810-nec
os=-none
;;
vaxv)
basic_machine=vax-dec
os=-sysv
;;
vms)
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
;;
vxworks68)
basic_machine=m68k-wrs
os=-vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
os=-vxworks
;;
w65*)
basic_machine=w65-wdc
os=-none
;;
w89k-*)
basic_machine=hppa1.1-winbond
os=-proelf
;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
xscale-* | xscalee[bl]-*)
basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
;;
z80-*-coff)
basic_machine=z80-unknown
os=-sim
;;
none)
basic_machine=none-none
os=-none
;;
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
w89k)
basic_machine=hppa1.1-winbond
;;
op50n)
basic_machine=hppa1.1-oki
;;
op60c)
basic_machine=hppa1.1-oki
;;
romp)
basic_machine=romp-ibm
;;
mmix)
basic_machine=mmix-knuth
;;
rs6000)
basic_machine=rs6000-ibm
;;
vax)
basic_machine=vax-dec
;;
pdp10)
# there are many clones, so DEC is not a safe bet
basic_machine=pdp10-unknown
;;
pdp11)
basic_machine=pdp11-dec
;;
we32k)
basic_machine=we32k-att
;;
sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
basic_machine=cydra-cydrome
;;
orion)
basic_machine=orion-highlevel
;;
orion105)
basic_machine=clipper-highlevel
;;
mac | mpw | mac-mpw)
basic_machine=m68k-apple
;;
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
;;
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
;;
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
-solaris)
os=-solaris2
;;
-svr4*)
os=-sysv4
;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# First accept the basic system types.
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -bitrig* | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
x86-* | i*86-*)
;;
*)
os=-nto$os
;;
esac
;;
-nto-qnx*)
;;
-nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
;;
-os400*)
os=-os400
;;
-wince*)
os=-wince
;;
-osfrose*)
os=-osfrose
;;
-osf*)
os=-osf
;;
-utek*)
os=-bsd
;;
-dynix*)
os=-bsd
;;
-acis*)
os=-aos
;;
-atheos*)
os=-atheos
;;
-syllable*)
os=-syllable
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-nova*)
os=-rtmk-nova
;;
-ns2 )
os=-nextstep2
;;
-nsk*)
os=-nsk
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
-sinix*)
os=-sysv4
;;
-tpf*)
os=-tpf
;;
-triton*)
os=-sysv3
;;
-oss*)
os=-sysv3
;;
-svr4)
os=-sysv4
;;
-svr3)
os=-sysv3
;;
-sysvr4)
os=-sysv4
;;
# This must come after -sysvr4.
-sysv*)
;;
-ose*)
os=-ose
;;
-es1800*)
os=-ose
;;
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-aros*)
os=-aros
;;
-zvmoe)
os=-zvmoe
;;
-dicos*)
os=-dicos
;;
-nacl*)
;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
exit 1
;;
esac
else
# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.
# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
case $basic_machine in
score-*)
os=-elf
;;
spu-*)
os=-elf
;;
*-acorn)
os=-riscix1.2
;;
arm*-rebel)
os=-linux
;;
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
;;
c8051-*)
os=-elf
;;
hexagon-*)
os=-elf
;;
tic54x-*)
os=-coff
;;
tic55x-*)
os=-coff
;;
tic6x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
pdp11-*)
os=-none
;;
*-dec | vax-*)
os=-ultrix4.2
;;
m68*-apollo)
os=-domain
;;
i386-sun)
os=-sunos4.0.2
;;
m68000-sun)
os=-sunos3
;;
m68*-cisco)
os=-aout
;;
mep-*)
os=-elf
;;
mips*-cisco)
os=-elf
;;
mips*-*)
os=-elf
;;
or1k-*)
os=-elf
;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-be)
os=-beos
;;
*-haiku)
os=-haiku
;;
*-ibm)
os=-aix
;;
*-knuth)
os=-mmixware
;;
*-wec)
os=-proelf
;;
*-winbond)
os=-proelf
;;
*-oki)
os=-proelf
;;
*-hp)
os=-hpux
;;
*-hitachi)
os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=-sysv
;;
*-cbm)
os=-amigaos
;;
*-dg)
os=-dgux
;;
*-dolphin)
os=-sysv3
;;
m68k-ccur)
os=-rtu
;;
m88k-omron*)
os=-luna
;;
*-next )
os=-nextstep
;;
*-sequent)
os=-ptx
;;
*-crds)
os=-unos
;;
*-ns)
os=-genix
;;
i370-*)
os=-mvs
;;
*-next)
os=-nextstep3
;;
*-gould)
os=-sysv
;;
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
os=-irix
;;
*-siemens)
os=-sysv4
;;
*-masscomp)
os=-rtu
;;
f30[01]-fujitsu | f700-fujitsu)
os=-uxpv
;;
*-rom68k)
os=-coff
;;
*-*bug)
os=-coff
;;
*-apple)
os=-macos
;;
*-atari*)
os=-mint
;;
*)
os=-none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
vendor=unknown
case $basic_machine in
*-unknown)
case $os in
-riscix*)
vendor=acorn
;;
-sunos*)
vendor=sun
;;
-cnk*|-aix*)
vendor=ibm
;;
-beos*)
vendor=be
;;
-hpux*)
vendor=hp
;;
-mpeix*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
-unos*)
vendor=crds
;;
-dgux*)
vendor=dg
;;
-luna*)
vendor=omron
;;
-genix*)
vendor=ns
;;
-mvs* | -opened*)
vendor=ibm
;;
-os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-tpf*)
vendor=ibm
;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
vendor=apple
;;
-hms*)
vendor=hitachi
;;
-mpw* | -macos*)
vendor=apple
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
-vos*)
vendor=stratus
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
cinnamon-menus-2.8.0/AUTHORS 0000664 0001750 0001750 00000000141 12610172545 014237 0 ustar maxy maxy Mark McLoughlin
Havoc Pennington
Vincent Untz
cinnamon-menus-2.8.0/libmenu/ 0000775 0001750 0001750 00000000000 12610172545 014626 5 ustar maxy maxy cinnamon-menus-2.8.0/libmenu/menu-util.c 0000664 0001750 0001750 00000030054 12610172545 016713 0 ustar maxy maxy /* Random utility functions for menu code */
/*
* Copyright (C) 2003 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include
#include "menu-util.h"
#include
#include
#ifdef G_ENABLE_DEBUG
static gboolean verbose = FALSE;
static gboolean initted = FALSE;
static inline gboolean
menu_verbose_enabled (void)
{
if (!initted)
{
verbose = g_getenv ("MENU_VERBOSE") != NULL;
initted = TRUE;
}
return verbose;
}
static int
utf8_fputs (const char *str,
FILE *f)
{
char *l;
int ret;
l = g_locale_from_utf8 (str, -1, NULL, NULL, NULL);
if (l == NULL)
ret = fputs (str, f); /* just print it anyway, better than nothing */
else
ret = fputs (l, f);
g_free (l);
return ret;
}
void
menu_verbose (const char *format,
...)
{
va_list args;
char *str;
if (!menu_verbose_enabled ())
return;
va_start (args, format);
str = g_strdup_vprintf (format, args);
va_end (args);
utf8_fputs (str, stderr);
fflush (stderr);
g_free (str);
}
static void append_to_string (MenuLayoutNode *node,
gboolean onelevel,
int depth,
GString *str);
static void
append_spaces (GString *str,
int depth)
{
while (depth > 0)
{
g_string_append_c (str, ' ');
--depth;
}
}
static void
append_children (MenuLayoutNode *node,
int depth,
GString *str)
{
MenuLayoutNode *iter;
iter = menu_layout_node_get_children (node);
while (iter != NULL)
{
append_to_string (iter, FALSE, depth, str);
iter = menu_layout_node_get_next (iter);
}
}
static void
append_simple_with_attr (MenuLayoutNode *node,
int depth,
const char *node_name,
const char *attr_name,
const char *attr_value,
GString *str)
{
const char *content;
append_spaces (str, depth);
if ((content = menu_layout_node_get_content (node)))
{
char *escaped;
escaped = g_markup_escape_text (content, -1);
if (attr_name && attr_value)
{
char *attr_escaped;
attr_escaped = g_markup_escape_text (attr_value, -1);
g_string_append_printf (str, "<%s %s=\"%s\">%s%s>\n",
node_name, attr_name,
attr_escaped, escaped, node_name);
g_free (attr_escaped);
}
else
{
g_string_append_printf (str, "<%s>%s%s>\n",
node_name, escaped, node_name);
}
g_free (escaped);
}
else
{
if (attr_name && attr_value)
{
char *attr_escaped;
attr_escaped = g_markup_escape_text (attr_value, -1);
g_string_append_printf (str, "<%s %s=\"%s\"/>\n",
node_name, attr_name,
attr_escaped);
g_free (attr_escaped);
}
else
{
g_string_append_printf (str, "<%s/>\n", node_name);
}
}
}
static void
append_layout (MenuLayoutNode *node,
int depth,
const char *node_name,
MenuLayoutValues *layout_values,
GString *str)
{
const char *content;
append_spaces (str, depth);
if ((content = menu_layout_node_get_content (node)))
{
char *escaped;
escaped = g_markup_escape_text (content, -1);
g_string_append_printf (str,
"<%s show_empty=\"%s\" inline=\"%s\" inline_header=\"%s\""
" inline_alias=\"%s\" inline_limit=\"%d\">%s%s>\n",
node_name,
layout_values->show_empty ? "true" : "false",
layout_values->inline_menus ? "true" : "false",
layout_values->inline_header ? "true" : "false",
layout_values->inline_alias ? "true" : "false",
layout_values->inline_limit,
escaped,
node_name);
g_free (escaped);
}
else
{
g_string_append_printf (str,
"<%s show_empty=\"%s\" inline=\"%s\" inline_header=\"%s\""
" inline_alias=\"%s\" inline_limit=\"%d\"/>\n",
node_name,
layout_values->show_empty ? "true" : "false",
layout_values->inline_menus ? "true" : "false",
layout_values->inline_header ? "true" : "false",
layout_values->inline_alias ? "true" : "false",
layout_values->inline_limit);
}
}
static void
append_merge (MenuLayoutNode *node,
int depth,
const char *node_name,
MenuLayoutMergeType merge_type,
GString *str)
{
const char *merge_type_str;
merge_type_str = NULL;
switch (merge_type)
{
case MENU_LAYOUT_MERGE_NONE:
merge_type_str = "none";
break;
case MENU_LAYOUT_MERGE_MENUS:
merge_type_str = "menus";
break;
case MENU_LAYOUT_MERGE_FILES:
merge_type_str = "files";
break;
case MENU_LAYOUT_MERGE_ALL:
merge_type_str = "all";
break;
default:
g_assert_not_reached ();
break;
}
append_simple_with_attr (node, depth, node_name, "type", merge_type_str, str);
}
static void
append_simple (MenuLayoutNode *node,
int depth,
const char *node_name,
GString *str)
{
append_simple_with_attr (node, depth, node_name, NULL, NULL, str);
}
static void
append_start (MenuLayoutNode *node,
int depth,
const char *node_name,
GString *str)
{
append_spaces (str, depth);
g_string_append_printf (str, "<%s>\n", node_name);
}
static void
append_end (MenuLayoutNode *node,
int depth,
const char *node_name,
GString *str)
{
append_spaces (str, depth);
g_string_append_printf (str, "%s>\n", node_name);
}
static void
append_container (MenuLayoutNode *node,
gboolean onelevel,
int depth,
const char *node_name,
GString *str)
{
append_start (node, depth, node_name, str);
if (!onelevel)
{
append_children (node, depth + 2, str);
append_end (node, depth, node_name, str);
}
}
static void
append_to_string (MenuLayoutNode *node,
gboolean onelevel,
int depth,
GString *str)
{
MenuLayoutValues layout_values;
switch (menu_layout_node_get_type (node))
{
case MENU_LAYOUT_NODE_ROOT:
if (!onelevel)
append_children (node, depth - 1, str); /* -1 to ignore depth of root */
else
append_start (node, depth - 1, "Root", str);
break;
case MENU_LAYOUT_NODE_PASSTHROUGH:
g_string_append (str,
menu_layout_node_get_content (node));
g_string_append_c (str, '\n');
break;
case MENU_LAYOUT_NODE_MENU:
append_container (node, onelevel, depth, "Menu", str);
break;
case MENU_LAYOUT_NODE_APP_DIR:
append_simple (node, depth, "AppDir", str);
break;
case MENU_LAYOUT_NODE_DEFAULT_APP_DIRS:
append_simple (node, depth, "DefaultAppDirs", str);
break;
case MENU_LAYOUT_NODE_DIRECTORY_DIR:
append_simple (node, depth, "DirectoryDir", str);
break;
case MENU_LAYOUT_NODE_DEFAULT_DIRECTORY_DIRS:
append_simple (node, depth, "DefaultDirectoryDirs", str);
break;
case MENU_LAYOUT_NODE_DEFAULT_MERGE_DIRS:
append_simple (node, depth, "DefaultMergeDirs", str);
break;
case MENU_LAYOUT_NODE_NAME:
append_simple (node, depth, "Name", str);
break;
case MENU_LAYOUT_NODE_DIRECTORY:
append_simple (node, depth, "Directory", str);
break;
case MENU_LAYOUT_NODE_ONLY_UNALLOCATED:
append_simple (node, depth, "OnlyUnallocated", str);
break;
case MENU_LAYOUT_NODE_NOT_ONLY_UNALLOCATED:
append_simple (node, depth, "NotOnlyUnallocated", str);
break;
case MENU_LAYOUT_NODE_INCLUDE:
append_container (node, onelevel, depth, "Include", str);
break;
case MENU_LAYOUT_NODE_EXCLUDE:
append_container (node, onelevel, depth, "Exclude", str);
break;
case MENU_LAYOUT_NODE_FILENAME:
append_simple (node, depth, "Filename", str);
break;
case MENU_LAYOUT_NODE_CATEGORY:
append_simple (node, depth, "Category", str);
break;
case MENU_LAYOUT_NODE_ALL:
append_simple (node, depth, "All", str);
break;
case MENU_LAYOUT_NODE_AND:
append_container (node, onelevel, depth, "And", str);
break;
case MENU_LAYOUT_NODE_OR:
append_container (node, onelevel, depth, "Or", str);
break;
case MENU_LAYOUT_NODE_NOT:
append_container (node, onelevel, depth, "Not", str);
break;
case MENU_LAYOUT_NODE_MERGE_FILE:
{
MenuMergeFileType type;
type = menu_layout_node_merge_file_get_type (node);
append_simple_with_attr (node, depth, "MergeFile",
"type", type == MENU_MERGE_FILE_TYPE_PARENT ? "parent" : "path",
str);
break;
}
case MENU_LAYOUT_NODE_MERGE_DIR:
append_simple (node, depth, "MergeDir", str);
break;
case MENU_LAYOUT_NODE_LEGACY_DIR:
append_simple_with_attr (node, depth, "LegacyDir",
"prefix", menu_layout_node_legacy_dir_get_prefix (node),
str);
break;
case MENU_LAYOUT_NODE_KDE_LEGACY_DIRS:
append_simple (node, depth, "KDELegacyDirs", str);
break;
case MENU_LAYOUT_NODE_MOVE:
append_container (node, onelevel, depth, "Move", str);
break;
case MENU_LAYOUT_NODE_OLD:
append_simple (node, depth, "Old", str);
break;
case MENU_LAYOUT_NODE_NEW:
append_simple (node, depth, "New", str);
break;
case MENU_LAYOUT_NODE_DELETED:
append_simple (node, depth, "Deleted", str);
break;
case MENU_LAYOUT_NODE_NOT_DELETED:
append_simple (node, depth, "NotDeleted", str);
break;
case MENU_LAYOUT_NODE_LAYOUT:
append_container (node, onelevel, depth, "Layout", str);
break;
case MENU_LAYOUT_NODE_DEFAULT_LAYOUT:
menu_layout_node_default_layout_get_values (node, &layout_values);
append_layout (node, depth, "DefaultLayout", &layout_values, str);
break;
case MENU_LAYOUT_NODE_MENUNAME:
menu_layout_node_menuname_get_values (node, &layout_values);
append_layout (node, depth, "MenuName", &layout_values, str);
break;
case MENU_LAYOUT_NODE_SEPARATOR:
append_simple (node, depth, "Name", str);
break;
case MENU_LAYOUT_NODE_MERGE:
append_merge (node,
depth,
"Merge",
menu_layout_node_merge_get_type (node),
str);
break;
default:
g_assert_not_reached ();
break;
}
}
void
menu_debug_print_layout (MenuLayoutNode *node,
gboolean onelevel)
{
if (menu_verbose_enabled ())
{
GString *str;
str = g_string_new (NULL);
append_to_string (node, onelevel, 0, str);
utf8_fputs (str->str, stderr);
fflush (stderr);
g_string_free (str, TRUE);
}
}
#endif /* G_ENABLE_DEBUG */
cinnamon-menus-2.8.0/libmenu/libcinnamon-menu-3.0-uninstalled.pc.in 0000664 0001750 0001750 00000000461 12610172545 023631 0 ustar maxy maxy prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libcinnamon-menu
Description: Desktop Menu Specification Implementation
Requires: gio-unix-2.0
Version: @VERSION@
Libs: ${pc_top_builddir}/${pcfiledir}/libcinnamon-menu-3.la
Cflags: -I${pc_top_builddir}/${pcfiledir}
cinnamon-menus-2.8.0/libmenu/gmenu-tree.c 0000664 0001750 0001750 00000400700 12610172545 017043 0 ustar maxy maxy /* -*- mode:c; c-file-style: "gnu"; indent-tabs-mode: nil -*-
* Copyright (C) 2003, 2004, 2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include
#include "gmenu-tree.h"
#include
#include
#include "menu-layout.h"
#include "menu-monitor.h"
#include "menu-util.h"
#include "canonicalize.h"
/* private */
typedef struct GMenuTreeItem GMenuTreeItem;
#define GMENU_TREE_ITEM(i) ((GMenuTreeItem *)(i))
#define GMENU_TREE_DIRECTORY(i) ((GMenuTreeDirectory *)(i))
#define GMENU_TREE_ENTRY(i) ((GMenuTreeEntry *)(i))
#define GMENU_TREE_SEPARATOR(i) ((GMenuTreeSeparator *)(i))
#define GMENU_TREE_HEADER(i) ((GMenuTreeHeader *)(i))
#define GMENU_TREE_ALIAS(i) ((GMenuTreeAlias *)(i))
enum {
PROP_0,
PROP_MENU_BASENAME,
PROP_MENU_PATH,
PROP_FLAGS
};
/* Signals */
enum
{
CHANGED,
LAST_SIGNAL
};
static guint gmenu_tree_signals [LAST_SIGNAL] = { 0 };
struct _GMenuTree
{
GObject parent_instance;
char *basename;
char *non_prefixed_basename;
char *path;
char *canonical_path;
GMenuTreeFlags flags;
GSList *menu_file_monitors;
MenuLayoutNode *layout;
GMenuTreeDirectory *root;
GHashTable *entries_by_id;
guint canonical : 1;
guint loaded : 1;
};
G_DEFINE_TYPE (GMenuTree, gmenu_tree, G_TYPE_OBJECT)
struct GMenuTreeItem
{
volatile gint refcount;
GMenuTreeItemType type;
GMenuTreeDirectory *parent;
GMenuTree *tree;
};
struct GMenuTreeIter
{
volatile gint refcount;
GMenuTreeItem *item;
GSList *contents;
GSList *contents_iter;
};
struct GMenuTreeDirectory
{
GMenuTreeItem item;
DesktopEntry *directory_entry;
char *name;
GSList *entries;
GSList *subdirs;
MenuLayoutValues default_layout_values;
GSList *default_layout_info;
GSList *layout_info;
GSList *contents;
guint only_unallocated : 1;
guint is_nodisplay : 1;
guint layout_pending_separator : 1;
guint preprocessed : 1;
/* 16 bits should be more than enough; G_MAXUINT16 means no inline header */
guint will_inline_header : 16;
};
struct GMenuTreeEntry
{
GMenuTreeItem item;
DesktopEntry *desktop_entry;
char *desktop_file_id;
guint is_excluded : 1;
guint is_unallocated : 1;
};
struct GMenuTreeSeparator
{
GMenuTreeItem item;
};
struct GMenuTreeHeader
{
GMenuTreeItem item;
GMenuTreeDirectory *directory;
};
struct GMenuTreeAlias
{
GMenuTreeItem item;
GMenuTreeDirectory *directory;
GMenuTreeItem *aliased_item;
};
static gboolean gmenu_tree_load_layout (GMenuTree *tree,
GError **error);
static void gmenu_tree_force_reload (GMenuTree *tree);
static gboolean gmenu_tree_build_from_layout (GMenuTree *tree,
GError **error);
static void gmenu_tree_force_rebuild (GMenuTree *tree);
static void gmenu_tree_resolve_files (GMenuTree *tree,
GHashTable *loaded_menu_files,
MenuLayoutNode *layout);
static void gmenu_tree_force_recanonicalize (GMenuTree *tree);
static void gmenu_tree_invoke_monitors (GMenuTree *tree);
static void gmenu_tree_item_unref_and_unset_parent (gpointer itemp);
typedef enum
{
MENU_FILE_MONITOR_INVALID = 0,
MENU_FILE_MONITOR_FILE,
MENU_FILE_MONITOR_NONEXISTENT_FILE,
MENU_FILE_MONITOR_DIRECTORY
} MenuFileMonitorType;
typedef struct
{
MenuFileMonitorType type;
MenuMonitor *monitor;
} MenuFileMonitor;
static void
handle_nonexistent_menu_file_changed (MenuMonitor *monitor,
MenuMonitorEvent event,
const char *path,
GMenuTree *tree)
{
if (event == MENU_MONITOR_EVENT_CHANGED ||
event == MENU_MONITOR_EVENT_CREATED)
{
menu_verbose ("\"%s\" %s, marking tree for recanonicalization\n",
path,
event == MENU_MONITOR_EVENT_CREATED ? "created" : "changed");
gmenu_tree_force_recanonicalize (tree);
gmenu_tree_invoke_monitors (tree);
}
}
static void
handle_menu_file_changed (MenuMonitor *monitor,
MenuMonitorEvent event,
const char *path,
GMenuTree *tree)
{
menu_verbose ("\"%s\" %s, marking tree for recanicalization\n",
path,
event == MENU_MONITOR_EVENT_CREATED ? "created" :
event == MENU_MONITOR_EVENT_CHANGED ? "changed" : "deleted");
gmenu_tree_force_recanonicalize (tree);
gmenu_tree_invoke_monitors (tree);
}
static void
handle_menu_file_directory_changed (MenuMonitor *monitor,
MenuMonitorEvent event,
const char *path,
GMenuTree *tree)
{
if (!g_str_has_suffix (path, ".menu"))
return;
menu_verbose ("\"%s\" %s, marking tree for recanicalization\n",
path,
event == MENU_MONITOR_EVENT_CREATED ? "created" :
event == MENU_MONITOR_EVENT_CHANGED ? "changed" : "deleted");
gmenu_tree_force_recanonicalize (tree);
gmenu_tree_invoke_monitors (tree);
}
static void
gmenu_tree_add_menu_file_monitor (GMenuTree *tree,
const char *path,
MenuFileMonitorType type)
{
MenuFileMonitor *monitor;
monitor = g_slice_new0 (MenuFileMonitor);
monitor->type = type;
switch (type)
{
case MENU_FILE_MONITOR_FILE:
menu_verbose ("Adding a menu file monitor for \"%s\"\n", path);
monitor->monitor = menu_get_file_monitor (path);
menu_monitor_add_notify (monitor->monitor,
(MenuMonitorNotifyFunc) handle_menu_file_changed,
tree);
break;
case MENU_FILE_MONITOR_NONEXISTENT_FILE:
menu_verbose ("Adding a menu file monitor for non-existent \"%s\"\n", path);
monitor->monitor = menu_get_file_monitor (path);
menu_monitor_add_notify (monitor->monitor,
(MenuMonitorNotifyFunc) handle_nonexistent_menu_file_changed,
tree);
break;
case MENU_FILE_MONITOR_DIRECTORY:
menu_verbose ("Adding a menu directory monitor for \"%s\"\n", path);
monitor->monitor = menu_get_directory_monitor (path);
menu_monitor_add_notify (monitor->monitor,
(MenuMonitorNotifyFunc) handle_menu_file_directory_changed,
tree);
break;
default:
g_assert_not_reached ();
break;
}
tree->menu_file_monitors = g_slist_prepend (tree->menu_file_monitors, monitor);
}
static void
remove_menu_file_monitor (MenuFileMonitor *monitor,
GMenuTree *tree)
{
switch (monitor->type)
{
case MENU_FILE_MONITOR_FILE:
menu_monitor_remove_notify (monitor->monitor,
(MenuMonitorNotifyFunc) handle_menu_file_changed,
tree);
break;
case MENU_FILE_MONITOR_NONEXISTENT_FILE:
menu_monitor_remove_notify (monitor->monitor,
(MenuMonitorNotifyFunc) handle_nonexistent_menu_file_changed,
tree);
break;
case MENU_FILE_MONITOR_DIRECTORY:
menu_monitor_remove_notify (monitor->monitor,
(MenuMonitorNotifyFunc) handle_menu_file_directory_changed,
tree);
break;
default:
g_assert_not_reached ();
break;
}
menu_monitor_unref (monitor->monitor);
monitor->monitor = NULL;
monitor->type = MENU_FILE_MONITOR_INVALID;
g_slice_free (MenuFileMonitor, monitor);
}
static void
gmenu_tree_remove_menu_file_monitors (GMenuTree *tree)
{
menu_verbose ("Removing all menu file monitors\n");
g_slist_foreach (tree->menu_file_monitors,
(GFunc) remove_menu_file_monitor,
tree);
g_slist_free (tree->menu_file_monitors);
tree->menu_file_monitors = NULL;
}
static gboolean
canonicalize_path (GMenuTree *tree,
const char *path)
{
tree->canonical_path = menu_canonicalize_file_name (path, FALSE);
if (tree->canonical_path)
{
tree->canonical = TRUE;
gmenu_tree_add_menu_file_monitor (tree,
tree->canonical_path,
MENU_FILE_MONITOR_FILE);
}
else
{
gmenu_tree_add_menu_file_monitor (tree,
path,
MENU_FILE_MONITOR_NONEXISTENT_FILE);
}
return tree->canonical;
}
static gboolean
canonicalize_basename_with_config_dir (GMenuTree *tree,
const char *basename,
const char *config_dir)
{
gboolean ret;
char *path;
path = g_build_filename (config_dir, "menus", basename, NULL);
ret = canonicalize_path (tree, path);
g_free (path);
return ret;
}
static void
canonicalize_basename (GMenuTree *tree,
const char *basename)
{
if (!canonicalize_basename_with_config_dir (tree,
basename,
g_get_user_config_dir ()))
{
const char * const *system_config_dirs;
int i;
system_config_dirs = g_get_system_config_dirs ();
i = 0;
while (system_config_dirs[i] != NULL)
{
if (canonicalize_basename_with_config_dir (tree,
basename,
system_config_dirs[i]))
break;
++i;
}
}
}
static char *
prefix_menu_name (const char *orig_name)
{
char *prefix;
prefix = (char *) g_getenv ("XDG_MENU_PREFIX");
if (prefix == NULL)
prefix = "gnome-";
return g_strconcat (prefix, orig_name, NULL);
}
static gboolean
gmenu_tree_canonicalize_path (GMenuTree *tree,
GError **error)
{
const char *menu_file = NULL;
if (tree->canonical)
return TRUE;
g_assert (tree->canonical_path == NULL);
gmenu_tree_remove_menu_file_monitors (tree);
if (tree->path)
{
menu_file = tree->path;
canonicalize_path (tree, tree->path);
}
else
{
const gchar *xdg_menu_prefix;
menu_file = tree->basename;
xdg_menu_prefix = g_getenv ("XDG_MENU_PREFIX");
if (xdg_menu_prefix == NULL)
xdg_menu_prefix = "gnome-";
if (xdg_menu_prefix != NULL)
{
gchar *prefixed_basename;
prefixed_basename = g_strdup_printf ("%sapplications.menu",
xdg_menu_prefix);
/* Some gnome-menus using applications just use "applications.menu"
* as the basename and expect gnome-menus to prefix it. Others (e.g.
* Alacarte) explicitly use "${XDG_MENU_PREFIX}applications.menu" as
* the basename, because they want to save changes to the right files
* in ~. In both cases, we want to use "applications-merged" as the
* merge directory (as required by the fd.o menu spec), so we save
* the non-prefixed basename and use it later when calling
* menu_layout_load().
*/
if (!g_strcmp0 (tree->basename, "applications.menu") ||
!g_strcmp0 (tree->basename, prefixed_basename))
{
canonicalize_basename (tree, prefixed_basename);
g_free (tree->non_prefixed_basename);
tree->non_prefixed_basename = g_strdup ("applications.menu");
}
g_free (prefixed_basename);
}
if (!tree->canonical)
canonicalize_basename (tree, tree->basename);
}
if (tree->canonical)
{
menu_verbose ("Successfully looked up menu_file for \"%s\": %s\n",
menu_file, tree->canonical_path);
return TRUE;
}
else
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"Failed to look up menu_file for \"%s\"\n",
menu_file);
return FALSE;
}
}
static void
gmenu_tree_force_recanonicalize (GMenuTree *tree)
{
gmenu_tree_remove_menu_file_monitors (tree);
if (tree->canonical)
{
gmenu_tree_force_reload (tree);
g_free (tree->canonical_path);
tree->canonical_path = NULL;
tree->canonical = FALSE;
}
}
/**
* gmenu_tree_new:
* @menu_basename: Basename of menu file
* @flags: Flags controlling menu content
*
* Returns: (transfer full): A new #GMenuTree instance
*/
GMenuTree *
gmenu_tree_new (const char *menu_basename,
GMenuTreeFlags flags)
{
g_return_val_if_fail (menu_basename != NULL, NULL);
return g_object_new (GMENU_TYPE_TREE,
"menu-basename", menu_basename,
"flags", flags,
NULL);
}
/**
* gmenu_tree_new_fo_path:
* @menu_path: Path of menu file
* @flags: Flags controlling menu content
*
* Returns: (transfer full): A new #GMenuTree instance
*/
GMenuTree *
gmenu_tree_new_for_path (const char *menu_path,
GMenuTreeFlags flags)
{
g_return_val_if_fail (menu_path != NULL, NULL);
return g_object_new (GMENU_TYPE_TREE,
"menu-path", menu_path,
"flags", flags,
NULL);
}
static GObject *
gmenu_tree_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *obj;
GMenuTree *self;
obj = G_OBJECT_CLASS (gmenu_tree_parent_class)->constructor (type,
n_construct_properties,
construct_properties);
/* If GMenuTree:menu-path is set, then we should make sure that
* GMenuTree:menu-basename is unset (especially as it has a default
* value). This has to be done here, in the constructor, since the
* properties are construct-only. */
self = GMENU_TREE (obj);
if (self->path != NULL)
g_object_set (self, "menu-basename", NULL, NULL);
return obj;
}
static void
gmenu_tree_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GMenuTree *self = GMENU_TREE (object);
switch (prop_id)
{
case PROP_MENU_BASENAME:
self->basename = g_value_dup_string (value);
break;
case PROP_MENU_PATH:
self->path = g_value_dup_string (value);
break;
case PROP_FLAGS:
self->flags = g_value_get_flags (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gmenu_tree_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GMenuTree *self = GMENU_TREE (object);
switch (prop_id)
{
case PROP_MENU_BASENAME:
g_value_set_string (value, self->basename);
break;
case PROP_MENU_PATH:
g_value_set_string (value, self->path);
break;
case PROP_FLAGS:
g_value_set_flags (value, self->flags);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gmenu_tree_finalize (GObject *object)
{
GMenuTree *tree = GMENU_TREE (object);
gmenu_tree_force_recanonicalize (tree);
if (tree->basename != NULL)
g_free (tree->basename);
tree->basename = NULL;
g_free (tree->non_prefixed_basename);
tree->non_prefixed_basename = NULL;
if (tree->path != NULL)
g_free (tree->path);
tree->path = NULL;
if (tree->canonical_path != NULL)
g_free (tree->canonical_path);
tree->canonical_path = NULL;
g_hash_table_destroy (tree->entries_by_id);
tree->entries_by_id = NULL;
G_OBJECT_CLASS (gmenu_tree_parent_class)->finalize (object);
}
static void
gmenu_tree_init (GMenuTree *self)
{
self->entries_by_id = g_hash_table_new (g_str_hash, g_str_equal);
}
static void
gmenu_tree_class_init (GMenuTreeClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->constructor = gmenu_tree_constructor;
gobject_class->get_property = gmenu_tree_get_property;
gobject_class->set_property = gmenu_tree_set_property;
gobject_class->finalize = gmenu_tree_finalize;
/**
* GMenuTree:menu-basename:
*
* The name of the menu file; must be a basename or a relative path. The file
* will be looked up in $XDG_CONFIG_DIRS/menus/. See the Desktop Menu
* specification.
*/
g_object_class_install_property (gobject_class,
PROP_MENU_BASENAME,
g_param_spec_string ("menu-basename", "", "",
"applications.menu",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
* GMenuTree:menu-path:
*
* The full path of the menu file. If set, GMenuTree:menu-basename will get
* ignored.
*/
g_object_class_install_property (gobject_class,
PROP_MENU_PATH,
g_param_spec_string ("menu-path", "", "",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
* GMenuTree:flags:
*
* Flags controlling the content of the menu.
*/
g_object_class_install_property (gobject_class,
PROP_FLAGS,
g_param_spec_flags ("flags", "", "",
GMENU_TYPE_TREE_FLAGS,
GMENU_TREE_FLAGS_NONE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
* GMenuTree:changed:
*
* This signal is emitted when applications are added, removed, or
* upgraded. But note the new data will only be visible after
* gmenu_tree_load_sync() or a variant thereof is invoked.
*/
gmenu_tree_signals[CHANGED] =
g_signal_new ("changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
/**
* gmenu_tree_get_canonical_menu_path:
* @tree: a #GMenuTree
*
* This function is only available if the tree has been loaded via
* gmenu_tree_load_sync() or a variant thereof.
*
* Returns: The absolute and canonicalized path to the loaded menu file
*/
const char *
gmenu_tree_get_canonical_menu_path (GMenuTree *tree)
{
g_return_val_if_fail (GMENU_IS_TREE (tree), NULL);
g_return_val_if_fail (tree->loaded, NULL);
return tree->canonical_path;
}
/**
* gmenu_tree_load_sync:
* @tree: a #GMenuTree
* @error: a #GError
*
* Synchronously load the menu contents. This function
* performs a significant amount of blocking I/O if the
* tree has not been loaded yet.
*
* Returns: %TRUE on success, %FALSE on error
*/
gboolean
gmenu_tree_load_sync (GMenuTree *tree,
GError **error)
{
GError *local_error = NULL;
if (tree->loaded)
return TRUE;
if (!gmenu_tree_build_from_layout (tree, &local_error))
{
if (local_error)
g_propagate_error (error, local_error);
return FALSE;
}
tree->loaded = TRUE;
return TRUE;
}
/**
* gmenu_tree_get_root_directory:
* @tree: a #GMenuTree
*
* Get the root directory; you must have loaded the tree first (at
* least once) via gmenu_tree_load_sync() or a variant thereof.
*
* Returns: (transfer full): Root of the tree
*/
GMenuTreeDirectory *
gmenu_tree_get_root_directory (GMenuTree *tree)
{
g_return_val_if_fail (tree != NULL, NULL);
g_return_val_if_fail (tree->loaded, NULL);
return gmenu_tree_item_ref (tree->root);
}
static GMenuTreeDirectory *
find_path (GMenuTreeDirectory *directory,
const char *path)
{
const char *name;
char *slash;
char *freeme;
GSList *tmp;
while (path[0] == G_DIR_SEPARATOR) path++;
if (path[0] == '\0')
return directory;
freeme = NULL;
slash = strchr (path, G_DIR_SEPARATOR);
if (slash)
{
name = freeme = g_strndup (path, slash - path);
path = slash + 1;
}
else
{
name = path;
path = NULL;
}
tmp = directory->contents;
while (tmp != NULL)
{
GMenuTreeItem *item = tmp->data;
if (item->type != GMENU_TREE_ITEM_DIRECTORY)
{
tmp = tmp->next;
continue;
}
if (!strcmp (name, GMENU_TREE_DIRECTORY (item)->name))
{
g_free (freeme);
if (path)
return find_path (GMENU_TREE_DIRECTORY (item), path);
else
return GMENU_TREE_DIRECTORY (item);
}
tmp = tmp->next;
}
g_free (freeme);
return NULL;
}
GMenuTreeDirectory *
gmenu_tree_get_directory_from_path (GMenuTree *tree,
const char *path)
{
GMenuTreeDirectory *root;
GMenuTreeDirectory *directory;
g_return_val_if_fail (tree != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
if (path[0] != G_DIR_SEPARATOR)
return NULL;
if (!(root = gmenu_tree_get_root_directory (tree)))
return NULL;
directory = find_path (root, path);
gmenu_tree_item_unref (root);
return directory ? gmenu_tree_item_ref (directory) : NULL;
}
/**
* gmenu_tree_get_entry_by_id:
* @tree: a #GMenuTree
* @id: a desktop file ID
*
* Look up the entry corresponding to the given "desktop file id".
*
* Returns: (transfer full): A newly referenced #GMenuTreeEntry, or %NULL if none
*/
GMenuTreeEntry *
gmenu_tree_get_entry_by_id (GMenuTree *tree,
const char *id)
{
GMenuTreeEntry *entry;
g_return_val_if_fail (tree->loaded, NULL);
entry = g_hash_table_lookup (tree->entries_by_id, id);
if (entry != NULL)
gmenu_tree_item_ref (entry);
return entry;
}
static void
gmenu_tree_invoke_monitors (GMenuTree *tree)
{
g_signal_emit (tree, gmenu_tree_signals[CHANGED], 0);
}
static GMenuTreeDirectory *
get_parent (GMenuTreeItem *item)
{
g_return_val_if_fail (item != NULL, NULL);
return item->parent ? gmenu_tree_item_ref (item->parent) : NULL;
}
/**
* gmenu_tree_directory_get_parent:
* @directory: a #GMenuTreeDirectory
*
* Returns: (transfer full): The parent directory, or %NULL if none
*/
GMenuTreeDirectory *
gmenu_tree_directory_get_parent (GMenuTreeDirectory *directory)
{
return get_parent ((GMenuTreeItem *)directory);
}
/**
* gmenu_tree_entry_get_parent:
* @entry: a #GMenuTreeEntry
*
* Returns: (transfer full): The parent directory, or %NULL if none
*/
GMenuTreeDirectory *
gmenu_tree_entry_get_parent (GMenuTreeEntry *entry)
{
return get_parent ((GMenuTreeItem *)entry);
}
/**
* gmenu_tree_alias_get_parent:
* @alias: a #GMenuTreeAlias
*
* Returns: (transfer full): The parent directory, or %NULL if none
*/
GMenuTreeDirectory *
gmenu_tree_alias_get_parent (GMenuTreeAlias *alias)
{
return get_parent ((GMenuTreeItem *)alias);
}
/**
* gmenu_tree_header_get_parent:
* @header: a #GMenuTreeHeader
*
* Returns: (transfer full): The parent directory, or %NULL if none
*/
GMenuTreeDirectory *
gmenu_tree_header_get_parent (GMenuTreeHeader *header)
{
return get_parent ((GMenuTreeItem *)header);
}
/**
* gmenu_tree_separator_get_parent:
* @separator: a #GMenuTreeSeparator
*
* Returns: (transfer full): The parent directory, or %NULL if none
*/
GMenuTreeDirectory *
gmenu_tree_separator_get_parent (GMenuTreeSeparator *separator)
{
return get_parent ((GMenuTreeItem *)separator);
}
static void
gmenu_tree_item_set_parent (GMenuTreeItem *item,
GMenuTreeDirectory *parent)
{
g_return_if_fail (item != NULL);
item->parent = parent;
}
/**
* gmenu_tree_iter_ref: (skip)
* @iter: iter
*
* Increment the reference count of @iter
*/
GMenuTreeIter *
gmenu_tree_iter_ref (GMenuTreeIter *iter)
{
g_atomic_int_inc (&iter->refcount);
return iter;
}
/**
* gmenu_tree_iter_unref: (skip)
* @iter: iter
*
* Decrement the reference count of @iter
*/
void
gmenu_tree_iter_unref (GMenuTreeIter *iter)
{
if (!g_atomic_int_dec_and_test (&iter->refcount))
return;
g_slist_foreach (iter->contents, (GFunc)gmenu_tree_item_unref, NULL);
g_slist_free (iter->contents);
g_slice_free (GMenuTreeIter, iter);
}
/**
* gmenu_tree_directory_iter:
* @directory: directory
*
* Returns: (transfer full): A new iterator over the directory contents
*/
GMenuTreeIter *
gmenu_tree_directory_iter (GMenuTreeDirectory *directory)
{
GMenuTreeIter *iter;
g_return_val_if_fail (directory != NULL, NULL);
iter = g_slice_new0 (GMenuTreeIter);
iter->refcount = 1;
iter->contents = g_slist_copy (directory->contents);
iter->contents_iter = iter->contents;
g_slist_foreach (iter->contents, (GFunc) gmenu_tree_item_ref, NULL);
return iter;
}
/**
* gmenu_tree_iter_next:
* @iter: iter
*
* Change the iterator to the next item, and return its type. If
* there are no more items, %GMENU_TREE_ITEM_INVALID is returned.
*
* Returns: The type of the next item that can be retrived from the iterator
*/
GMenuTreeItemType
gmenu_tree_iter_next (GMenuTreeIter *iter)
{
g_return_val_if_fail (iter != NULL, GMENU_TREE_ITEM_INVALID);
if (iter->contents_iter)
{
iter->item = iter->contents_iter->data;
iter->contents_iter = iter->contents_iter->next;
return iter->item->type;
}
else
return GMENU_TREE_ITEM_INVALID;
}
/**
* gmenu_tree_iter_get_directory:
* @iter: iter
*
* This method may only be called if gmenu_tree_iter_next()
* returned GMENU_TREE_ITEM_DIRECTORY.
*
* Returns: (transfer full): A directory
*/
GMenuTreeDirectory *
gmenu_tree_iter_get_directory (GMenuTreeIter *iter)
{
g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (iter->item != NULL, NULL);
g_return_val_if_fail (iter->item->type == GMENU_TREE_ITEM_DIRECTORY, NULL);
return (GMenuTreeDirectory*)gmenu_tree_item_ref (iter->item);
}
/**
* gmenu_tree_iter_get_entry:
* @iter: iter
*
* This method may only be called if gmenu_tree_iter_next()
* returned GMENU_TREE_ITEM_ENTRY.
*
* Returns: (transfer full): An entry
*/
GMenuTreeEntry *
gmenu_tree_iter_get_entry (GMenuTreeIter *iter)
{
g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (iter->item != NULL, NULL);
g_return_val_if_fail (iter->item->type == GMENU_TREE_ITEM_ENTRY, NULL);
return (GMenuTreeEntry*)gmenu_tree_item_ref (iter->item);
}
/**
* gmenu_tree_iter_get_header:
* @iter: iter
*
* This method may only be called if gmenu_tree_iter_next()
* returned GMENU_TREE_ITEM_HEADER.
*
* Returns: (transfer full): A header
*/
GMenuTreeHeader *
gmenu_tree_iter_get_header (GMenuTreeIter *iter)
{
g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (iter->item != NULL, NULL);
g_return_val_if_fail (iter->item->type == GMENU_TREE_ITEM_HEADER, NULL);
return (GMenuTreeHeader*)gmenu_tree_item_ref (iter->item);
}
/**
* gmenu_tree_iter_get_alias:
* @iter: iter
*
* This method may only be called if gmenu_tree_iter_next()
* returned GMENU_TREE_ITEM_ALIAS.
*
* Returns: (transfer full): An alias
*/
GMenuTreeAlias *
gmenu_tree_iter_get_alias (GMenuTreeIter *iter)
{
g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (iter->item != NULL, NULL);
g_return_val_if_fail (iter->item->type == GMENU_TREE_ITEM_ALIAS, NULL);
return (GMenuTreeAlias*)gmenu_tree_item_ref (iter->item);
}
/**
* gmenu_tree_iter_get_separator:
* @iter: iter
*
* This method may only be called if gmenu_tree_iter_next()
* returned #GMENU_TREE_ITEM_SEPARATOR.
*
* Returns: (transfer full): A separator
*/
GMenuTreeSeparator *
gmenu_tree_iter_get_separator (GMenuTreeIter *iter)
{
g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (iter->item != NULL, NULL);
g_return_val_if_fail (iter->item->type == GMENU_TREE_ITEM_SEPARATOR, NULL);
return (GMenuTreeSeparator*)gmenu_tree_item_ref (iter->item);
}
const char *
gmenu_tree_directory_get_name (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, NULL);
if (!directory->directory_entry)
return directory->name;
return desktop_entry_get_name (directory->directory_entry);
}
const char *
gmenu_tree_directory_get_generic_name (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, NULL);
if (!directory->directory_entry)
return NULL;
return desktop_entry_get_generic_name (directory->directory_entry);
}
const char *
gmenu_tree_directory_get_comment (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, NULL);
if (!directory->directory_entry)
return NULL;
return desktop_entry_get_comment (directory->directory_entry);
}
/**
* gmenu_tree_directory_get_icon:
* @directory: a #GMenuTreeDirectory
*
* Gets the icon for the directory.
*
* Returns: (transfer none): The #GIcon for this directory
*/
GIcon *
gmenu_tree_directory_get_icon (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, NULL);
if (!directory->directory_entry)
return NULL;
return desktop_entry_get_icon (directory->directory_entry);
}
const char *
gmenu_tree_directory_get_desktop_file_path (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, NULL);
if (!directory->directory_entry)
return NULL;
return desktop_entry_get_path (directory->directory_entry);
}
const char *
gmenu_tree_directory_get_menu_id (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, NULL);
return directory->name;
}
gboolean
gmenu_tree_directory_get_is_nodisplay (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, FALSE);
return directory->is_nodisplay;
}
/**
* gmenu_tree_directory_get_tree:
* @directory: A #GMenuTreeDirectory
*
* Grab the tree associated with a #GMenuTreeItem.
*
* Returns: (transfer full): The #GMenuTree
*/
GMenuTree *
gmenu_tree_directory_get_tree (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, NULL);
return g_object_ref (directory->item.tree);
}
static void
append_directory_path (GMenuTreeDirectory *directory,
GString *path)
{
if (!directory->item.parent)
{
g_string_append_c (path, G_DIR_SEPARATOR);
return;
}
append_directory_path (directory->item.parent, path);
g_string_append (path, directory->name);
g_string_append_c (path, G_DIR_SEPARATOR);
}
char *
gmenu_tree_directory_make_path (GMenuTreeDirectory *directory,
GMenuTreeEntry *entry)
{
GString *path;
g_return_val_if_fail (directory != NULL, NULL);
path = g_string_new (NULL);
append_directory_path (directory, path);
if (entry != NULL)
{
const char *basename;
basename = desktop_entry_get_basename (entry->desktop_entry);
g_string_append (path, basename);
}
return g_string_free (path, FALSE);
}
/**
* gmenu_tree_entry_get_app_info:
* @entry: a #GMenuTreeEntry
*
* Returns: (transfer none): The #GDesktopAppInfo for this entry
*/
GDesktopAppInfo *
gmenu_tree_entry_get_app_info (GMenuTreeEntry *entry)
{
g_return_val_if_fail (entry != NULL, NULL);
return desktop_entry_get_app_info (entry->desktop_entry);
}
const char *
gmenu_tree_entry_get_desktop_file_path (GMenuTreeEntry *entry)
{
g_return_val_if_fail (entry != NULL, NULL);
return desktop_entry_get_path (entry->desktop_entry);
}
const char *
gmenu_tree_entry_get_desktop_file_id (GMenuTreeEntry *entry)
{
g_return_val_if_fail (entry != NULL, FALSE);
return entry->desktop_file_id;
}
gboolean
gmenu_tree_entry_get_is_nodisplay_recurse (GMenuTreeEntry *entry)
{
GMenuTreeDirectory *directory;
GDesktopAppInfo *app_info;
g_return_val_if_fail (entry != NULL, FALSE);
app_info = gmenu_tree_entry_get_app_info (entry);
if (g_desktop_app_info_get_nodisplay (app_info))
return TRUE;
directory = entry->item.parent;
while (directory != NULL)
{
if (directory->is_nodisplay)
return TRUE;
directory = directory->item.parent;
}
return FALSE;
}
gboolean
gmenu_tree_entry_get_is_excluded (GMenuTreeEntry *entry)
{
g_return_val_if_fail (entry != NULL, FALSE);
return entry->is_excluded;
}
gboolean
gmenu_tree_entry_get_is_unallocated (GMenuTreeEntry *entry)
{
g_return_val_if_fail (entry != NULL, FALSE);
return entry->is_unallocated;
}
/**
* gmenu_tree_entry_get_tree:
* @entry: A #GMenuTreeEntry
*
* Grab the tree associated with a #GMenuTreeEntry.
*
* Returns: (transfer full): The #GMenuTree
*/
GMenuTree *
gmenu_tree_entry_get_tree (GMenuTreeEntry *entry)
{
g_return_val_if_fail (entry != NULL, NULL);
return g_object_ref (entry->item.tree);
}
GMenuTreeDirectory *
gmenu_tree_header_get_directory (GMenuTreeHeader *header)
{
g_return_val_if_fail (header != NULL, NULL);
return gmenu_tree_item_ref (header->directory);
}
/**
* gmenu_tree_header_get_tree:
* @header: A #GMenuTreeHeader
*
* Grab the tree associated with a #GMenuTreeHeader.
*
* Returns: (transfer full): The #GMenuTree
*/
GMenuTree *
gmenu_tree_header_get_tree (GMenuTreeHeader *header)
{
g_return_val_if_fail (header != NULL, NULL);
return g_object_ref (header->item.tree);
}
GMenuTreeItemType
gmenu_tree_alias_get_aliased_item_type (GMenuTreeAlias *alias)
{
g_return_val_if_fail (alias != NULL, GMENU_TREE_ITEM_INVALID);
g_assert (alias->aliased_item != NULL);
return alias->aliased_item->type;
}
GMenuTreeDirectory *
gmenu_tree_alias_get_directory (GMenuTreeAlias *alias)
{
g_return_val_if_fail (alias != NULL, NULL);
return gmenu_tree_item_ref (alias->directory);
}
/**
* gmenu_tree_alias_get_tree:
* @alias: A #GMenuTreeAlias
*
* Grab the tree associated with a #GMenuTreeAlias.
*
* Returns: (transfer full): The #GMenuTree
*/
GMenuTree *
gmenu_tree_alias_get_tree (GMenuTreeAlias *alias)
{
g_return_val_if_fail (alias != NULL, NULL);
return g_object_ref (alias->item.tree);
}
/**
* gmenu_tree_separator_get_tree:
* @separator: A #GMenuTreeSeparator
*
* Grab the tree associated with a #GMenuTreeSeparator.
*
* Returns: (transfer full): The #GMenuTree
*/
GMenuTree *
gmenu_tree_separator_get_tree (GMenuTreeSeparator *separator)
{
g_return_val_if_fail (separator != NULL, NULL);
return g_object_ref (separator->item.tree);
}
/**
* gmenu_tree_alias_get_aliased_directory:
* @alias: alias
*
* Returns: (transfer full): The aliased directory entry
*/
GMenuTreeDirectory *
gmenu_tree_alias_get_aliased_directory (GMenuTreeAlias *alias)
{
g_return_val_if_fail (alias != NULL, NULL);
g_return_val_if_fail (alias->aliased_item->type == GMENU_TREE_ITEM_DIRECTORY, NULL);
return (GMenuTreeDirectory *) gmenu_tree_item_ref (alias->aliased_item);
}
/**
* gmenu_tree_alias_get_aliased_entry:
* @alias: alias
*
* Returns: (transfer full): The aliased entry
*/
GMenuTreeEntry *
gmenu_tree_alias_get_aliased_entry (GMenuTreeAlias *alias)
{
g_return_val_if_fail (alias != NULL, NULL);
g_return_val_if_fail (alias->aliased_item->type == GMENU_TREE_ITEM_ENTRY, NULL);
return (GMenuTreeEntry *) gmenu_tree_item_ref (alias->aliased_item);
}
static GMenuTreeDirectory *
gmenu_tree_directory_new (GMenuTree *tree,
GMenuTreeDirectory *parent,
const char *name)
{
GMenuTreeDirectory *retval;
retval = g_slice_new0 (GMenuTreeDirectory);
retval->item.type = GMENU_TREE_ITEM_DIRECTORY;
retval->item.parent = parent;
retval->item.refcount = 1;
retval->item.tree = tree;
retval->name = g_strdup (name);
retval->directory_entry = NULL;
retval->entries = NULL;
retval->subdirs = NULL;
retval->default_layout_info = NULL;
retval->layout_info = NULL;
retval->contents = NULL;
retval->only_unallocated = FALSE;
retval->is_nodisplay = FALSE;
retval->layout_pending_separator = FALSE;
retval->preprocessed = FALSE;
retval->will_inline_header = G_MAXUINT16;
retval->default_layout_values.mask = MENU_LAYOUT_VALUES_NONE;
retval->default_layout_values.show_empty = FALSE;
retval->default_layout_values.inline_menus = FALSE;
retval->default_layout_values.inline_limit = 4;
retval->default_layout_values.inline_header = FALSE;
retval->default_layout_values.inline_alias = FALSE;
return retval;
}
static void
gmenu_tree_directory_finalize (GMenuTreeDirectory *directory)
{
g_assert (directory->item.refcount == 0);
g_slist_foreach (directory->contents,
(GFunc) gmenu_tree_item_unref_and_unset_parent,
NULL);
g_slist_free (directory->contents);
directory->contents = NULL;
g_slist_foreach (directory->default_layout_info,
(GFunc) menu_layout_node_unref,
NULL);
g_slist_free (directory->default_layout_info);
directory->default_layout_info = NULL;
g_slist_foreach (directory->layout_info,
(GFunc) menu_layout_node_unref,
NULL);
g_slist_free (directory->layout_info);
directory->layout_info = NULL;
g_slist_foreach (directory->subdirs,
(GFunc) gmenu_tree_item_unref_and_unset_parent,
NULL);
g_slist_free (directory->subdirs);
directory->subdirs = NULL;
g_slist_foreach (directory->entries,
(GFunc) gmenu_tree_item_unref_and_unset_parent,
NULL);
g_slist_free (directory->entries);
directory->entries = NULL;
if (directory->directory_entry)
desktop_entry_unref (directory->directory_entry);
directory->directory_entry = NULL;
g_free (directory->name);
directory->name = NULL;
g_slice_free (GMenuTreeDirectory, directory);
}
static GMenuTreeSeparator *
gmenu_tree_separator_new (GMenuTreeDirectory *parent)
{
GMenuTreeSeparator *retval;
retval = g_slice_new0 (GMenuTreeSeparator);
retval->item.type = GMENU_TREE_ITEM_SEPARATOR;
retval->item.parent = parent;
retval->item.refcount = 1;
retval->item.tree = parent->item.tree;
return retval;
}
static void
gmenu_tree_separator_finalize (GMenuTreeSeparator *separator)
{
g_assert (separator->item.refcount == 0);
g_slice_free (GMenuTreeSeparator, separator);
}
static GMenuTreeHeader *
gmenu_tree_header_new (GMenuTreeDirectory *parent,
GMenuTreeDirectory *directory)
{
GMenuTreeHeader *retval;
retval = g_slice_new0 (GMenuTreeHeader);
retval->item.type = GMENU_TREE_ITEM_HEADER;
retval->item.parent = parent;
retval->item.refcount = 1;
retval->item.tree = parent->item.tree;
retval->directory = gmenu_tree_item_ref (directory);
gmenu_tree_item_set_parent (GMENU_TREE_ITEM (retval->directory), NULL);
return retval;
}
static void
gmenu_tree_header_finalize (GMenuTreeHeader *header)
{
g_assert (header->item.refcount == 0);
if (header->directory != NULL)
gmenu_tree_item_unref (header->directory);
header->directory = NULL;
g_slice_free (GMenuTreeHeader, header);
}
static GMenuTreeAlias *
gmenu_tree_alias_new (GMenuTreeDirectory *parent,
GMenuTreeDirectory *directory,
GMenuTreeItem *item)
{
GMenuTreeAlias *retval;
retval = g_slice_new0 (GMenuTreeAlias);
retval->item.type = GMENU_TREE_ITEM_ALIAS;
retval->item.parent = parent;
retval->item.refcount = 1;
retval->item.tree = parent->item.tree;
retval->directory = gmenu_tree_item_ref (directory);
if (item->type != GMENU_TREE_ITEM_ALIAS)
retval->aliased_item = gmenu_tree_item_ref (item);
else
{
GMenuTreeAlias *alias = GMENU_TREE_ALIAS (item);
retval->aliased_item = gmenu_tree_item_ref (alias->aliased_item);
}
gmenu_tree_item_set_parent (GMENU_TREE_ITEM (retval->directory), NULL);
gmenu_tree_item_set_parent (retval->aliased_item, NULL);
return retval;
}
static void
gmenu_tree_alias_finalize (GMenuTreeAlias *alias)
{
g_assert (alias->item.refcount == 0);
if (alias->directory != NULL)
gmenu_tree_item_unref (alias->directory);
alias->directory = NULL;
if (alias->aliased_item != NULL)
gmenu_tree_item_unref (alias->aliased_item);
alias->aliased_item = NULL;
g_slice_free (GMenuTreeAlias, alias);
}
static GMenuTreeEntry *
gmenu_tree_entry_new (GMenuTreeDirectory *parent,
DesktopEntry *desktop_entry,
const char *desktop_file_id,
gboolean is_excluded,
gboolean is_unallocated)
{
GMenuTreeEntry *retval;
retval = g_slice_new0 (GMenuTreeEntry);
retval->item.type = GMENU_TREE_ITEM_ENTRY;
retval->item.parent = parent;
retval->item.refcount = 1;
retval->item.tree = parent->item.tree;
retval->desktop_entry = desktop_entry_ref (desktop_entry);
retval->desktop_file_id = g_strdup (desktop_file_id);
retval->is_excluded = is_excluded != FALSE;
retval->is_unallocated = is_unallocated != FALSE;
return retval;
}
static void
gmenu_tree_entry_finalize (GMenuTreeEntry *entry)
{
g_assert (entry->item.refcount == 0);
g_free (entry->desktop_file_id);
entry->desktop_file_id = NULL;
if (entry->desktop_entry)
desktop_entry_unref (entry->desktop_entry);
entry->desktop_entry = NULL;
g_slice_free (GMenuTreeEntry, entry);
}
static int
gmenu_tree_entry_compare_by_id (GMenuTreeItem *a,
GMenuTreeItem *b)
{
if (a->type == GMENU_TREE_ITEM_ALIAS)
a = GMENU_TREE_ALIAS (a)->aliased_item;
if (b->type == GMENU_TREE_ITEM_ALIAS)
b = GMENU_TREE_ALIAS (b)->aliased_item;
return strcmp (GMENU_TREE_ENTRY (a)->desktop_file_id,
GMENU_TREE_ENTRY (b)->desktop_file_id);
}
/**
* gmenu_tree_item_ref:
* @item: a #GMenuTreeItem
*
* Returns: (transfer full): The same @item, or %NULL if @item is not a valid #GMenuTreeItem
*/
gpointer
gmenu_tree_item_ref (gpointer itemp)
{
GMenuTreeItem *item;
item = (GMenuTreeItem *) itemp;
g_return_val_if_fail (item != NULL, NULL);
g_return_val_if_fail (item->refcount > 0, NULL);
g_atomic_int_inc (&item->refcount);
return item;
}
void
gmenu_tree_item_unref (gpointer itemp)
{
GMenuTreeItem *item;
item = (GMenuTreeItem *) itemp;
g_return_if_fail (item != NULL);
g_return_if_fail (item->refcount > 0);
if (g_atomic_int_dec_and_test (&(item->refcount)))
{
switch (item->type)
{
case GMENU_TREE_ITEM_DIRECTORY:
gmenu_tree_directory_finalize (GMENU_TREE_DIRECTORY (item));
break;
case GMENU_TREE_ITEM_ENTRY:
gmenu_tree_entry_finalize (GMENU_TREE_ENTRY (item));
break;
case GMENU_TREE_ITEM_SEPARATOR:
gmenu_tree_separator_finalize (GMENU_TREE_SEPARATOR (item));
break;
case GMENU_TREE_ITEM_HEADER:
gmenu_tree_header_finalize (GMENU_TREE_HEADER (item));
break;
case GMENU_TREE_ITEM_ALIAS:
gmenu_tree_alias_finalize (GMENU_TREE_ALIAS (item));
break;
default:
g_assert_not_reached ();
break;
}
}
}
static void
gmenu_tree_item_unref_and_unset_parent (gpointer itemp)
{
GMenuTreeItem *item;
item = (GMenuTreeItem *) itemp;
g_return_if_fail (item != NULL);
gmenu_tree_item_set_parent (item, NULL);
gmenu_tree_item_unref (item);
}
static inline const char *
gmenu_tree_item_compare_get_name_helper (GMenuTreeItem *item,
GMenuTreeFlags flags)
{
const char *name;
name = NULL;
switch (item->type)
{
case GMENU_TREE_ITEM_DIRECTORY:
if (GMENU_TREE_DIRECTORY (item)->directory_entry)
name = desktop_entry_get_name (GMENU_TREE_DIRECTORY (item)->directory_entry);
else
name = GMENU_TREE_DIRECTORY (item)->name;
break;
case GMENU_TREE_ITEM_ENTRY:
if (flags & GMENU_TREE_FLAGS_SORT_DISPLAY_NAME)
name = g_app_info_get_display_name (G_APP_INFO (gmenu_tree_entry_get_app_info (GMENU_TREE_ENTRY (item))));
else
name = desktop_entry_get_name (GMENU_TREE_ENTRY (item)->desktop_entry);
break;
case GMENU_TREE_ITEM_ALIAS:
{
GMenuTreeItem *dir;
dir = GMENU_TREE_ITEM (GMENU_TREE_ALIAS (item)->directory);
name = gmenu_tree_item_compare_get_name_helper (dir, flags);
}
break;
case GMENU_TREE_ITEM_SEPARATOR:
case GMENU_TREE_ITEM_HEADER:
default:
g_assert_not_reached ();
break;
}
return name;
}
static int
gmenu_tree_item_compare (GMenuTreeItem *a,
GMenuTreeItem *b,
gpointer flags_p)
{
const char *name_a;
const char *name_b;
GMenuTreeFlags flags;
flags = GPOINTER_TO_INT (flags_p);
name_a = gmenu_tree_item_compare_get_name_helper (a, flags);
name_b = gmenu_tree_item_compare_get_name_helper (b, flags);
return g_utf8_collate (name_a, name_b);
}
static MenuLayoutNode *
find_menu_child (MenuLayoutNode *layout)
{
MenuLayoutNode *child;
child = menu_layout_node_get_children (layout);
while (child && menu_layout_node_get_type (child) != MENU_LAYOUT_NODE_MENU)
child = menu_layout_node_get_next (child);
return child;
}
static void
merge_resolved_children (GMenuTree *tree,
GHashTable *loaded_menu_files,
MenuLayoutNode *where,
MenuLayoutNode *from)
{
MenuLayoutNode *insert_after;
MenuLayoutNode *menu_child;
MenuLayoutNode *from_child;
gmenu_tree_resolve_files (tree, loaded_menu_files, from);
insert_after = where;
g_assert (menu_layout_node_get_type (insert_after) != MENU_LAYOUT_NODE_ROOT);
g_assert (menu_layout_node_get_parent (insert_after) != NULL);
/* skip root node */
menu_child = find_menu_child (from);
g_assert (menu_child != NULL);
g_assert (menu_layout_node_get_type (menu_child) == MENU_LAYOUT_NODE_MENU);
/* merge children of toplevel