<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>support/osx/makeicns</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -52,6 +52,11 @@ Iain Sheppard
 cpIRC - C++ class based IRC protocol wrapper
 LGPL [8]
 
+Nicolas Weber
+makeicns - converts images to Apple's icns format
+Belongs to docerator, http://code.google.com/p/docerator/
+MIT [9]
+
 ==============================================================================
 [1] WebKit, KJS and related
 
@@ -275,6 +280,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 
 ==============================================================================
+[9] makeicns - Converts images to Apple's icns format.
+
+Written by nicolasweber@gmx.de, released under MIT license.
+Belongs to docerator, http://code.google.com/p/docerator/
+
+
+==============================================================================
 ==============================================================================
 Appcelerator is a registered trademark of Appcelerator, Inc. Appcelerator,
 Appcelerator Titanium and the Appcelerator and Titanium logos and marks </diff>
      <filename>CREDITS</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>installation/net_installer/osx/titanium.icns</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-Subproject commit 73f2a9c88984102f9cb11a22ed457d7ba3a50263
+Subproject commit a0fc6a3a8bf80666759468ed458288df4bfeec5c</diff>
      <filename>kroll</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@
 # Original author: Jeff Haynie 04/02/09
 #
 #
-import os, shutil, distutils.dir_util as dir_util
+import os, shutil, distutils.dir_util as dir_util, sys
 
 class DesktopBuilder(object):
 	def __init__(self, options, log):
@@ -17,127 +17,131 @@ class DesktopBuilder(object):
 		self.logger = log
 		self.appname = options.manifest['appname']
 		log(options,&quot;Packaging application named: %s, version: %s&quot;%(self.appname,options.version))
-		options.mobile = (options.platform == 'iphone' or options.platform == 'android')
-		if not options.mobile:
-			if options.platform == 'osx':
-				self.base_dir = os.path.join(options.destination,('%s.app'%self.appname))
-				if not os.path.exists(self.base_dir):
-					os.makedirs(self.base_dir)
-				self.contents_dir = os.path.join(self.base_dir,'Contents')
-				if os.path.exists(self.contents_dir):
-					dir_util.remove_tree(self.contents_dir)
-				os.makedirs(self.contents_dir)
-				self.executable_dir = os.path.join(self.contents_dir,'MacOS')
-				os.makedirs(self.executable_dir)
-				self.resources_dir = os.path.join(self.contents_dir,'Resources')
-				os.makedirs(self.resources_dir)
-				self.lproj = os.path.join(self.resources_dir, 'English.lproj')
-				os.makedirs(self.lproj)
-			else:
-				self.base_dir = os.path.join(options.destination,self.appname)
-				self.contents_dir = os.path.join(options.destination,self.appname)
-				self.executable_dir = os.path.join(options.destination,self.appname)
-				if os.path.exists(self.contents_dir):
-					dir_util.remove_tree(self.contents_dir)
+		if options.platform == 'osx':
+			self.base_dir = os.path.join(options.destination,('%s.app'%self.appname))
+			if not os.path.exists(self.base_dir):
 				os.makedirs(self.base_dir)
-				self.resources_dir = os.path.join(self.contents_dir,'Resources')
-				os.makedirs(self.resources_dir)
+			self.contents_dir = os.path.join(self.base_dir,'Contents')
+			if os.path.exists(self.contents_dir):
+				dir_util.remove_tree(self.contents_dir)
+			os.makedirs(self.contents_dir)
+			self.executable_dir = os.path.join(self.contents_dir,'MacOS')
+			os.makedirs(self.executable_dir)
+			self.resources_dir = os.path.join(self.contents_dir,'Resources')
+			os.makedirs(self.resources_dir)
+			self.lproj = os.path.join(self.resources_dir, 'English.lproj')
+			os.makedirs(self.lproj)
+		else:
+			self.base_dir = os.path.join(options.destination,self.appname)
+			self.contents_dir = os.path.join(options.destination,self.appname)
+			self.executable_dir = os.path.join(options.destination,self.appname)
+			if os.path.exists(self.contents_dir):
+				dir_util.remove_tree(self.contents_dir)
+			os.makedirs(self.base_dir)
+			self.resources_dir = os.path.join(self.contents_dir,'Resources')
+			os.makedirs(self.resources_dir)
 
