Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
@@ -37,5 +37,3 @@ window, requesting sharing across the network, and basic
|
||||
"what type of application are you" queries.
|
||||
"""
|
||||
|
||||
from sugar.activity.registry import ActivityRegistry
|
||||
from sugar.activity.registry import ActivityInfo
|
||||
|
||||
@@ -93,7 +93,7 @@ class Bundle:
|
||||
logging.error('%s must specify exec or class' % self._path)
|
||||
|
||||
if cp.has_option(section, 'mime_types'):
|
||||
mime_list = cp.get(section, 'show_launcher')
|
||||
mime_list = cp.get(section, 'mime_types')
|
||||
self._mime_types = mime_list.strip(';')
|
||||
|
||||
if cp.has_option(section, 'show_launcher'):
|
||||
|
||||
@@ -32,13 +32,6 @@ class ActivityInfo(object):
|
||||
self.service_name = service_name
|
||||
self.path = path
|
||||
|
||||
def to_dict(self):
|
||||
return { 'name' : self.name,
|
||||
'icon' : self.icon,
|
||||
'service_name' : self.service_name,
|
||||
'path' : self.path
|
||||
}
|
||||
|
||||
class ActivityRegistry(object):
|
||||
def __init__(self):
|
||||
bus = dbus.SessionBus()
|
||||
@@ -53,10 +46,19 @@ class ActivityRegistry(object):
|
||||
|
||||
return result
|
||||
|
||||
def get_activities_for_name(self, name):
|
||||
info_list = self._registry.GetActivitiesForName(name)
|
||||
def get_activity(self, service_name):
|
||||
info_dict = self._registry.GetActivity(service_name)
|
||||
return _activity_info_from_dict(info_dict)
|
||||
|
||||
def find_activity(self, name):
|
||||
info_list = self._registry.FindActivity(name)
|
||||
return self._convert_info_list(info_list)
|
||||
|
||||
def get_activities_for_type(self, mime_type):
|
||||
info_list = self._registry.GetActivitiesForType(mime_type)
|
||||
return self._convert_info_list(info_list)
|
||||
|
||||
_registry = ActivityRegistry()
|
||||
|
||||
def get_registry():
|
||||
return _registry
|
||||
|
||||
@@ -25,9 +25,17 @@ class DSMetadata(gobject.GObject):
|
||||
([]))
|
||||
}
|
||||
|
||||
def __init__(self, props={}):
|
||||
def __init__(self, props=None):
|
||||
gobject.GObject.__init__(self)
|
||||
self._props = props
|
||||
if not props:
|
||||
self._props = {}
|
||||
else:
|
||||
self._props = props
|
||||
|
||||
default_keys = ['activity', 'mime_type']
|
||||
for key in default_keys:
|
||||
if not self._props.has_key(key):
|
||||
self._props[key] = ''
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._props[key]
|
||||
@@ -88,7 +96,7 @@ def create():
|
||||
return DSObject(object_id=None, metadata=DSMetadata(), file_path=None)
|
||||
|
||||
def write(ds_object, reply_handler=None, error_handler=None):
|
||||
logging.debug('datastore.write')
|
||||
logging.debug('datastore.write: %r' % ds_object.metadata.get_dictionary())
|
||||
if ds_object.object_id:
|
||||
dbus_helpers.update(ds_object.object_id,
|
||||
ds_object.metadata.get_dictionary(),
|
||||
|
||||
+23
-11
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user