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-08-09 10:57:42 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-08-09 10:57:42 (GMT)
commit7e85c5160ec0a04cb7434cd53368a7c5ba8ce0fa (patch)
tree13a0147daa22113625ce33818b1d938d893970da /shell
parente4c4e866a5c99d81f7fa0a0972311a604c6f1af2 (diff)
Setup the activity from the shell process, through dbus,
this simplifies things a lot...
Diffstat (limited to 'shell')
-rw-r--r--shell/ActivityHost.py5
-rw-r--r--shell/ActivityRegistry.py7
-rw-r--r--shell/HomeWindow.py13
-rwxr-xr-xshell/Shell.py28
4 files changed, 38 insertions, 15 deletions
diff --git a/shell/ActivityHost.py b/shell/ActivityHost.py
index 540d1e2..f2287c4 100644
--- a/shell/ActivityHost.py
+++ b/shell/ActivityHost.py
@@ -10,11 +10,10 @@ class ActivityHost:
self._xid = xid
bus = dbus.SessionBus()
- service = Activity.ACTIVITY_SERVICE_NAME + "%s" % xid
path = Activity.ACTIVITY_SERVICE_PATH + "/%s" % xid
- proxy_obj = bus.get_object(service, path)
+ proxy_obj = bus.get_object(Activity.ACTIVITY_SERVICE_NAME, path)
- self._activity = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Activity')
+ self._activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
self._id = self._activity.get_id()
self._default_type = self._activity.get_default_type()
self._window = gtk.gdk.window_foreign_new(xid)
diff --git a/shell/ActivityRegistry.py b/shell/ActivityRegistry.py
index 3ac8a4f..acf379c 100644
--- a/shell/ActivityRegistry.py
+++ b/shell/ActivityRegistry.py
@@ -45,6 +45,13 @@ class ActivityRegistry:
def __init__(self):
self._activities = []
+
+ def get_activity_from_id(self, activity_id):
+ """Returns an activity given his identifier"""
+ for activity in self._activities:
+ if activity.get_id() == activity_id:
+ return activity
+ return None
def get_activity(self, default_type):
"""Returns an activity given his default type"""
diff --git a/shell/HomeWindow.py b/shell/HomeWindow.py
index ef44f61..886068c 100644
--- a/shell/HomeWindow.py
+++ b/shell/HomeWindow.py
@@ -72,16 +72,7 @@ class ActivitiesGrid(gtk.VBox):
self._buttons[activity.get_id()] = button
def __button_clicked_cb(self, button, info):
- activity = self._shell.get_registry().get_activity(info.get_type())
-
- activity_id = info.get_service().get_activity_id()
- pservice = PresenceService()
- activity_ps = pservice.get_activity(activity_id)
-
- if activity_ps:
- ActivityFactory.create(activity.get_id(), activity_ps)
- else:
- print 'Cannot start activity.'
+ self._shell.join_activity(info.get_service())
class TasksGrid(gtk.VBox):
def __init__(self, home):
@@ -168,7 +159,7 @@ class HomeWindow(gtk.Window):
return self._shell.get_registry().list_activities()
def create(self, activity_name):
- ActivityFactory.create(activity_name)
+ self._shell.start_activity(activity_name)
def activate(self, activity_window):
activity_window.activate(gtk.get_current_event_time())
diff --git a/shell/Shell.py b/shell/Shell.py
index 2860ed0..f08d724 100755
--- a/shell/Shell.py
+++ b/shell/Shell.py
@@ -1,4 +1,5 @@
import os
+import logging
import dbus
import dbus.glib
@@ -12,9 +13,10 @@ from HomeWindow import HomeWindow
from sugar import env
from ConsoleWindow import ConsoleWindow
from Owner import ShellOwner
-from PresenceService import PresenceService
+from sugar.presence.PresenceService import PresenceService
from ActivityHost import ActivityHost
from ChatListener import ChatListener
+from sugar.activity import ActivityFactory
class ShellDbusService(dbus.service.Object):
def __init__(self, shell, bus_name):
@@ -106,6 +108,30 @@ class Shell:
module = self._registry.get_activity(activity.get_default_type())
console = self.get_console(module.get_id())
activity.show_dialog(console)
+
+ def join_activity(self, service):
+ info = self._registry.get_activity(service.get_type())
+
+ activity_id = service.get_activity_id()
+ pservice = PresenceService()
+ activity_ps = pservice.get_activity(activity_id)
+
+ if activity_ps:
+ activity = ActivityFactory.create(info.get_id())
+ activity.set_default_type(service.get_type())
+ activity.join(activity_ps.object_path())
+ else:
+ logging.error('Cannot start activity.')
+
+ def start_activity(self, activity_name):
+ activity = ActivityFactory.create(activity_name)
+ info = self._registry.get_activity_from_id(activity_name)
+ if info:
+ activity.set_default_type(info.get_default_type())
+ return activity
+ else:
+ logging.error('No such activity in the directory')
+ return None
def log(self, module_id, message):
console = self.get_console(module_id)