From 22689ed1dac2c99b10c7de5d8a51789f3abd4f35 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Tue, 12 Jun 2007 19:57:49 +0000 Subject: Several fixes for the object type registry and the activity registry. --- (limited to 'sugar/objects') diff --git a/sugar/objects/objecttype.py b/sugar/objects/objecttype.py index 81b8ec1..b515bd1 100644 --- a/sugar/objects/objecttype.py +++ b/sugar/objects/objecttype.py @@ -1,3 +1,21 @@ +# Copyright (C) 2007, 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 dbus + _SERVICE = "org.laptop.ObjectTypeRegistry" _PATH = "/org/laptop/ObjectTypeRegistry" _IFACE = "org.laptop.ObjectTypeRegistry" @@ -11,33 +29,27 @@ def _object_type_from_dict(info_dict): return None class ObjectType(object): - def __init__(self, type_id, name, icon, mime_types): + def __init__(self, type_id, name, icon): self.type_id = type_id self.name = name self.icon = icon self.mime_types = [] - def to_dict(self): - return { 'type_id' : self.type_id, - 'name' : self.name, - 'icon' : self.icon - } - class ObjectTypeRegistry(object): def __init__(self): bus = dbus.SessionBus() bus_object = bus.get_object(_SERVICE, _PATH) self._registry = dbus.Interface(bus_object, _IFACE) - def get_type(type_id): + def get_type(self, type_id): type_dict = self._registry.GetType(type_id) return _object_type_from_dict(type_dict) - def get_type_for_mime(mime_type): - type_dict = self._registry.GetTypeForMime(type_id) + def get_type_for_mime(self, mime_type): + type_dict = self._registry.GetTypeForMIME(mime_type) return _object_type_from_dict(type_dict) -_registry = ObjectRegistry() +_registry = ObjectTypeRegistry() def get_registry(): return _registry -- cgit v0.9.1