Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2006-06-18 05:50:01 (GMT)
committer Dan Williams <dcbw@redhat.com>2006-06-18 05:50:01 (GMT)
commitbc43e25e107f8737342db295d165ba30b0b2c46d (patch)
treeb7e8ee104d48b570800c9c84a41a4c0a336df478 /sugar
parentbf55ae8644fd0c0f47f24a46a72c1e242d17da14 (diff)
Filter out duplicate shared activities from the Start Page list
Diffstat (limited to 'sugar')
-rw-r--r--sugar/shell/StartPage.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/sugar/shell/StartPage.py b/sugar/shell/StartPage.py
index 3aa2e7e..27a3277 100644
--- a/sugar/shell/StartPage.py
+++ b/sugar/shell/StartPage.py
@@ -18,6 +18,11 @@ _COLUMN_ADDRESS = 1
_COLUMN_SUBTITLE = 2
_COLUMN_SERVICE = 3
+class SearchHelper(object):
+ def __init__(self, activity_uid):
+ self.search_uid = activity_uid
+ self.found = False
+
class ActivitiesModel(gtk.ListStore):
def __init__(self):
gtk.ListStore.__init__(self, gobject.TYPE_STRING, gobject.TYPE_STRING,
@@ -25,9 +30,31 @@ class ActivitiesModel(gtk.ListStore):
def add_web_page(self, title, address):
self.append([ title, address, None, None ])
+
+ def _filter_dupe_activities(self, model, path, it, user_data):
+ """Search the list of list rows for an existing service that
+ has the activity ID we're looking for."""
+ helper = user_data
+ (service, ) = model.get(it, _COLUMN_SERVICE)
+ if not service:
+ return False
+ if service.get_activity_uid() == helper.search_uid:
+ helper.found = True
+ return True
+ return False
def add_activity(self, buddy, service):
# Web Activity check
+ activity_uid = service.get_activity_uid()
+ if activity_uid is None:
+ return
+ # Don't show dupes
+ helper = SearchHelper(activity_uid)
+ self.foreach(self._filter_dupe_activities, helper)
+ if helper.found == True:
+ return
+
+ # Only accept browser activities for now
if service.get_type() == BrowserActivity._BROWSER_ACTIVITY_TYPE:
escaped_title = service.get_one_property('Title')
escaped_uri = service.get_one_property('URI')