Simplify the API to get icon/description for objects.

Get rid of the service for now, it's not necessary
until we allow activities to extend the
mime type -> generic type mapping (post 1.0)
This commit is contained in:
Marco Pesenti Gritti 2007-10-16 17:18:43 +02:00
parent 05236c6670
commit 40fc6e2e47
5 changed files with 12 additions and 31 deletions

View File

@ -52,7 +52,6 @@ lib/sugar/activity/Makefile
lib/sugar/bundle/Makefile
lib/sugar/clipboard/Makefile
lib/sugar/graphics/Makefile
lib/sugar/objects/Makefile
lib/sugar/presence/Makefile
lib/sugar/datastore/Makefile
services/Makefile

View File

@ -1,4 +1,4 @@
SUBDIRS = activity bundle clipboard graphics objects presence datastore
SUBDIRS = activity bundle clipboard graphics presence datastore
sugardir = $(pythondir)/sugar
sugar_PYTHON = \

View File

@ -148,10 +148,7 @@ class CollapsedEntry(CanvasRoundBox):
mime_type = self.jobject.metadata['mime_type']
if not self._icon_name and mime_type:
type = objecttype.get_registry().get_type_for_mime(mime_type)
if type:
self._icon_name = type.icon
self._icon_name = mime.get_mime_icon(mime_type)
if not self._icon_name:
self._icon_name = 'image-missing'

View File

@ -2,13 +2,11 @@ servicedir = $(datadir)/dbus-1/services
service_in_files = \
org.laptop.ActivityRegistry.service.in \
org.laptop.Clipboard.service.in \
org.laptop.ObjectTypeRegistry.service.in
org.laptop.Clipboard.service.in
service_DATA = \
org.laptop.ActivityRegistry.service \
org.laptop.Clipboard.service \
org.laptop.ObjectTypeRegistry.service
org.laptop.Clipboard.service
org.laptop.ActivityRegistry.service: org.laptop.ActivityRegistry.service.in Makefile
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
@ -26,8 +24,7 @@ sugar_PYTHON = \
activityregistryservice.py \
bundleregistry.py \
clipboardobject.py \
clipboardservice.py \
objecttypeservice.py
clipboardservice.py
bin_SCRIPTS = sugar-shell-service

View File

@ -20,7 +20,6 @@ import urlparse
from sugar import mime
import objecttypeservice
import bundleregistry
class ClipboardObject:
@ -38,27 +37,16 @@ class ClipboardObject:
def get_id(self):
return self._id
def _get_type_info(self):
logging.debug('_get_type_info')
type_registry = objecttypeservice.get_instance()
return type_registry.GetTypeForMIME(self.get_mime_type())
def get_name(self):
if self._name:
return self._name
else:
type_info = self._get_type_info()
if type_info:
return type_info['name']
else:
return ''
name = self._name
if not name:
name = mime.get_mime_description(self.get_mime_type())
if not name:
name = ''
return name
def get_icon(self):
type_info = self._get_type_info()
if type_info:
return type_info['icon']
else:
return ''
return mime.get_mime_icon(self.get_mime_type())
def get_preview(self):
# TODO: should previews really be here?