Add management of summary property to the activity.info file

This summary is translatable as the Activity name and will be displayed
in the Activity list in the Home View.

Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
This commit is contained in:
Gonzalo Odiard 2012-09-20 12:34:02 -03:00 committed by Simon Schampijer
parent 7eec45f031
commit 3a30d3f84e
2 changed files with 24 additions and 0 deletions

View File

@ -77,6 +77,7 @@ class Config(object):
self.tar_root_dir = None
self.xo_name = None
self.tar_name = None
self.summary = None
self.update()
@ -85,6 +86,7 @@ class Config(object):
self.version = bundle.get_activity_version()
self.activity_name = bundle.get_bundle_name()
self.bundle_id = bundle.get_bundle_id()
self.summary = bundle.get_summary()
self.bundle_name = reduce(operator.add, self.activity_name.split())
self.bundle_root_dir = self.bundle_name + '.activity'
self.tar_root_dir = '%s-%s' % (self.bundle_name, self.version)
@ -136,9 +138,11 @@ class Builder(object):
cat = gettext.GNUTranslations(open(mo_file, 'r'))
translated_name = cat.gettext(self.config.activity_name)
translated_summary = cat.gettext(self.config.summary)
linfo_file = os.path.join(localedir, 'activity.linfo')
f = open(linfo_file, 'w')
f.write('[Activity]\nname = %s\n' % translated_name)
f.write('summary = %s\n' % translated_summary)
f.close()
def get_files(self):
@ -356,6 +360,11 @@ def cmd_genpot(config, args):
f.write('#: activity/activity.info:2\n')
f.write('msgid "%s"\n' % escaped_name)
f.write('msgstr ""\n')
if config.summary is not None:
escaped_summary = re.sub('([\\\\"])', '\\\\\\1', config.summary)
f.write('#: activity/activity.info:3\n')
f.write('msgid "%s"\n' % escaped_summary)
f.write('msgstr ""\n')
f.close()
args = ['xgettext', '--join-existing', '--language=Python',

View File

@ -62,6 +62,8 @@ class ActivityBundle(Bundle):
self._tags = None
self._activity_version = '0'
self._installation_time = os.stat(path).st_mtime
self._summary = None
self._local_summary = None
info_file = self.get_file('activity/activity.info')
if info_file is None:
@ -75,6 +77,9 @@ class ActivityBundle(Bundle):
if self._local_name == None:
self._local_name = self._name
if self._local_summary == None:
self._local_summary = self._summary
def _parse_info(self, info_file):
cp = ConfigParser()
cp.readfp(info_file)
@ -126,6 +131,9 @@ class ActivityBundle(Bundle):
(self._path, version))
self._activity_version = version
if cp.has_option(section, 'summary'):
self._summary = cp.get(section, 'summary')
def _get_linfo_file(self):
lang = locale.getdefaultlocale()[0]
if not lang:
@ -152,6 +160,9 @@ class ActivityBundle(Bundle):
if cp.has_option(section, 'name'):
self._local_name = cp.get(section, 'name')
if cp.has_option(section, 'summary'):
self._local_summary = cp.get(section, 'summary')
if cp.has_option(section, 'tags'):
tag_list = cp.get(section, 'tags').strip(';')
self._tags = [tag.strip() for tag in tag_list.split(';')]
@ -225,6 +236,10 @@ class ActivityBundle(Bundle):
"""Get the tags that describe the activity"""
return self._tags
def get_summary(self):
"""Get the summary that describe the activity"""
return self._local_summary
def get_show_launcher(self):
"""Get whether there should be a visible launcher for the activity"""
return self._show_launcher