#5760: Limit the number of items in the clipboard frame.

This commit is contained in:
Tomeu Vizoso 2008-01-09 18:47:06 +01:00
parent 2b0b83aa09
commit 86b943b244

View File

@ -24,6 +24,7 @@ import gtk
from sugar import util
from sugar.clipboard import clipboardservice
from sugar.graphics.tray import VTray
from sugar.graphics import style
from view.clipboardicon import ClipboardIcon
@ -58,6 +59,8 @@ class _ContextMap:
class ClipboardBox(hippo.CanvasBox):
MAX_ITEMS = gtk.gdk.screen_height() / style.GRID_CELL_SIZE - 2
def __init__(self):
hippo.CanvasBox.__init__(self)
self._icons = {}
@ -110,6 +113,12 @@ class ClipboardBox(hippo.CanvasBox):
icon.show()
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.')
def _object_deleted_cb(self, cb_service, object_id):