From d758d881919c6e6be84fdfb7751d0e5c51ab54bb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 30 Aug 2014 10:49:00 +0530 Subject: [PATCH] Decrease size of icns files in the OS X app bundle By running the PNG images through a PNG optimizer. Also specify a thumbnail image to use for files associated with calibre. Fixes #295 (Icon association for book files on Mac) --- icons/icns/make_iconsets.py | 5 ++++- setup/installer/osx/app/main.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/icons/icns/make_iconsets.py b/icons/icns/make_iconsets.py index ec353c93b3..2a88daf2f6 100644 --- a/icons/icns/make_iconsets.py +++ b/icons/icns/make_iconsets.py @@ -13,7 +13,7 @@ base = d(a(__file__)) os.chdir(base) imgsrc = j(d(d(base)), 'imgsrc') -sources = {'calibre':j(d(base), 'calibre.png'), 'ebook-edit':j(imgsrc, 'tweak.svg'), 'ebook-viewer':j(imgsrc, 'viewer.svg')} +sources = {'calibre':j(d(base), 'calibre.png'), 'ebook-edit':j(imgsrc, 'tweak.svg'), 'ebook-viewer':j(imgsrc, 'viewer.svg'), 'book':j(imgsrc, 'book.svg')} for name, src in sources.iteritems(): iconset = name + '.iconset' @@ -37,6 +37,9 @@ for name, src in sources.iteritems(): shutil.copy2(iname, iname2x) if sz > 512: os.remove(iname) + for name in (iname, iname2x): + if os.path.exists(name): + subprocess.check_call(['optipng', '-o7', name]) finally: os.chdir('..') diff --git a/setup/installer/osx/app/main.py b/setup/installer/osx/app/main.py index 7e5cc056ed..10d955d768 100644 --- a/setup/installer/osx/app/main.py +++ b/setup/installer/osx/app/main.py @@ -321,8 +321,6 @@ class Py2App(object): c = join(self.build_dir, 'Contents') for x in ('Frameworks', 'MacOS', 'Resources'): os.makedirs(join(c, x)) - for x in ('book.icns',): - shutil.copyfile(join('icons', x), join(self.resources_dir, x)) for x in glob.glob(join('icons', 'icns', '*.iconset')): subprocess.check_call([ 'iconutil', '-c', 'icns', x, '-o', join( @@ -343,6 +341,7 @@ class Py2App(object): env['CALIBRE_LAUNCHED_FROM_BUNDLE']='1' docs = [{'CFBundleTypeName':'E-book', 'CFBundleTypeExtensions':list(BOOK_EXTENSIONS), + 'CFBundleTypeIconFile':'book.icns', 'CFBundleTypeRole':'Viewer', }]