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:
parent
05236c6670
commit
40fc6e2e47
@ -52,7 +52,6 @@ lib/sugar/activity/Makefile
|
|||||||
lib/sugar/bundle/Makefile
|
lib/sugar/bundle/Makefile
|
||||||
lib/sugar/clipboard/Makefile
|
lib/sugar/clipboard/Makefile
|
||||||
lib/sugar/graphics/Makefile
|
lib/sugar/graphics/Makefile
|
||||||
lib/sugar/objects/Makefile
|
|
||||||
lib/sugar/presence/Makefile
|
lib/sugar/presence/Makefile
|
||||||
lib/sugar/datastore/Makefile
|
lib/sugar/datastore/Makefile
|
||||||
services/Makefile
|
services/Makefile
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = activity bundle clipboard graphics objects presence datastore
|
SUBDIRS = activity bundle clipboard graphics presence datastore
|
||||||
|
|
||||||
sugardir = $(pythondir)/sugar
|
sugardir = $(pythondir)/sugar
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
|
@ -148,10 +148,7 @@ class CollapsedEntry(CanvasRoundBox):
|
|||||||
|
|
||||||
mime_type = self.jobject.metadata['mime_type']
|
mime_type = self.jobject.metadata['mime_type']
|
||||||
if not self._icon_name and mime_type:
|
if not self._icon_name and mime_type:
|
||||||
type = objecttype.get_registry().get_type_for_mime(mime_type)
|
self._icon_name = mime.get_mime_icon(mime_type)
|
||||||
if type:
|
|
||||||
self._icon_name = type.icon
|
|
||||||
|
|
||||||
if not self._icon_name:
|
if not self._icon_name:
|
||||||
self._icon_name = 'image-missing'
|
self._icon_name = 'image-missing'
|
||||||
|
|
||||||
|
@ -2,13 +2,11 @@ servicedir = $(datadir)/dbus-1/services
|
|||||||
|
|
||||||
service_in_files = \
|
service_in_files = \
|
||||||
org.laptop.ActivityRegistry.service.in \
|
org.laptop.ActivityRegistry.service.in \
|
||||||
org.laptop.Clipboard.service.in \
|
org.laptop.Clipboard.service.in
|
||||||
org.laptop.ObjectTypeRegistry.service.in
|
|
||||||
|
|
||||||
service_DATA = \
|
service_DATA = \
|
||||||
org.laptop.ActivityRegistry.service \
|
org.laptop.ActivityRegistry.service \
|
||||||
org.laptop.Clipboard.service \
|
org.laptop.Clipboard.service
|
||||||
org.laptop.ObjectTypeRegistry.service
|
|
||||||
|
|
||||||
org.laptop.ActivityRegistry.service: org.laptop.ActivityRegistry.service.in Makefile
|
org.laptop.ActivityRegistry.service: org.laptop.ActivityRegistry.service.in Makefile
|
||||||
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
||||||
@ -26,8 +24,7 @@ sugar_PYTHON = \
|
|||||||
activityregistryservice.py \
|
activityregistryservice.py \
|
||||||
bundleregistry.py \
|
bundleregistry.py \
|
||||||
clipboardobject.py \
|
clipboardobject.py \
|
||||||
clipboardservice.py \
|
clipboardservice.py
|
||||||
objecttypeservice.py
|
|
||||||
|
|
||||||
bin_SCRIPTS = sugar-shell-service
|
bin_SCRIPTS = sugar-shell-service
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import urlparse
|
|||||||
|
|
||||||
from sugar import mime
|
from sugar import mime
|
||||||
|
|
||||||
import objecttypeservice
|
|
||||||
import bundleregistry
|
import bundleregistry
|
||||||
|
|
||||||
class ClipboardObject:
|
class ClipboardObject:
|
||||||
@ -38,27 +37,16 @@ class ClipboardObject:
|
|||||||
def get_id(self):
|
def get_id(self):
|
||||||
return self._id
|
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):
|
def get_name(self):
|
||||||
if self._name:
|
name = self._name
|
||||||
return self._name
|
if not name:
|
||||||
else:
|
name = mime.get_mime_description(self.get_mime_type())
|
||||||
type_info = self._get_type_info()
|
if not name:
|
||||||
if type_info:
|
name = ''
|
||||||
return type_info['name']
|
return name
|
||||||
else:
|
|
||||||
return ''
|
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
type_info = self._get_type_info()
|
return mime.get_mime_icon(self.get_mime_type())
|
||||||
if type_info:
|
|
||||||
return type_info['icon']
|
|
||||||
else:
|
|
||||||
return ''
|
|
||||||
|
|
||||||
def get_preview(self):
|
def get_preview(self):
|
||||||
# TODO: should previews really be here?
|
# TODO: should previews really be here?
|
||||||
|
Loading…
Reference in New Issue
Block a user