From 40fc6e2e47b956eabc34d8b772c066d8f8f0d530 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 16 Oct 2007 17:18:43 +0200 Subject: [PATCH] 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) --- configure.ac | 1 - lib/sugar/Makefile.am | 2 +- lib/sugar/graphics/objectchooser.py | 5 +---- services/shell/Makefile.am | 9 +++------ services/shell/clipboardobject.py | 26 +++++++------------------- 5 files changed, 12 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index 6eec5658..5af4b0ae 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/sugar/Makefile.am b/lib/sugar/Makefile.am index 8c1946d7..34468302 100644 --- a/lib/sugar/Makefile.am +++ b/lib/sugar/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = activity bundle clipboard graphics objects presence datastore +SUBDIRS = activity bundle clipboard graphics presence datastore sugardir = $(pythondir)/sugar sugar_PYTHON = \ diff --git a/lib/sugar/graphics/objectchooser.py b/lib/sugar/graphics/objectchooser.py index 114665f9..7522a9d5 100644 --- a/lib/sugar/graphics/objectchooser.py +++ b/lib/sugar/graphics/objectchooser.py @@ -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' diff --git a/services/shell/Makefile.am b/services/shell/Makefile.am index b34b974c..44496ff1 100644 --- a/services/shell/Makefile.am +++ b/services/shell/Makefile.am @@ -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 diff --git a/services/shell/clipboardobject.py b/services/shell/clipboardobject.py index 7a7d1c7e..70c21a04 100644 --- a/services/shell/clipboardobject.py +++ b/services/shell/clipboardobject.py @@ -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?