Create a conf module. Move activity registry out of the shell
(should only be graphical) into it.
This commit is contained in:
@@ -2,9 +2,9 @@ from home.FriendsModel import FriendsModel
|
||||
from home.MeshModel import MeshModel
|
||||
|
||||
class HomeModel:
|
||||
def __init__(self, registry):
|
||||
def __init__(self):
|
||||
self._friends = FriendsModel()
|
||||
self._mesh = MeshModel(registry)
|
||||
self._mesh = MeshModel()
|
||||
|
||||
def get_friends(self):
|
||||
return self._friends
|
||||
|
||||
@@ -7,6 +7,7 @@ from sugar.canvas.IconItem import IconColor
|
||||
from sugar.canvas.DonutItem import DonutItem
|
||||
from sugar.canvas.DonutItem import PieceItem
|
||||
from sugar.canvas.DonutItem import PieceIcon
|
||||
from sugar import conf
|
||||
|
||||
class TasksItem(DonutItem):
|
||||
def __init__(self, shell):
|
||||
@@ -56,7 +57,7 @@ class ActivityBar(goocanvas.Group):
|
||||
|
||||
self._shell = shell
|
||||
|
||||
registry = shell.get_registry()
|
||||
registry = conf.get_activity_registry()
|
||||
for activity in registry.list_activities():
|
||||
if activity.get_show_launcher():
|
||||
self.add_activity(activity)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import gobject
|
||||
|
||||
from sugar.presence.PresenceService import PresenceService
|
||||
from ActivityRegistry import ActivityRegistry
|
||||
from sugar import conf
|
||||
|
||||
class ActivityInfo:
|
||||
def __init__(self, service):
|
||||
@@ -27,11 +27,10 @@ class MeshModel(gobject.GObject):
|
||||
([gobject.TYPE_PYOBJECT]))
|
||||
}
|
||||
|
||||
def __init__(self, registry):
|
||||
def __init__(self):
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
self._activities = {}
|
||||
self._registry = registry
|
||||
|
||||
self._pservice = PresenceService()
|
||||
self._pservice.connect("service-appeared", self.__service_appeared_cb)
|
||||
@@ -55,6 +54,7 @@ class MeshModel(gobject.GObject):
|
||||
self.__check_service(service)
|
||||
|
||||
def __check_service(self, service):
|
||||
if self._registry.get_activity(service.get_type()) != None:
|
||||
registry = conf.get_activity_registry()
|
||||
if registry.get_activity(service.get_type()) != None:
|
||||
if not self.has_activity(service.get_activity_id()):
|
||||
self.add_activity(service)
|
||||
|
||||
@@ -4,9 +4,11 @@ import goocanvas
|
||||
|
||||
from sugar.canvas.IconItem import IconItem
|
||||
from sugar.canvas.IconItem import IconColor
|
||||
from sugar import conf
|
||||
|
||||
class ActivityItem(IconItem):
|
||||
def __init__(self, activity, registry):
|
||||
def __init__(self, activity):
|
||||
registry = conf.get_activity_registry()
|
||||
info = registry.get_activity(activity.get_type())
|
||||
icon_name = info.get_icon()
|
||||
|
||||
@@ -18,9 +20,8 @@ class ActivityItem(IconItem):
|
||||
return self._activity.get_service()
|
||||
|
||||
class Model(goocanvas.CanvasModelSimple):
|
||||
def __init__(self, data_model, registry):
|
||||
def __init__(self, data_model):
|
||||
goocanvas.CanvasModelSimple.__init__(self)
|
||||
self._registry = registry
|
||||
|
||||
root = self.get_root_item()
|
||||
|
||||
@@ -51,7 +52,7 @@ class MeshView(goocanvas.CanvasView):
|
||||
|
||||
self.connect("item_view_created", self.__item_view_created_cb)
|
||||
|
||||
canvas_model = Model(data_model, shell.get_registry())
|
||||
canvas_model = Model(data_model)
|
||||
self.set_model(canvas_model)
|
||||
|
||||
def __activity_button_press_cb(self, view, target, event, service):
|
||||
|
||||
Reference in New Issue
Block a user