[Sugar-devel] [sugar-toolkit-gtk2] Add management of summary property to the activity.info file - v2

godiard at sugarlabs.org godiard at sugarlabs.org
Thu Sep 20 11:34:02 EDT 2012


From: Gonzalo Odiard <godiard at gmail.com>

This summary is translatable aas the name and will be displayed
in the activivity list in the home view.

Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>

v2: remove installation_time because is not used anymore
---
 src/sugar3/activity/bundlebuilder.py |  9 +++++++++
 src/sugar3/bundle/activitybundle.py  | 21 +++++++++++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/sugar3/activity/bundlebuilder.py b/src/sugar3/activity/bundlebuilder.py
index 0e4af59..1450ec2 100644
--- a/src/sugar3/activity/bundlebuilder.py
+++ b/src/sugar3/activity/bundlebuilder.py
@@ -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',
diff --git a/src/sugar3/bundle/activitybundle.py b/src/sugar3/bundle/activitybundle.py
index 2313f41..f686715 100644
--- a/src/sugar3/bundle/activitybundle.py
+++ b/src/sugar3/bundle/activitybundle.py
@@ -61,7 +61,8 @@ class ActivityBundle(Bundle):
         self._show_launcher = True
         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 +76,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 +130,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 +159,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(';')]
@@ -180,11 +190,6 @@ class ActivityBundle(Bundle):
         """Get the activity bundle name."""
         return self._name
 
-    def get_installation_time(self):
-        """Get a timestamp representing the time at which this activity was
-        installed."""
-        return self._installation_time
-
     def get_bundle_id(self):
         """Get the activity bundle id"""
         return self._bundle_id
@@ -225,6 +230,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
-- 
1.7.11.4



More information about the Sugar-devel mailing list