Complete move to external bundle registry.
This commit is contained in:
+6
-6
@@ -26,6 +26,7 @@ import gtk
|
||||
import wnck
|
||||
|
||||
from sugar.activity.activityhandle import ActivityHandle
|
||||
from sugar import activity
|
||||
from sugar.activity import activityfactory
|
||||
from sugar.datastore import datastore
|
||||
from sugar import profile
|
||||
@@ -34,7 +35,6 @@ from view.ActivityHost import ActivityHost
|
||||
from view.frame.frame import Frame
|
||||
from view.keyhandler import KeyHandler
|
||||
from view.home.HomeWindow import HomeWindow
|
||||
from model import bundleregistry
|
||||
from model.shellmodel import ShellModel
|
||||
from hardware import hardwaremanager
|
||||
|
||||
@@ -116,16 +116,16 @@ class Shell(gobject.GObject):
|
||||
return self._frame
|
||||
|
||||
def join_activity(self, bundle_id, activity_id):
|
||||
activity = self.get_activity(activity_id)
|
||||
if activity:
|
||||
activity.present()
|
||||
activity_host = self.get_activity(activity_id)
|
||||
if activity_host:
|
||||
activity_host.present()
|
||||
return
|
||||
|
||||
# Get the service name for this activity, if
|
||||
# we have a bundle on the system capable of handling
|
||||
# this activity type
|
||||
breg = bundleregistry.get_registry()
|
||||
bundle = breg.get_bundle(bundle_id)
|
||||
registry = activity.get_registry()
|
||||
bundle = registry.get_activity(bundle_id)
|
||||
if not bundle:
|
||||
logging.error("Couldn't find activity for type %s" % bundle_id)
|
||||
return
|
||||
|
||||
@@ -123,32 +123,8 @@ class ClipboardMenu(Palette):
|
||||
def _open_item_activate_cb(self, menu_item):
|
||||
if self._percent < 100:
|
||||
return
|
||||
|
||||
jobject = self._copy_to_journal()
|
||||
# TODO: we cannot simply call resume() right now because we would lock
|
||||
# the shell as we are sharing the same loop as the shell service.
|
||||
#jobject.resume()
|
||||
|
||||
# TODO: take this out when we fix the mess that is the shell/shellservice.
|
||||
from model import bundleregistry
|
||||
from sugar.activity.bundle import Bundle
|
||||
from sugar.activity import activityfactory
|
||||
if jobject.is_bundle():
|
||||
bundle = Bundle(jobject.file_path)
|
||||
if not bundle.is_installed():
|
||||
bundle.install()
|
||||
|
||||
activityfactory.create(bundle.get_service_name())
|
||||
else:
|
||||
service_name = None
|
||||
mime_type = jobject.metadata['mime_type']
|
||||
for bundle in bundleregistry.get_registry():
|
||||
if bundle.get_mime_types() and mime_type in bundle.get_mime_types():
|
||||
service_name = bundle.get_service_name()
|
||||
break
|
||||
if service_name:
|
||||
activityfactory.create_with_object_id(service_name,
|
||||
jobject.object_id)
|
||||
jobject.resume()
|
||||
|
||||
def _remove_item_activate_cb(self, menu_item):
|
||||
cb_service = clipboardservice.get_instance()
|
||||
|
||||
@@ -22,31 +22,31 @@ from sugar.graphics.xocolor import XoColor
|
||||
from sugar.graphics.iconbutton import IconButton
|
||||
from sugar.graphics import style
|
||||
from sugar import profile
|
||||
from sugar import activity
|
||||
|
||||
from model import bundleregistry
|
||||
from frameinvoker import FrameCanvasInvoker
|
||||
|
||||
class ActivityButton(IconButton):
|
||||
def __init__(self, activity):
|
||||
IconButton.__init__(self, icon_name=activity.get_icon(),
|
||||
def __init__(self, activity_info):
|
||||
IconButton.__init__(self, icon_name=activity_info.icon,
|
||||
stroke_color=style.COLOR_WHITE,
|
||||
fill_color=style.COLOR_TRANSPARENT)
|
||||
|
||||
palette = Palette(activity.get_name())
|
||||
palette = Palette(activity_info.name)
|
||||
palette.props.invoker = FrameCanvasInvoker(self)
|
||||
palette.set_group_id('frame')
|
||||
self.set_palette(palette)
|
||||
|
||||
self._activity = activity
|
||||
self._activity_info = activity_info
|
||||
|
||||
def get_bundle_id(self):
|
||||
return self._activity.get_service_name()
|
||||
return self._activity_info.service_name
|
||||
|
||||
class InviteButton(IconButton):
|
||||
def __init__(self, activity, invite):
|
||||
IconButton.__init__(self, icon_name=activity.get_icon())
|
||||
def __init__(self, activity_model, invite):
|
||||
IconButton.__init__(self, icon_name=activity_model.get_color())
|
||||
|
||||
self.props.xo_color = activity.get_color()
|
||||
self.props.xo_color = activity_model.get_color()
|
||||
self._invite = invite
|
||||
|
||||
def get_activity_id(self):
|
||||
@@ -67,12 +67,12 @@ class ActivitiesBox(hippo.CanvasBox):
|
||||
self._invite_to_item = {}
|
||||
self._invites = self._shell_model.get_invites()
|
||||
|
||||
bundle_registry = bundleregistry.get_registry()
|
||||
for bundle in bundle_registry:
|
||||
if bundle.get_show_launcher():
|
||||
self.add_activity(bundle)
|
||||
registry = activity.get_registry()
|
||||
for activity_info in registry.get_activities():
|
||||
if activity_info.show_launcher:
|
||||
self.add_activity(activity_info)
|
||||
|
||||
bundle_registry.connect('bundle-added', self._bundle_added_cb)
|
||||
registry.connect('activity-added', self._activity_added_cb)
|
||||
|
||||
for invite in self._invites:
|
||||
self.add_invite(invite)
|
||||
@@ -93,19 +93,19 @@ class ActivitiesBox(hippo.CanvasBox):
|
||||
def _invite_removed_cb(self, invites, invite):
|
||||
self.remove_invite(invite)
|
||||
|
||||
def _bundle_added_cb(self, bundle_registry, bundle):
|
||||
self.add_activity(bundle)
|
||||
def _activity_added_cb(self, activity_registry, activity_info):
|
||||
self.add_activity(activity_info)
|
||||
|
||||
def add_activity(self, activity):
|
||||
item = ActivityButton(activity)
|
||||
def add_activity(self, activity_info):
|
||||
item = ActivityButton(activity_info)
|
||||
item.connect('activated', self._activity_clicked_cb)
|
||||
self.append(item, 0)
|
||||
|
||||
def add_invite(self, invite):
|
||||
mesh = self._shell_model.get_mesh()
|
||||
activity = mesh.get_activity(invite.get_activity_id())
|
||||
activity_model = mesh.get_activity(invite.get_activity_id())
|
||||
if activity:
|
||||
item = InviteButton(activity, invite)
|
||||
item = InviteButton(activity_model, invite)
|
||||
item.connect('activated', self._invite_clicked_cb)
|
||||
self.append(item, 0)
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import gobject
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import style
|
||||
from sugar.presence import presenceservice
|
||||
from sugar import activity
|
||||
|
||||
from model import bundleregistry
|
||||
from view.BuddyIcon import BuddyIcon
|
||||
|
||||
class FriendView(hippo.CanvasBox):
|
||||
@@ -46,9 +46,9 @@ class FriendView(hippo.CanvasBox):
|
||||
self._buddy.connect('disappeared', self._buddy_disappeared_cb)
|
||||
self._buddy.connect('color-changed', self._buddy_color_changed_cb)
|
||||
|
||||
def _get_new_icon_name(self, activity):
|
||||
registry = bundleregistry.get_registry()
|
||||
bundle = registry.get_bundle(activity.get_type())
|
||||
def _get_new_icon_name(self, home_activity):
|
||||
registry = activity.get_registry()
|
||||
bundle = registry.get_bundle(home_activity.get_type())
|
||||
if bundle:
|
||||
return bundle.get_icon()
|
||||
return None
|
||||
@@ -58,14 +58,14 @@ class FriendView(hippo.CanvasBox):
|
||||
self.remove(self._activity_icon)
|
||||
self._activity_icon_visible = False
|
||||
|
||||
def _buddy_activity_changed_cb(self, buddy, activity=None):
|
||||
if not activity:
|
||||
def _buddy_activity_changed_cb(self, buddy, home_activity=None):
|
||||
if not home_activity:
|
||||
self._remove_activity_icon()
|
||||
return
|
||||
|
||||
# FIXME: use some sort of "unknown activity" icon rather
|
||||
# than hiding the icon?
|
||||
name = self._get_new_icon_name(activity)
|
||||
name = self._get_new_icon_name(home_activity)
|
||||
if name:
|
||||
self._activity_icon.props.icon_name = name
|
||||
self._activity_icon.props.xo_color = buddy.get_color()
|
||||
@@ -76,8 +76,8 @@ class FriendView(hippo.CanvasBox):
|
||||
self._remove_activity_icon()
|
||||
|
||||
def _buddy_appeared_cb(self, buddy):
|
||||
activity = self._buddy.get_current_activity()
|
||||
self._buddy_activity_changed_cb(buddy, activity)
|
||||
home_activity = self._buddy.get_current_activity()
|
||||
self._buddy_activity_changed_cb(buddy, home_activity)
|
||||
|
||||
def _buddy_disappeared_cb(self, buddy):
|
||||
self._buddy_activity_changed_cb(buddy, None)
|
||||
|
||||
Reference in New Issue
Block a user