-			# copy the tiapp
-			tiapp = os.path.join(options.appdir,'tiapp.xml')
-			shutil.copy(tiapp, self.contents_dir)
-			
-			# copy the manifest
-			manifest = os.path.join(options.appdir,'manifest')
-			shutil.copy(manifest, self.contents_dir)
+		# copy the tiapp
+		tiapp = os.path.join(options.appdir,'tiapp.xml')
+		shutil.copy(tiapp, self.contents_dir)
+		
+		# copy the manifest
+		manifest = os.path.join(options.appdir,'manifest')
+		shutil.copy(manifest, self.contents_dir)
 
-			# copy the boot
-			if options.platform == 'win32':
-				kboot = os.path.join(options.runtime_dir, 'template', 'kboot.exe')
-				options.executable = os.path.join(self.executable_dir, 'installer.exe')
-				shutil.copy(kboot, options.executable)
-			else:
-				kboot = os.path.join(options.runtime_dir, 'template', 'kboot')
-				options.executable = os.path.join(self.executable_dir, self.appname)
-				shutil.copy(kboot, options.executable)
+		# copy the boot
+		if options.platform == 'win32':
+			kboot = os.path.join(options.runtime_dir, 'template', 'kboot.exe')
+			options.executable = os.path.join(self.executable_dir, 'installer.exe')
+			shutil.copy(kboot, options.executable)
+		else:
+			kboot = os.path.join(options.runtime_dir, 'template', 'kboot')
+			options.executable = os.path.join(self.executable_dir, self.appname)
+			shutil.copy(kboot, options.executable)
 
-			if options.platform == 'osx':
-				shutil.copy(os.path.join(options.assets_dir, 'titanium.icns'), self.lproj)
-				shutil.copy(os.path.join(options.runtime_dir, 'template','MainMenu.nib'), self.lproj)
+		# copy in the resources
+		rdir = os.path.join(options.appdir,'Resources')
+		dir_util.copy_tree(rdir, self.resources_dir, preserve_symlinks=True)
 
-			# copy in the resources
-			rdir = os.path.join(options.appdir,'Resources')
-			dir_util.copy_tree(rdir, self.resources_dir, preserve_symlinks=True)
+		if options.platform == 'osx':
+			shutil.copy(os.path.join(options.assets_dir, 'titanium.icns'), self.lproj)
+			shutil.copy(os.path.join(options.runtime_dir, 'template','MainMenu.nib'), self.lproj)
+			self.app_icns = os.path.join(self.lproj,'titanium.icns')
+			self.make_osx_icon(os.path.join(self.resources_dir,options.icon),self.app_icns)
 
-			# copy the installer
-			if options.platform == 'osx':
-				installer = os.path.join(self.contents_dir,'installer','Installer App.app')
-				if not os.path.exists(installer):
-					os.makedirs(installer)
-				netinstaller = os.path.join(options.runtime_dir, 'installer','Installer App.app')
-				dir_util.copy_tree(netinstaller,installer,preserve_symlinks=True)
-			elif options.platform == 'win32':
-				installer = os.path.join(self.contents_dir,'installer')
-				if not os.path.exists(installer):
-					os.makedirs(installer)
-				netinstaller = os.path.join(options.runtime_dir, 'installer', 'Installer.exe')
-				shutil.copy(netinstaller, installer)
-			elif options.platform == 'linux':
-				installer = os.path.join(self.contents_dir,'installer')
-				if not os.path.exists(installer):
-					os.makedirs(installer)
-				netinstaller = os.path.join(options.runtime_dir, 'installer', 'installer')
-				shutil.copy(netinstaller, installer)
+		# copy the installer
+		if options.platform == 'osx':
+			installer = os.path.join(self.contents_dir,'installer','Installer App.app')
+			if not os.path.exists(installer):
+				os.makedirs(installer)
+			netinstaller = os.path.join(options.runtime_dir, 'installer','Installer App.app')
+			dir_util.copy_tree(netinstaller,installer,preserve_symlinks=True)
+			# copy in the custom app icon into the net installer
+			shutil.copy(self.app_icns,os.path.join(installer,'Contents','Resources','English.lproj'))
+		elif options.platform == 'win32':
+			installer = os.path.join(self.contents_dir,'installer')
+			if not os.path.exists(installer):
+				os.makedirs(installer)
+			netinstaller = os.path.join(options.runtime_dir, 'installer', 'Installer.exe')
+			shutil.copy(netinstaller, installer)
+		elif options.platform == 'linux':
+			installer = os.path.join(self.contents_dir,'installer')
+			if not os.path.exists(installer):
+				os.makedirs(installer)
+			netinstaller = os.path.join(options.runtime_dir, 'installer', 'installer')
+			shutil.copy(netinstaller, installer)
 
