diff --git a/shell/conf/ActivityRegistry.py b/shell/conf/ActivityRegistry.py deleted file mode 100644 index 5899f34d..00000000 --- a/shell/conf/ActivityRegistry.py +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright (C) 2006, Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -import logging -import os -from ConfigParser import ConfigParser -from ConfigParser import NoOptionError - -from sugar import activity -from sugar import env -import sugar - -class ActivityModule: - """Info about an activity module. Wraps a .activity file.""" - - def __init__(self, name, activity_id, directory): - self._name = name - self._icon = None - self._id = activity_id - self._directory = directory - self._show_launcher = False - - def get_name(self): - """Get the activity user visible name.""" - return self._name - - def get_id(self): - """Get the activity identifier""" - return self._id - - def get_icon(self): - """Get the activity icon name""" - return self._icon - - def set_icon(self, icon): - """Set the activity icon name""" - self._icon = icon - - def get_directory(self): - """Get the path to activity directory.""" - return self._directory - - def get_default_type(self): - """Get the the type of the default activity service.""" - return activity.get_default_type(self._id) - - def set_default_type(self, default_type): - """Set the the type of the default activity service.""" - self._default_type = default_type - - def get_show_launcher(self): - """Get whether there should be a visible launcher for the activity""" - return self._show_launcher - - def set_show_launcher(self, show_launcher): - """Set whether there should be a visible launcher for the activity""" - self._show_launcher = show_launcher - -class _ActivityRegistry: - """Service that tracks the available activities""" - - def __init__(self): - self._activities = [] - self.scan_directory(env.get_activity_info_dir()) - - def get_activity(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_from_type(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): - for f in os.listdir(path): - if f.endswith(".activity"): - self.add(os.path.join(path, f)) - - def add(self, path): - """Add an activity to the registry. The path points to a .activity file.""" - cp = ConfigParser() - cp.read([path]) - - directory = os.path.dirname(path) - - try: - activity_id = cp.get('Activity', 'id') - except NoOptionError: - logging.error('%s miss the required id option' % (path)) - return False - - try: - name = cp.get('Activity', 'name') - except NoOptionError: - logging.error('%s miss the required name option' % (path)) - return False - - module = ActivityModule(name, activity_id, directory) - self._activities.append(module) - - if cp.has_option('Activity', 'show_launcher'): - if cp.get('Activity', 'show_launcher') == 'yes': - module.set_show_launcher(True) - - if cp.has_option('Activity', 'icon'): - module.set_icon(cp.get('Activity', 'icon')) - - return True - - def list_activities(self): - """Enumerate the registered activities as an ActivityModule list.""" - return self._activities diff --git a/shell/conf/Makefile.am b/shell/conf/Makefile.am deleted file mode 100644 index 0c3967ca..00000000 --- a/shell/conf/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -sugardir = $(pkgdatadir)/shell/conf -sugar_PYTHON = \ - __init__.py \ - ActivityRegistry.py diff --git a/shell/conf/__init__.py b/shell/conf/__init__.py deleted file mode 100644 index 8842daca..00000000 --- a/shell/conf/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from conf.ActivityRegistry import _ActivityRegistry - -_activity_registry = _ActivityRegistry() - -def get_activity_registry(): - return _activity_registry diff --git a/shell/model/Invites.py b/shell/model/Invites.py index 66c8a898..bc947a93 100644 --- a/shell/model/Invites.py +++ b/shell/model/Invites.py @@ -16,28 +16,12 @@ import gobject -import conf -from sugar.presence import PresenceService -from sugar.graphics.iconcolor import IconColor - class Invite: def __init__(self, issuer, bundle_id, activity_id): self._issuer = issuer self._activity_id = activity_id self._bundle_id = bundle_id - def get_icon(self): - reg = conf.get_activity_registry() - return reg.get_activity(self._bundle_id).get_icon() - - def get_color(self): - pservice = PresenceService.get_instance() - buddy = pservice.get_buddy_by_name(self._issuer) - if buddy != None: - return IconColor(buddy.get_color()) - else: - return IconColor('white') - def get_activity_id(self): return self._activity_id diff --git a/shell/model/MeshModel.py b/shell/model/MeshModel.py index 2006b5d4..0ecf2b86 100644 --- a/shell/model/MeshModel.py +++ b/shell/model/MeshModel.py @@ -16,7 +16,6 @@ import gobject -import conf from sugar.graphics.iconcolor import IconColor from sugar.presence import PresenceService from model.BuddyModel import BuddyModel diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index 65e2ac03..a7e177d7 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -17,7 +17,6 @@ import gtk import dbus -import conf from sugar import profile from sugar.activity import Activity from sugar.presence import PresenceService diff --git a/shell/view/home/FriendView.py b/shell/view/home/FriendView.py index e3343f83..2b5cf7c1 100644 --- a/shell/view/home/FriendView.py +++ b/shell/view/home/FriendView.py @@ -21,15 +21,12 @@ from view.BuddyIcon import BuddyIcon from sugar.graphics.canvasicon import CanvasIcon from sugar.graphics import style from sugar.presence import PresenceService -import conf - class FriendView(hippo.CanvasBox): def __init__(self, shell, menu_shell, buddy, **kwargs): hippo.CanvasBox.__init__(self, **kwargs) self._pservice = PresenceService.get_instance() - self._activity_registry = shell.get_model().get_registry() self._buddy = buddy self._buddy_icon = BuddyIcon(shell, menu_shell, buddy) @@ -52,8 +49,9 @@ class FriendView(hippo.CanvasBox): # FIXME: do something better here; we probably need to use "flagship" # services like mDNS where activities default services are marked # somehow. + activity_registry = shell.get_model().get_bundle_registry() for serv in activity.get_services(): - bundle = self._activity_registry.get_bundle(serv.get_type()) + bundle = activity_registry.get_bundle(serv.get_type()) if bundle: return bundle.get_icon() return None