Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-04-19 14:35:45 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-04-19 14:35:45 (GMT)
commit8aa84cd69e458ebefd4800c6cf5c25b51e337a82 (patch)
tree4f694fd99a781fd25fe8de02b2d3aae510e2b6ab /services
parentcf5ef53070a8138aff7dbc8d48d20e1baf6b78d1 (diff)
parentd223579f22c4327eec367b0362cc18f214137e76 (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'services')
-rw-r--r--services/clipboard/typeregistry.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/services/clipboard/typeregistry.py b/services/clipboard/typeregistry.py
index b6f4ae1..88bdf60 100644
--- a/services/clipboard/typeregistry.py
+++ b/services/clipboard/typeregistry.py
@@ -1,5 +1,7 @@
import logging
from gettext import gettext as _
+import urlparse
+import posixpath
class FileType:
def __init__(self, formats):
@@ -200,15 +202,33 @@ class OOTextFileType(FileType):
class UriListFileType(FileType):
_types = set(['text/uri-list'])
-
+
+ def _is_image(self):
+ uris = self._formats['text/uri-list'].get_data().split('\n')
+ if len(uris) == 1:
+ uri = urlparse.urlparse(uris[0])
+ ext = posixpath.splitext(uri.path)[1]
+ logging.debug(ext)
+ # FIXME: Bad hack, the type registry should treat text/uri-list as a special case.
+ if ext in ['.jpg', '.jpeg', '.gif', '.png', '.svg']:
+ return True
+
+ return False
+
def get_name(self):
- return _('text/uri-list')
+ if self._is_image():
+ return _('Image')
+ else:
+ return _('File')
def get_icon(self):
- return 'theme:stock-missing'
+ if self._is_image():
+ return 'theme:object-image'
+ else:
+ return 'theme:stock-missing'
def get_preview(self):
- return 'preview'
+ return ''
def get_activity(self):
return ''