-			# if selected, write in the .installed file
-			if options.no_install:
-				f = open(os.path.join(self.contents_dir,'.installed'),'w')	
-				f.write(&quot;&quot;)
+		# if selected, write in the .installed file
+		if options.no_install:
+			f = open(os.path.join(self.contents_dir,'.installed'),'w')	
+			f.write(&quot;&quot;)
+			f.close()
+		else:
+			# copy the license
+			if options.license_file:
+				f = open(os.path.join(self.contents_dir,'LICENSE.txt'),'w')	
+				f.write(open(options.license_file).read())
 				f.close()
-			else:
-				# copy the license
-				if options.license_file:
-					f = open(os.path.join(self.contents_dir,'LICENSE.txt'),'w')	
-					f.write(open(options.license_file).read())
-					f.close()
-
-			# copy in modules (this will be empty if network and no local ones)
-			for p in options.module_paths:
-				log(options,&quot;adding module: %s/%s&quot;%(p['name'],p['version']))
-				d = os.path.join(self.contents_dir,'modules',p['name'])
-				if os.path.exists(d):
-					dir_util.remove_tree(d)
-				os.makedirs(d)
-				dir_util.copy_tree(p['path'], d, preserve_symlinks=True)
-			
-			# copy in the runtime if not network install
-			if options.type != 'network':
-				log(options,&quot;adding runtime: %s&quot;%options.runtime)
-				rd = os.path.join(self.contents_dir,'runtime')
-				if os.path.exists(rd):
-					dir_util.remove_tree(rd)
-				os.makedirs(rd)
-				dir_util.copy_tree(options.runtime_dir, rd, preserve_symlinks=True)
-
-			if options.platform == 'osx':
-				plist = open(os.path.join(options.assets_dir, 'Info.plist')).read()
-				plist = plist.replace('APPNAME', self.appname)
-				plist = plist.replace('APPEXE', self.appname)
-				plist = plist.replace('APPICON', 'titanium.icns')
-				plist = plist.replace('APPID', options.manifest['appid'])
-				plist = plist.replace('APPNIB', 'MainMenu')
-				plist = plist.replace('APPVER', str(options.version))
-				out_file = open(os.path.join(self.contents_dir, 'Info.plist'), 'w')
-				out_file.write(plist)
-				out_file.close()
 
+		# copy in modules (this will be empty if network and no local ones)
+		for p in options.module_paths:
+			log(options,&quot;adding module: %s/%s&quot;%(p['name'],p['version']))
+			d = os.path.join(self.contents_dir,'modules',p['name'])
+			if os.path.exists(d):
+				dir_util.remove_tree(d)
+			os.makedirs(d)
+			dir_util.copy_tree(p['path'], d, preserve_symlinks=True)
+		
+		# copy in the runtime if not network install
+		if options.type != 'network':
+			log(options,&quot;adding runtime: %s&quot;%options.runtime)
+			rd = os.path.join(self.contents_dir,'runtime')
+			if os.path.exists(rd):
+				dir_util.remove_tree(rd)
+			os.makedirs(rd)
+			dir_util.copy_tree(options.runtime_dir, rd, preserve_symlinks=True)
 
