Some clipboard fixes.
This commit is contained in:
parent
a7d6251664
commit
1ee6b7faf0
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
class FileType:
|
class FileType:
|
||||||
def __init__(self, formats):
|
def __init__(self, formats):
|
||||||
@ -22,7 +23,7 @@ class TextFileType(FileType):
|
|||||||
_types = set(['text/plain', 'UTF8_STRING', 'STRING'])
|
_types = set(['text/plain', 'UTF8_STRING', 'STRING'])
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return 'Text snippet'
|
return _('Text snippet')
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
return 'activity-xbook'
|
return 'activity-xbook'
|
||||||
@ -30,7 +31,11 @@ class TextFileType(FileType):
|
|||||||
def get_preview(self):
|
def get_preview(self):
|
||||||
for format, data in self._formats.iteritems():
|
for format, data in self._formats.iteritems():
|
||||||
if format in TextFileType._types:
|
if format in TextFileType._types:
|
||||||
return str(data.get_data())
|
text = str(data.get_data())
|
||||||
|
if len(text) < 50:
|
||||||
|
return text
|
||||||
|
else:
|
||||||
|
return text[0:49] + "..."
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@ -43,7 +48,7 @@ class ImageFileType(FileType):
|
|||||||
_types = set(['image/jpeg', 'image/gif', 'image/png', 'image/tiff'])
|
_types = set(['image/jpeg', 'image/gif', 'image/png', 'image/tiff'])
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return 'Image'
|
return _('Image')
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
return 'activity-sketch'
|
return 'activity-sketch'
|
||||||
@ -60,7 +65,7 @@ class UriFileType(FileType):
|
|||||||
_types = set(['_NETSCAPE_URL'])
|
_types = set(['_NETSCAPE_URL'])
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return 'URL'
|
return _('Web Page')
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
return 'activity-web'
|
return 'activity-web'
|
||||||
@ -83,7 +88,7 @@ class PdfFileType(FileType):
|
|||||||
_types = set(['application/pdf'])
|
_types = set(['application/pdf'])
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return 'PDF file'
|
return _('PDF file')
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
return 'activity-xbook'
|
return 'activity-xbook'
|
||||||
@ -100,7 +105,7 @@ class MsWordFileType(FileType):
|
|||||||
_types = set(['application/msword'])
|
_types = set(['application/msword'])
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return 'MS Word file'
|
return _('MS Word file')
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
return 'activity-abiword'
|
return 'activity-abiword'
|
||||||
@ -117,7 +122,7 @@ class RtfFileType(FileType):
|
|||||||
_types = set(['application/rtf', 'text/rtf'])
|
_types = set(['application/rtf', 'text/rtf'])
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return 'RTF file'
|
return _('RTF file')
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
return 'activity-abiword'
|
return 'activity-abiword'
|
||||||
@ -131,7 +136,7 @@ class RtfFileType(FileType):
|
|||||||
|
|
||||||
class UnknownFileType(FileType):
|
class UnknownFileType(FileType):
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return 'Object'
|
return _('Object')
|
||||||
|
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
return 'stock-missing'
|
return 'stock-missing'
|
||||||
|
@ -31,7 +31,7 @@ class ClipboardMenu(Menu):
|
|||||||
self._remove_icon = None
|
self._remove_icon = None
|
||||||
self._stop_icon = None
|
self._stop_icon = None
|
||||||
|
|
||||||
self.add_item(preview)
|
self.add_item(preview, wrap=True)
|
||||||
|
|
||||||
self._update_icons(percent)
|
self._update_icons(percent)
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class ClipboardPanelWindow(PanelWindow):
|
|||||||
key = util.unique_id()
|
key = util.unique_id()
|
||||||
|
|
||||||
cb_service = clipboardservice.get_instance()
|
cb_service = clipboardservice.get_instance()
|
||||||
cb_service.add_object(key, "name")
|
cb_service.add_object(key, name="")
|
||||||
cb_service.set_object_percent(key, percent = 100)
|
cb_service.set_object_percent(key, percent = 100)
|
||||||
|
|
||||||
targets = clipboard.wait_for_targets()
|
targets = clipboard.wait_for_targets()
|
||||||
|
@ -76,12 +76,14 @@ class Menu(gtk.Window):
|
|||||||
orientation=hippo.ORIENTATION_HORIZONTAL)
|
orientation=hippo.ORIENTATION_HORIZONTAL)
|
||||||
self._root.append(self._action_box)
|
self._root.append(self._action_box)
|
||||||
|
|
||||||
def add_item(self, label, action_id=None):
|
def add_item(self, label, action_id=None, wrap=False):
|
||||||
if not self._item_box:
|
if not self._item_box:
|
||||||
self._create_item_box()
|
self._create_item_box()
|
||||||
|
|
||||||
text = hippo.CanvasText(text=label)
|
text = hippo.CanvasText(text=label)
|
||||||
style.apply_stylesheet(text, 'menu.Item')
|
style.apply_stylesheet(text, 'menu.Item')
|
||||||
|
if wrap:
|
||||||
|
text.set_property("size-mode", "wrap-word")
|
||||||
|
|
||||||
# FIXME need a way to make hippo items activable in python
|
# FIXME need a way to make hippo items activable in python
|
||||||
if action_id:
|
if action_id:
|
||||||
|
Loading…
Reference in New Issue
Block a user