Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/objects
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-05-29 12:16:49 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-05-29 12:16:49 (GMT)
commit53d64a053682d1739326e28f0fe76e940a8f78ec (patch)
tree54b0a4e30c61fdf785201a930ddec7073149092e /sugar/objects
parent0c77275ba7a5a7e30b685ba847f7b39ca29803a4 (diff)
Use the commit id for the snapshot name
Diffstat (limited to 'sugar/objects')
-rw-r--r--sugar/objects/objecttype.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/sugar/objects/objecttype.py b/sugar/objects/objecttype.py
new file mode 100644
index 0000000..81b8ec1
--- /dev/null
+++ b/sugar/objects/objecttype.py
@@ -0,0 +1,43 @@
+_SERVICE = "org.laptop.ObjectTypeRegistry"
+_PATH = "/org/laptop/ObjectTypeRegistry"
+_IFACE = "org.laptop.ObjectTypeRegistry"
+
+def _object_type_from_dict(info_dict):
+ if info_dict:
+ return ObjectType(info_dict['type_id'],
+ info_dict['name'],
+ info_dict['icon'])
+ else:
+ return None
+
+class ObjectType(object):
+ def __init__(self, type_id, name, icon, mime_types):
+ 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):
+ 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)
+ return _object_type_from_dict(type_dict)
+
+_registry = ObjectRegistry()
+
+def get_registry():
+ return _registry