Linux installer: Create a 128x128 calibre icon as apparently GNOME can't handle large icons

This commit is contained in:
Kovid Goyal 2010-07-25 17:53:05 -06:00
parent ca6691887e
commit d1a773f2ee

View File

@ -3,12 +3,14 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
''' Post installation script for linux ''' ''' Post installation script for linux '''
import sys, os, shutil, cPickle, textwrap, stat import sys, os, cPickle, textwrap, stat
from subprocess import check_call from subprocess import check_call
from calibre import __appname__, prints, guess_type from calibre import __appname__, prints, guess_type
from calibre.constants import islinux, isfreebsd from calibre.constants import islinux, isfreebsd
from calibre.customize.ui import all_input_formats from calibre.customize.ui import all_input_formats
from calibre.ptempfile import TemporaryDirectory
from calibre import CurrentDir
entry_points = { entry_points = {
@ -323,26 +325,26 @@ class PostInstall:
def setup_desktop_integration(self): def setup_desktop_integration(self):
try: try:
from PyQt4.QtCore import QFile from PyQt4.Qt import QFile, QImage, Qt
from tempfile import mkdtemp
self.info('Setting up desktop integration...') self.info('Setting up desktop integration...')
tdir = mkdtemp() with TemporaryDirectory() as tdir:
cwd = os.getcwdu() with CurrentDir(tdir):
try: render_svg(QFile(I('mimetypes/lrf.svg')), 'calibre-lrf.png')
os.chdir(tdir)
render_svg(QFile(I('mimetypes/lrf.svg')), os.path.join(tdir, 'calibre-lrf.png'))
check_call('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png application-lrf', shell=True) check_call('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png application-lrf', shell=True)
self.icon_resources.append(('mimetypes', 'application-lrf', '128')) self.icon_resources.append(('mimetypes', 'application-lrf', '128'))
check_call('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png text-lrs', shell=True) check_call('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png text-lrs', shell=True)
self.icon_resources.append(('mimetypes', 'application-lrs', self.icon_resources.append(('mimetypes', 'application-lrs',
'128')) '128'))
QFile(I('library.png')).copy(os.path.join(tdir, 'calibre-gui.png')) p = QImage(I('lt.png')).scaledToHeight(128,
Qt.SmoothTransformation)
p.save('calibre-gui.png')
QFile(I('l.png')).copy('calibre-gui.png')
check_call('xdg-icon-resource install --noupdate --size 128 calibre-gui.png calibre-gui', shell=True) check_call('xdg-icon-resource install --noupdate --size 128 calibre-gui.png calibre-gui', shell=True)
self.icon_resources.append(('apps', 'calibre-gui', '128')) self.icon_resources.append(('apps', 'calibre-gui', '128'))
render_svg(QFile(I('viewer.svg')), os.path.join(tdir, 'calibre-viewer.png')) render_svg(QFile(I('viewer.svg')), 'calibre-viewer.png')
check_call('xdg-icon-resource install --size 128 calibre-viewer.png calibre-viewer', shell=True) check_call('xdg-icon-resource install --size 128 calibre-viewer.png calibre-viewer', shell=True)
self.icon_resources.append(('apps', 'calibre-viewer', '128')) self.icon_resources.append(('apps', 'calibre-viewer', '128'))
@ -379,9 +381,6 @@ class PostInstall:
f.close() f.close()
self.mime_resources.append('calibre-mimetypes') self.mime_resources.append('calibre-mimetypes')
check_call('xdg-mime install ./calibre-mimetypes', shell=True) check_call('xdg-mime install ./calibre-mimetypes', shell=True)
finally:
os.chdir(cwd)
shutil.rmtree(tdir)
except Exception: except Exception:
if self.opts.fatal_errors: if self.opts.fatal_errors:
raise raise