Magellan Linux

Annotation of /smage/trunk/include/xdg.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations) (download)
Sat Jan 2 16:59:51 2010 UTC (14 years, 4 months ago) by niro
File size: 4204 byte(s)
-initial smage includes
1 niro 3 # $Id$
2     # xdg-utils
3    
4     # for a complete list of known categories see:
5     # http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry
6     #
7     # AudioVideo Audio Video Development Education
8     # Game Graphics Network Office Settings System
9     # Utility Building Debugger IDE GUIDesigner
10     # Profiling RevisionControl Translation Calendar
11     # ContactManagement Database Dictionary Chart
12     # Email Finance FlowChart PDA ProjectManagement
13     # Presentation Spreadsheet WordProcessor 2DGraphics
14     # VectorGraphics RasterGraphics 3DGraphics Scanning
15     # OCR Photography Viewer DesktopSettings HardwareSettings
16     # PackageManager Dialup InstantMessaging IRCClient
17     # FileTransfer HamRadio News P2P RemoteAccess Telephony
18     # WebBrowser WebDevelopment Midi Mixer Sequencer Tuner
19     # TV AudioVideoEditing Player Recorder DiscBurning
20     # ActionGame AdventureGame ArcadeGame BoardGame
21     # BlocksGame CardGame KidsGame LogicGame RolePlaying
22     # Simulation SportsGame StrategyGame Art Construction
23     # Music Languages Science Astronomy Biology Chemistry
24     # Geology Math MedicalSoftware Physics Amusement
25     # Archiving Electronics Emulator Engineering
26     # FileManager TerminalEmulator Filesystem Monitor
27     # Security Accessibility Calculator Clock TextEditor
28     # Core KDE GNOME GTK Qt Motif Java ConsoleOnly Screensaver
29     # TrayIcon Applet Shell
30    
31     sminclude mtools
32    
33     # desktop-file-utils are needed
34     SDEPEND="${SDEPEND}
35     >= dev-util/desktop-file-utils-0.1"
36    
37     # installs a desktop icon
38     minstall_desktop_icon()
39     {
40     local i
41     local name
42     local file
43     local comment
44     local exec
45     local icon
46     local terminal
47     local notify
48     local categories
49     local vendor
50     local all_categories
51     local mimetypes
52     local all_mimetypes
53    
54     for i in $*
55     do
56     case $1 in
57     --name|-n) shift; name="$1" ;;
58     --file|-f) shift; file="$1.desktop" ;;
59     --comment|-m) shift; comment="$1" ;;
60     --exec|-e) shift; exec="$1" ;;
61     --icon|-i) shift; icon="$1" ;;
62     --terminal|-t) terminal="true" ;;
63     --no-notify|-y) notify="false" ;;
64     --categories|-c) shift; categories="$1" ;;
65     --vendor|-v) shift; vendor="$1" ;;
66     --mimetypes|-x) shift; mimetypes="$1" ;;
67     esac
68     shift
69     done
70    
71     # sanity checks; abort if not given
72     #[[ -z ${name} ]] && die "minstall_desktop_icon() \$name not given."
73    
74     # some sane defaults
75     [[ -z ${name} ]] && name="${PNAME}"
76     [[ -z ${file} ]] && file="${name}.desktop"
77     [[ -z ${exec} ]] && exec="${name}"
78     [[ -z ${icon} ]] && icon="${name}.png"
79     [[ -z ${terminal} ]] && terminal="false"
80     [[ -z ${notify} ]] && notify="true"
81     [[ -z ${vendor} ]] && vendor="X-Magellan"
82    
83     # get all categories
84     if [[ -n ${categories} ]]
85     then
86     for i in $(echo ${categories} | sed "s:,:\ :g")
87     do
88     all_categories="${all_categories} --add-category ${i}"
89     done
90     fi
91    
92     # get all mimetypes
93     if [[ -n ${mimetypes} ]]
94     then
95     for i in $(echo ${mimetypes} | sed "s:,:\ :g")
96     do
97     all_mimetypes="${all_mimetypes} --add-mime-type ${i}"
98     done
99     fi
100    
101     echo "[Desktop Entry]
102     Encoding=UTF-8
103     Name=${name}
104     Comment=${comment}
105     Exec=${exec}
106     Icon=${icon}
107     Terminal=${terminal}
108     StartupNotify=${notify}
109     Type=Application" > ${SRCDIR}/${file}
110     desktop-file-install \
111     --vendor ${vendor} \
112     --delete-original \
113     --dir ${BINDIR}/usr/share/applications \
114     --add-category X-Magellan-Application \
115     ${all_categories} \
116     ${all_mimetyes} \
117     ${SRCDIR}/${file} \
118     || die
119     }
120    
121     # installs already created desktop icons to application dir
122     # minstallxdg {-s} srcname destname {/path/to}
123     minstallxdg()
124     {
125     local file
126     local destdir
127     local destfile
128    
129     [[ -z "$1" ]] && die "No xdg desktop file given"
130    
131     # if no fullpath given use file from sourcedir
132     if [[ $1 = -s ]]
133     then
134     file="${SOURCEDIR}/${PNAME}/$2"
135     destfile="$3"
136    
137     else
138     file="$1"
139     fi
140    
141     if [[ $1 = -s ]]
142     then
143     file="${SOURCEDIR}/${PNAME}/$2"
144     if [[ -n "$3" ]]
145     then
146     destfile="$3"
147     else
148     destfile="$(basename ${file})"
149     fi
150    
151     if [[ -n "$4" ]]
152     then
153     destdir="$4"
154     else
155     destdir="/usr/share/applications"
156     fi
157    
158     else
159     file="$1"
160     if [[ -n "$2" ]]
161     then
162     destfile="$2"
163     else
164     destfile="$(basename ${file})"
165     fi
166    
167     if [[ -n "$3" ]]
168     then
169     destdir="$3"
170     else
171     destdir="/usr/share/applications"
172     fi
173     fi
174    
175     # needed directory
176     minstalldir ${destdir} || die
177    
178     # install our xdg
179     minstallfile ${file} ${destdir}/${destfile} || die
180     }