blob: fde115662bb96a1ea649e8eba9149c9e89fb6a77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import hippo
from sugar.graphics.bubble import Bubble
class LinksView(hippo.Canvas):
def __init__(self, model):
hippo.Canvas.__init__(self)
self._bubbles = {}
self._box = hippo.CanvasBox(background_color=0x414141ff)
self.set_root(self._box)
for link in model:
self._add_link(link)
model.connect('link_added', self._link_added_cb)
model.connect('link_removed', self._link_removed_cb)
def _add_link(self, link):
bubble = Bubble(color=link.buddy.get_color())
self._box.append(link)
self._bubbles[link] = bubble
def _remove_link(self, link):
bubble = self._bubbles[link]
self._box.remove(bubble)
del self._bubbles[link]
def _link_added_cb(self, model, link):
self._add_link(link)
def _link_removed_cb(self, model, link):
self._removed_link(link)
|