From c1b5b9cf98c5d7f1a1d4c90f4df189770e87cb8c Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Mon, 02 Mar 2009 14:19:29 +0000 Subject: Merge branch 'master' of gitorious@git.sugarlabs.org:sugar/mainline --- (limited to 'src') diff --git a/src/jarabe/frame/clipboardobject.py b/src/jarabe/frame/clipboardobject.py index ccbaf8e..38da151 100644 --- a/src/jarabe/frame/clipboardobject.py +++ b/src/jarabe/frame/clipboardobject.py @@ -51,7 +51,14 @@ class ClipboardObject(object): return name def get_icon(self): - icons = gio.content_type_get_icon(self.get_mime_type()) + mime_type = self.get_mime_type() + + generic_types = mime.get_all_generic_types() + for generic_type in generic_types: + if mime_type in generic_type.mime_types: + return generic_type.icon + + icons = gio.content_type_get_icon(mime_type) icon_name = None if icons is not None: icon_theme = gtk.icon_theme_get_default() @@ -60,12 +67,9 @@ class ClipboardObject(object): gtk.ICON_SIZE_LARGE_TOOLBAR, 0) if icon_info is not None: icon_info.free() - break - - if icon_name is None: - icon_name = 'application-octet-stream' + return icon_name - return icon_name + return 'application-octet-stream' def get_preview(self): for mime_type in ['text/plain']: diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py index 52a86fa..f481644 100644 --- a/src/jarabe/journal/misc.py +++ b/src/jarabe/journal/misc.py @@ -65,17 +65,20 @@ def get_icon_name(metadata): if file_name is None and is_activity_bundle(metadata): file_path = model.get_file(metadata['uid']) - if os.path.exists(file_path): + if file_path is not None and os.path.exists(file_path): try: bundle = ActivityBundle(file_path) file_name = bundle.get_icon() - except Exception: + except: logging.warning('Could not read bundle:\n' + \ - ''.join(traceback.format_exception(*sys.exc_info()))) + traceback.format_exc()) if file_name is None: file_name = _get_icon_for_mime(metadata.get('mime_type', '')) + if file_name is None: + file_name = get_icon_file_name('application-octet-stream') + return file_name def get_date(metadata): diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py index 054de7d..b6d2bde 100644 --- a/src/jarabe/journal/model.py +++ b/src/jarabe/journal/model.py @@ -39,7 +39,7 @@ DS_DBUS_PATH = '/org/laptop/sugar/DataStore' # Properties the journal cares about. PROPERTIES = ['uid', 'title', 'mtime', 'timestamp', 'keep', 'buddies', 'icon-color', 'mime_type', 'progress', 'activity', 'mountpoint', - 'activity_id'] + 'activity_id', 'bundle_id'] PAGES_TO_CACHE = 5 diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py index 62ac6e2..ee440a5 100644 --- a/src/jarabe/model/bundleregistry.py +++ b/src/jarabe/model/bundleregistry.py @@ -72,15 +72,7 @@ class BundleRegistry(gobject.GObject): if not one_file.get_path().endswith('.activity'): return if event_type == gio.FILE_MONITOR_EVENT_CREATED: - try: - bundle = ActivityBundle(one_file.get_path()) - except MalformedBundleException: - logging.error('Error loading bundle %r:\n%s' % ( - one_file.get_path(), - ''.join(traceback.format_exception(*sys.exc_info())))) - return - if not self.is_installed(bundle): - self.add_bundle(one_file.get_path()) + self.add_bundle(one_file.get_path()) elif event_type == gio.FILE_MONITOR_EVENT_DELETED: self.remove_bundle(one_file.get_path()) @@ -216,6 +208,9 @@ class BundleRegistry(gobject.GObject): ''.join(traceback.format_exception(*sys.exc_info())))) return None + if self.get_bundle(bundle.get_bundle_id()) is not None: + return None + self._bundles.append(bundle) return bundle -- cgit v0.9.1