mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Linux installer: Create a 128x128 calibre icon as apparently GNOME can't handle large icons
This commit is contained in:
parent
ca6691887e
commit
d1a773f2ee
@ -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,65 +325,62 @@ 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)
|
check_call('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png application-lrf', shell=True)
|
||||||
render_svg(QFile(I('mimetypes/lrf.svg')), os.path.join(tdir, 'calibre-lrf.png'))
|
self.icon_resources.append(('mimetypes', 'application-lrf', '128'))
|
||||||
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 text-lrs', shell=True)
|
||||||
self.icon_resources.append(('mimetypes', 'application-lrf', '128'))
|
self.icon_resources.append(('mimetypes', 'application-lrs',
|
||||||
check_call('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png text-lrs', shell=True)
|
'128'))
|
||||||
self.icon_resources.append(('mimetypes', 'application-lrs',
|
p = QImage(I('lt.png')).scaledToHeight(128,
|
||||||
'128'))
|
Qt.SmoothTransformation)
|
||||||
QFile(I('library.png')).copy(os.path.join(tdir, 'calibre-gui.png'))
|
p.save('calibre-gui.png')
|
||||||
check_call('xdg-icon-resource install --noupdate --size 128 calibre-gui.png calibre-gui', shell=True)
|
QFile(I('l.png')).copy('calibre-gui.png')
|
||||||
self.icon_resources.append(('apps', 'calibre-gui', '128'))
|
check_call('xdg-icon-resource install --noupdate --size 128 calibre-gui.png calibre-gui', shell=True)
|
||||||
render_svg(QFile(I('viewer.svg')), os.path.join(tdir, 'calibre-viewer.png'))
|
self.icon_resources.append(('apps', 'calibre-gui', '128'))
|
||||||
check_call('xdg-icon-resource install --size 128 calibre-viewer.png calibre-viewer', shell=True)
|
render_svg(QFile(I('viewer.svg')), 'calibre-viewer.png')
|
||||||
self.icon_resources.append(('apps', 'calibre-viewer', '128'))
|
check_call('xdg-icon-resource install --size 128 calibre-viewer.png calibre-viewer', shell=True)
|
||||||
|
self.icon_resources.append(('apps', 'calibre-viewer', '128'))
|
||||||
|
|
||||||
mimetypes = set([])
|
mimetypes = set([])
|
||||||
for x in all_input_formats():
|
for x in all_input_formats():
|
||||||
mt = guess_type('dummy.'+x)[0]
|
mt = guess_type('dummy.'+x)[0]
|
||||||
if mt and 'chemical' not in mt:
|
if mt and 'chemical' not in mt:
|
||||||
mimetypes.add(mt)
|
mimetypes.add(mt)
|
||||||
|
|
||||||
def write_mimetypes(f):
|
def write_mimetypes(f):
|
||||||
f.write('MimeType=%s;\n'%';'.join(mimetypes))
|
f.write('MimeType=%s;\n'%';'.join(mimetypes))
|
||||||
|
|
||||||
f = open('calibre-lrfviewer.desktop', 'wb')
|
f = open('calibre-lrfviewer.desktop', 'wb')
|
||||||
f.write(VIEWER)
|
f.write(VIEWER)
|
||||||
f.close()
|
f.close()
|
||||||
f = open('calibre-ebook-viewer.desktop', 'wb')
|
f = open('calibre-ebook-viewer.desktop', 'wb')
|
||||||
f.write(EVIEWER)
|
f.write(EVIEWER)
|
||||||
write_mimetypes(f)
|
write_mimetypes(f)
|
||||||
f.close()
|
f.close()
|
||||||
f = open('calibre-gui.desktop', 'wb')
|
f = open('calibre-gui.desktop', 'wb')
|
||||||
f.write(GUI)
|
f.write(GUI)
|
||||||
write_mimetypes(f)
|
write_mimetypes(f)
|
||||||
f.close()
|
f.close()
|
||||||
des = ('calibre-gui.desktop', 'calibre-lrfviewer.desktop',
|
des = ('calibre-gui.desktop', 'calibre-lrfviewer.desktop',
|
||||||
'calibre-ebook-viewer.desktop')
|
'calibre-ebook-viewer.desktop')
|
||||||
for x in des:
|
for x in des:
|
||||||
cmd = ['xdg-desktop-menu', 'install', './'+x]
|
cmd = ['xdg-desktop-menu', 'install', './'+x]
|
||||||
if x != des[-1]:
|
if x != des[-1]:
|
||||||
cmd.insert(2, '--noupdate')
|
cmd.insert(2, '--noupdate')
|
||||||
check_call(' '.join(cmd), shell=True)
|
check_call(' '.join(cmd), shell=True)
|
||||||
self.menu_resources.append(x)
|
self.menu_resources.append(x)
|
||||||
f = open('calibre-mimetypes', 'wb')
|
f = open('calibre-mimetypes', 'wb')
|
||||||
f.write(MIME)
|
f.write(MIME)
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user