#5760: Limit the number of items in the clipboard frame.
This commit is contained in:
parent
2b0b83aa09
commit
86b943b244
@ -24,6 +24,7 @@ import gtk
|
|||||||
from sugar import util
|
from sugar import util
|
||||||
from sugar.clipboard import clipboardservice
|
from sugar.clipboard import clipboardservice
|
||||||
from sugar.graphics.tray import VTray
|
from sugar.graphics.tray import VTray
|
||||||
|
from sugar.graphics import style
|
||||||
|
|
||||||
from view.clipboardicon import ClipboardIcon
|
from view.clipboardicon import ClipboardIcon
|
||||||
|
|
||||||
@ -58,6 +59,8 @@ class _ContextMap:
|
|||||||
|
|
||||||
class ClipboardBox(hippo.CanvasBox):
|
class ClipboardBox(hippo.CanvasBox):
|
||||||
|
|
||||||
|
MAX_ITEMS = gtk.gdk.screen_height() / style.GRID_CELL_SIZE - 2
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
hippo.CanvasBox.__init__(self)
|
hippo.CanvasBox.__init__(self)
|
||||||
self._icons = {}
|
self._icons = {}
|
||||||
@ -109,7 +112,13 @@ class ClipboardBox(hippo.CanvasBox):
|
|||||||
self._tray.add_item(icon, 0)
|
self._tray.add_item(icon, 0)
|
||||||
icon.show()
|
icon.show()
|
||||||
self._icons[object_id] = icon
|
self._icons[object_id] = icon
|
||||||
|
|
||||||
|
objects_to_delete = self._tray.get_children()[ClipboardBox.MAX_ITEMS:]
|
||||||
|
for icon in objects_to_delete:
|
||||||
|
logging.debug('ClipboardBox: deleting surplus object')
|
||||||
|
cb_service = clipboardservice.get_instance()
|
||||||
|
cb_service.delete_object(icon.get_object_id())
|
||||||
|
|
||||||
logging.debug('ClipboardBox: ' + object_id + ' was added.')
|
logging.debug('ClipboardBox: ' + object_id + ' was added.')
|
||||||
|
|
||||||
def _object_deleted_cb(self, cb_service, object_id):
|
def _object_deleted_cb(self, cb_service, object_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user