Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2008-01-09 17:47:06 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2008-01-09 17:47:06 (GMT)
commit86b943b2445f42ee42ee07d3258abe695739e65e (patch)
treeb90c5c23465377735104b2d22d6d14bda1cffdbb /shell
parent2b0b83aa096df328de968ba0a5beb26598bbbd15 (diff)
#5760: Limit the number of items in the clipboard frame.
Diffstat (limited to 'shell')
-rw-r--r--shell/view/frame/clipboardbox.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/shell/view/frame/clipboardbox.py b/shell/view/frame/clipboardbox.py
index cf2f9f5..7702759 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):