[Pkg-mozext-commits] [adblock-plus] 422/464: Allow to specify the default icon for browserActions and pageActions in multiple sizes.
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 20:44:40 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 500223a43d5fc204c61dc3bad31bd73147dcbd61
Author: Sebastian Noack <sebastian at adblockplug.org>
Date: Fri Apr 4 13:11:45 2014 +0200
Allow to specify the default icon for browserActions and pageActions in multiple sizes.
https://issues.adblockplus.org/ticket/4
---
packagerChrome.py | 48 +++++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/packagerChrome.py b/packagerChrome.py
index ec98715..923a8ec 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -50,6 +50,16 @@ def processFile(path, data, params):
# that it can be overridden if necessary.
return data
+def makeIcons(files, filenames):
+ from PIL import Image
+ icons = {}
+ for filename in filenames:
+ width, height = Image.open(StringIO(files[filename])).size
+ if(width != height):
+ print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be square' % (filename, width, height)
+ icons[width] = filename
+ return icons
+
def createManifest(params, files):
template = getTemplate('manifest.json.tmpl')
templateData = dict(params)
@@ -57,29 +67,29 @@ def createManifest(params, files):
baseDir = templateData['baseDir']
metadata = templateData['metadata']
- if metadata.has_option('general', 'pageAction') and metadata.get('general', 'pageAction') != '':
- if re.search(r'\s+', metadata.get('general', 'pageAction')):
- icon, popup = re.split(r'\s+', metadata.get('general', 'pageAction'), 1)
- else:
- icon, popup = (metadata.get('general', 'pageAction'), None)
- templateData['pageAction'] = {'icon': icon, 'popup': popup}
+ for opt in ('browserAction', 'pageAction'):
+ if not metadata.has_option('general', opt):
+ continue
- if metadata.has_option('general', 'browserAction') and metadata.get('general', 'browserAction') != '':
- if re.search(r'\s+', metadata.get('general', 'browserAction')):
- icon, popup = re.split(r'\s+', metadata.get('general', 'browserAction'), 1)
+ icons = metadata.get('general', opt).split()
+ if not icons:
+ continue
+
+ if len(icons) == 1:
+ # ... = icon.png
+ icon, popup = icons[0], None
+ elif len(icons) == 2:
+ # ... = icon.png popup.html
+ icon, popup = icons
else:
- icon, popup = (metadata.get('general', 'browserAction'), None)
- templateData['browserAction'] = {'icon': icon, 'popup': popup}
+ # ... = icon-19.png icon-38.png popup.html
+ popup = icons.pop()
+ icon = makeIcons(files, icons)
+
+ templateData[opt] = {'icon': icon, 'popup': popup}
if metadata.has_option('general', 'icons'):
- from PIL import Image
- icons = {}
- for icon in re.split('\s+', metadata.get('general', 'icons')):
- width, height = Image.open(StringIO(files[icon])).size
- if(width != height):
- print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be square' % (icon, width, height)
- icons[width] = icon
- templateData['icons'] = icons
+ templateData['icons'] = makeIcons(files, metadata.get('general', 'icons').split())
if metadata.has_option('general', 'permissions'):
templateData['permissions'] = re.split(r'\s+', metadata.get('general', 'permissions'))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list