diff --git a/shell/view/frame/clipboardbox.py b/shell/view/frame/clipboardbox.py index cf2f9f55..77027595 100644 --- a/shell/view/frame/clipboardbox.py +++ b/shell/view/frame/clipboardbox.py @@ -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 = {} @@ -109,7 +112,13 @@ class ClipboardBox(hippo.CanvasBox): self._tray.add_item(icon, 0) 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):