Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-07-15 10:31:06 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-07-15 10:31:06 (GMT)
commit21b46a002256f7004c45c7ac379a93ce75d7834f (patch)
tree35474ae2d15f152a9a09b9b3d142363a669579e0 /shell
parentdb08c3795f5e02245477126e8eb19e0049303332 (diff)
Bunch of fixes, sharing should be back to work
Diffstat (limited to 'shell')
-rw-r--r--shell/ActivitiesModel.py17
-rw-r--r--shell/ActivityRegistry.py7
-rw-r--r--shell/HomeWindow.py16
3 files changed, 30 insertions, 10 deletions
diff --git a/shell/ActivitiesModel.py b/shell/ActivitiesModel.py
index 6ed2eb4..9b1a955 100644
--- a/shell/ActivitiesModel.py
+++ b/shell/ActivitiesModel.py
@@ -1,3 +1,5 @@
+import xml.sax.saxutils
+
import gobject
from sugar.presence.PresenceService import PresenceService
@@ -7,11 +9,18 @@ class ActivityInfo:
self._service = service
def get_id(self):
- activity_id = service.get_one_property('activity_id')
+ activity_id = self._service.get_one_property('activity_id')
+
+ def get_type(self):
+ return self._service.get_type()
def get_title(self):
- escaped_title = service.get_one_property('Title')
+ escaped_title = self._service.get_one_property('Title')
title = xml.sax.saxutils.unescape(escaped_title)
+ return title
+
+ def get_service(self):
+ return self._service
class ActivitiesModel(gobject.GObject):
__gsignals__ = {
@@ -44,4 +53,6 @@ class ActivitiesModel(gobject.GObject):
self._pservice.track_service_type(short_stype)
def _on_activity_announced_cb(self, pservice, service, buddy):
- self.add_activity(buddy, service)
+ # FIXME We should not hard code activity types here
+ if service.get_type() == "_web_olpc._udp":
+ self.add_activity(service)
diff --git a/shell/ActivityRegistry.py b/shell/ActivityRegistry.py
index 6d296bb..70a502f 100644
--- a/shell/ActivityRegistry.py
+++ b/shell/ActivityRegistry.py
@@ -44,6 +44,13 @@ class ActivityRegistry:
def __init__(self):
self._activities = []
+ def get_activity(self, default_type):
+ """Returns an activity given his default type"""
+ for activity in self._activities:
+ if activity.get_default_type() == default_type:
+ return activity
+ return None
+
def scan_directory(self, path):
"""Scan a directory for activities and add them to the registry."""
if os.path.isdir(path):
diff --git a/shell/HomeWindow.py b/shell/HomeWindow.py
index a88e18f..8f2618a 100644
--- a/shell/HomeWindow.py
+++ b/shell/HomeWindow.py
@@ -39,9 +39,10 @@ class Toolbar(gtk.Toolbar):
new_activity_button.show()
class ActivitiesGrid(gtk.VBox):
- def __init__(self, model):
- gtk.VBox.__init__(self)
+ def __init__(self, shell, model):
+ gtk.VBox.__init__(self, shell)
+ self._shell = shell
self._buttons = {}
for activity in model:
@@ -60,15 +61,16 @@ class ActivitiesGrid(gtk.VBox):
self.remove(button)
def _add(self, activity):
- button = gtk.Button(window.get_title())
- button.connect('clicked', self.__button_clicked_cb, window)
+ button = gtk.Button(activity.get_title())
+ button.connect('clicked', self.__button_clicked_cb, activity)
self.pack_start(button, False)
button.show()
self._buttons[activity.get_id()] = button
- def __button_clicked_cb(self, button, window):
- self._home.activate(window)
+ def __button_clicked_cb(self, button, info):
+ activity = self._shell.get_registry().get_activity(info.get_type())
+ Activity.create(activity.get_id(), info.get_service())
class TasksGrid(gtk.VBox):
def __init__(self, home):
@@ -137,7 +139,7 @@ class HomeWindow(gtk.Window):
label.show()
model = ActivitiesModel()
- grid = ActivitiesGrid(model)
+ grid = ActivitiesGrid(shell, model)
vbox.pack_start(grid)
grid.show()