-		else:
-			pass
+		if options.platform == 'osx':
+			plist = open(os.path.join(options.assets_dir, 'Info.plist')).read()
+			plist = plist.replace('APPNAME', self.appname)
+			plist = plist.replace('APPEXE', self.appname)
+			plist = plist.replace('APPICON', 'titanium.icns')
+			plist = plist.replace('APPID', options.manifest['appid'])
+			plist = plist.replace('APPNIB', 'MainMenu')
+			plist = plist.replace('APPVER', str(options.version))
+			out_file = open(os.path.join(self.contents_dir, 'Info.plist'), 'w')
+			out_file.write(plist)
+			out_file.close()
 	
 	def log(self,msg):
 		self.logger(self.options,msg)
 
+	def make_osx_icon(self,icon,dest):
+		makeicns = os.path.join(self.options.assets_dir,'makeicns')
+		if os.path.exists(makeicns):
+			self.log('&quot;%s&quot; -in &quot;%s&quot; -out &quot;%s&quot;' % (makeicns,icon,dest))
+			os.system('&quot;%s&quot; -in &quot;%s&quot; -out &quot;%s&quot;' % (makeicns,icon,dest))
+
 	def invoke(self,cmd):
 		if self.options.verbose:
 			self.log(&quot;Executing: %s&quot; % cmd)</diff>
      <filename>support/desktop_builder.py</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>support/osx/titanium.icns</filename>
    </modified>
    <modified>
      <diff>@@ -23,15 +23,22 @@ def log(options,msg):
 	if options.verbose:
 		print msg
 
-def get_version_from_tiapp(appdir):
+def get_from_tiapp(appdir,name,defv):
 	f = os.path.join(appdir,'tiapp.xml')
 	if not os.path.exists(f):
 		print &quot;Couldn't find tiapp.xml at: %s&quot; % appdir
 		sys.exit(1)
 	xml = open(f).read()
-	m = re.search('&lt;version&gt;(.*?)&lt;/version&gt;',xml)
+	m = re.search('&lt;%s&gt;(.*?)&lt;/%s&gt;' % (name,name),xml)
+	if m==None: return defv
 	return str(m.group(1)).strip()
+
+def get_icon_from_tiapp(appdir):
+	return get_from_tiapp(appdir,'icon','default_app_logo.png')
 	
+def get_version_from_tiapp(appdir):
+	return get_from_tiapp(appdir,'version','1.0')
+			
 def examine_manifest(appdir):
 	f = os.path.join(appdir,'manifest')
 	if not os.path.exists(f):
@@ -118,6 +125,9 @@ def desktop_setup(options,appdir):
 	# assign appdir
 	options.appdir = appdir
 	
+	# assign icon
+	options.icon = get_icon_from_tiapp(appdir)
+	
 	# convert this option
 	if options.package == 'false' or options.package == 'no':
 		options.package = False</diff>
      <filename>support/tibuild.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>dbb9150822a4f5be4ce0706d74ac78d98ba6b3b3</id>
    </parent>
  </parents>
  <author>
    <name>Jeff Haynie</name>
    <email>jhaynie@gmail.com</email>
  </author>
  <url>http://github.com/marshall/titanium/commit/3c71ab8c1b731a5deebfb4c849bfd142355b274e</url>
  <id>3c71ab8c1b731a5deebfb4c849bfd142355b274e</id>
  <committed-date>2009-06-03T21:13:35-07:00</committed-date>
  <authored-date>2009-06-03T21:13:35-07:00</authored-date>
  <message>implement custom app icon logic for osx</message>
  <tree>6de5071c83b5401741ef0b03cf2f387ab7e7c949</tree>
  <committer>
    <name>Jeff Haynie</name>
    <email>jhaynie@gmail.com</email>
  </committer>
</commit>
