Hi Michael: That's very nice indeed!
Just a little nitpick: the 'Foundation' Python module seems to be non-standard; at least it's not present by default on Tiger. Thus I suggest to use POSIX tools exclusively, as with the attached patch - somewhat more ugly, but serves the same. If the script is extended, only XML encoding in the strings must be taken into account which shouldn't be a hurdle. Otherwise, we must add the py module to either the repository (license?), or add it to the dependencies list. Opinions? Am 06.09.11 14:44 schrieb(en) Oliver Eichler:
interesting that Apple needs a special event to do this.
The Info.plist iirc serves more or less the same as the .desktop files on Linux - they just register extensions with an application. Try to erase the file, and see what happens with the icons... ;-) Best, Albrecht.
Index: src/CMakeLists.txt
===================================================================
--- src/CMakeLists.txt (revision 2964)
+++ src/CMakeLists.txt (working copy)
@@ -554,9 +554,9 @@
COMMAND
${CMAKE_SOURCE_DIR}/MacOSX/mklocversion.sh ${MAC_BUNDLE_PATH} ${qlandkarte_QM_FILES}
)
- add_custom_target(pimp-info.plist.py ALL
+ add_custom_target(modify-plist.sh ALL
COMMAND
- ${CMAKE_SOURCE_DIR}/MacOSX/pimp-info.plist.py ${MAC_BUNDLE_PATH}
+ ${CMAKE_SOURCE_DIR}/MacOSX/modify-plist.sh ${MAC_BUNDLE_PATH}/Contents/Info.plist
)
endif (APPLE)
ENDIF(ENABLE_TRANSLATION)
Index: MacOSX/pimp-info.plist.py
===================================================================
--- MacOSX/pimp-info.plist.py (revision 2964)
+++ MacOSX/pimp-info.plist.py (working copy)
@@ -1,44 +0,0 @@
-#!/usr/bin/python
-#
-# Augment cmake generated Info.plist with file formats understood by QLGT
-#
-# Written 2011 by Michael Klein <[email protected]>
-# Released under the terms of the GPL v. 2 as usual.
-
-import sys
-from Foundation import *
-
-if len(sys.argv) != 2:
- print >> sys.stderr, "Usage: %s <bundle>" % sys.argv[0]
- exit(1)
-
-info_plist = NSDictionary.dictionaryWithContentsOfFile_(sys.argv[1] + "/Contents/Info.plist")
-if info_plist == None:
- print >> sys.stderr, "Fatal: can't load <%s>" % sys.argv[1]
- exit(1)
-
-info_plist.setObject_forKey_("QLGT", "CFBundleSignature")
-
-btd = NSMutableArray.array()
-
-types = { "gpx": "GPS exchange data",
- "qlb": "QLandkarte data",
- "tcx": "TrainingsCenterExchange data",
- "gdb": "MapSource data",
- "kml": "Google Earth (Keyhole) data",
- "loc": "Geocaching.com - EasyGPS data",
- "plt": "OziExplorer track",
- "rte": "OziExplorer route",
- "wpt": "OziExplorer waypoint"
- }
-
-for ext, name in types.iteritems():
- dt = NSMutableDictionary.dictionary()
- dt.setObject_forKey_(NSArray.arrayWithObject_(ext), "CFBundleTypeExtensions")
- dt.setObject_forKey_(name, "CFBundleTypeName")
- # icons produced by http://code.google.com/p/docerator/
- dt.setObject_forKey_("qlandkartegt-%s.icns" % ext, "CFBundleTypeIconFile")
- btd.append(dt)
-
-info_plist.setObject_forKey_(btd, "CFBundleDocumentTypes")
-info_plist.writeToFile_atomically_(sys.argv[1] + "/Contents/Info.plist", True)
Index: MacOSX/modify-plist.sh
===================================================================
--- MacOSX/modify-plist.sh (revision 0)
+++ MacOSX/modify-plist.sh (revision 0)
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+if [ -z "$1" ] ; then
+ echo "usage: $0 <plist file>"
+ exit 1
+fi
+if [ ! -f "$1" ] ; then
+ echo "bad input file: $1"
+ exit 2
+fi
+
+TMPFILE=$(mktemp /tmp/qlgt.plist.XXXXXXXXXX) || exit 3
+
+(
+cat "$1" | \
+ tr '\n' '#' | \
+ sed -e 's;\(CFBundleSignature</key>[^<]*<string>\)....\(</string>\);\1QLGT\2;' -e 's;#</dict>#</plist>#$;;' | \
+ tr '#' '\n'
+
+read -r -d '' TYPES <<-'EOF'
+ gpx:GPS exchange data
+ qlb:QLandkarte data
+ tcx:TrainingsCenterExchange data
+ gdb:MapSource data
+ kml:Google Earth (Keyhole) data
+ loc:Geocaching.com - EasyGPS data
+ plt:OziExplorer track
+ rte:OziExplorer route
+ wpt:OziExplorer waypoint
+EOF
+
+echo -e '\t<key>CFBundleDocumentTypes</key>\n\t<array>'
+IFS='
+'
+for n in $TYPES ; do
+ echo -e '\t\t<dict>'
+ EXT=${n%%:*}
+ NAME=${n##*:}
+ echo -e "\t\t\t<key>CFBundleTypeExtensions</key>\n\t\t\t<array>\n\t\t\t\t<string>$EXT</string>\n\t\t\t</array>"
+ echo -e "\t\t\t<key>CFBundleTypeName</key>\n\t\t\t<string>$NAME</string>"
+ echo -e "\t\t\t<key>CFBundleTypeIconFile</key>\n\t\t\t<string>qlandkartegt-${EXT}.icns</string>"
+ echo -e '\t\t</dict>'
+done
+unset IFS
+echo -e '\t</array>\n</dict>\n</plist>'
+) > "$TMPFILE"
+
+rm -f "$1"
+cp "$TMPFILE" "$1"
+rm -f "$TMPFILE"
+
Property changes on: MacOSX/modify-plist.sh
___________________________________________________________________
Added: svn:executable
+ *
pgpVKQ9Nxy6LM.pgp
Description: PGP signature
------------------------------------------------------------------------------ Using storage to extend the benefits of virtualization and iSCSI Virtualization increases hardware utilization and delivers a new level of agility. Learn what those decisions are and how to modernize your storage and backup environments for virtualization. http://www.accelacomm.com/jaw/sfnl/114/51434361/
_______________________________________________ Qlandkartegt-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users
