Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 914 - (show annotations) (download)
Tue Dec 7 21:21:39 2010 UTC (13 years, 4 months ago) by niro
File size: 4095 byte(s)
-merged with upstream
1 # $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 -s given use file from sourcedir
132 if [[ $1 = -s ]]
133 then
134 file="${SOURCEDIR}/${PNAME}/$2"
135 if [[ -n "$3" ]]
136 then
137 destfile="$3"
138 else
139 destfile="$(basename ${file})"
140 fi
141
142 if [[ -n "$4" ]]
143 then
144 destdir="$4"
145 else
146 destdir="/usr/share/applications"
147 fi
148
149 else
150 file="$1"
151 if [[ -n "$2" ]]
152 then
153 destfile="$2"
154 else
155 destfile="$(basename ${file})"
156 fi
157
158 if [[ -n "$3" ]]
159 then
160 destdir="$3"
161 else
162 destdir="/usr/share/applications"
163 fi
164 fi
165
166 # needed directory
167 minstalldir ${destdir} || die
168
169 # install our xdg
170 minstallfile ${file} ${destdir}/${destfile} || die
171 }