[Sugar-devel] [PATCH] Update window title when the activity title changes - OLPC #10978

godiard at sugarlabs.org godiard at sugarlabs.org
Wed Jul 6 09:24:02 EDT 2011


From: Gonzalo Odiard <godiard at gmail.com>

The patch updates the window title when the user changes
the title in the toolbar or in the Journal.

Signed-of-by: Gonzalo Odiard <gonzalo at laptop.org>
---
 src/sugar/activity/activity.py |   10 +++++++++-
 src/sugar/activity/widgets.py  |    2 ++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py
index 31827da..35ad485 100644
--- a/src/sugar/activity/activity.py
+++ b/src/sugar/activity/activity.py
@@ -307,7 +307,8 @@ class Activity(Window, gtk.Container):
         if handle.object_id:
             self._jobject = datastore.get(handle.object_id)
             self.set_title(self._jobject.metadata['title'])
-
+            self._jobject.metadata.connect('updated',
+                                           self.__jobject_updated_cb)
             if 'share-scope' in self._jobject.metadata:
                 share_scope = self._jobject.metadata['share-scope']
 
@@ -333,6 +334,8 @@ class Activity(Window, gtk.Container):
             logging.debug('Creating a jobject.')
             self._jobject = self._initialize_journal_object()
             self.set_title(self._jobject.metadata['title'])
+            self._jobject.metadata.connect('updated',
+                                           self.__jobject_updated_cb)
 
     def _initialize_journal_object(self):
         title = _('%s Activity') % get_bundle_name()
@@ -363,6 +366,11 @@ class Activity(Window, gtk.Container):
 
         return jobject
 
+    def __jobject_updated_cb(self, jobject):
+        if self.get_title() == jobject['title']:
+            return
+        self.set_title(jobject['title'])
+
     def _set_up_sharing(self, mesh_instance, share_scope):
         # handle activity share/join
         logging.debug('*** Act %s, mesh instance %r, scope %s',
diff --git a/src/sugar/activity/widgets.py b/src/sugar/activity/widgets.py
index 7166d3e..2cc863b 100644
--- a/src/sugar/activity/widgets.py
+++ b/src/sugar/activity/widgets.py
@@ -217,6 +217,8 @@ class TitleEntry(gtk.ToolItem):
         activity.metadata['title_set_by_user'] = '1'
         activity.save()
 
+        activity.set_title(title)
+
         shared_activity = activity.get_shared_activity()
         if shared_activity is not None:
             shared_activity.props.name = title
-- 
1.7.4.4



More information about the Sugar-devel mailing list