diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-10-13 17:04:04 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-10-13 17:04:04 (GMT) |
commit | 62fd4dcd89512299be4705db81f39cb3e8827dcd (patch) | |
tree | fe3f1f1036df7a1d36eff2406dabea9aede06459 | |
parent | 63e12fbd5ea5aef17a5b7aa26cb3c772cb0cb3db (diff) |
Basic functionalities mostly working
-rw-r--r-- | activities/web/linkscontroller.py | 14 | ||||
-rw-r--r-- | activities/web/linksview.py | 14 | ||||
-rw-r--r-- | activities/web/stylesheet.py | 10 | ||||
-rw-r--r-- | activities/web/webactivity.py | 2 | ||||
-rw-r--r-- | shell/view/frame/PanelWindow.py | 2 |
5 files changed, 33 insertions, 9 deletions
diff --git a/activities/web/linkscontroller.py b/activities/web/linkscontroller.py index 51d9c42..109c7bb 100644 --- a/activities/web/linkscontroller.py +++ b/activities/web/linkscontroller.py @@ -1,20 +1,30 @@ from sugar.p2p.Stream import Stream from sugar.presence import PresenceService +class _Marshaller(object): + def marshal(self, title, address): + return title + '\n' + address + + def demarshal(self, message): + return message.split('\n') + class LinksController(object): def __init__(self, service, model): self._model = model self._pservice = PresenceService.get_instance() + self._marshaller = _Marshaller() self._stream = Stream.new_from_service(service) self._stream.set_data_listener(self._recv_message) self._stream_writer = self._stream.new_writer() def post_link(self, title, address): - self._stream_writer.write('test') + message = self._marshaller.marshal(title, address) + self._stream_writer.write(message) def _recv_message(self, address, msg): buddy = self._pservice.get_buddy_by_address(address) if buddy: - self._model.add_link(buddy, 'Test title', 'Test address') + link = self._marshaller.demarshal(msg) + self._model.add_link(buddy, *link) diff --git a/activities/web/linksview.py b/activities/web/linksview.py index 3c8e3df..1afd651 100644 --- a/activities/web/linksview.py +++ b/activities/web/linksview.py @@ -6,10 +6,11 @@ from sugar.graphics.iconcolor import IconColor from sugar.graphics import style class LinksView(hippo.Canvas): - def __init__(self, model): + def __init__(self, model, browser): hippo.Canvas.__init__(self) self._bubbles = {} + self._browser = browser self._box = hippo.CanvasBox(background_color=0x414141ff) self.set_root(self._box) @@ -22,10 +23,16 @@ class LinksView(hippo.Canvas): def _add_link(self, link): color = IconColor(link.buddy.get_color()) + bubble = Bubble(color=color) - style.apply_stylesheet(bubble, 'bubble.Box') + style.apply_stylesheet(bubble, 'bubble.Bubble') self._box.append(bubble) + text = hippo.CanvasLink(text=link.title) + text.connect('activated', self._link_activated_cb, link) + style.apply_stylesheet(text, 'bubble.Text') + bubble.append(text, hippo.PACK_EXPAND) + self._bubbles[link] = bubble def _remove_link(self, link): @@ -39,3 +46,6 @@ class LinksView(hippo.Canvas): def _link_removed_cb(self, model, link): self._removed_link(link) + + def _link_activated_cb(self, link_item, link): + self._browser.load_url(link.url) diff --git a/activities/web/stylesheet.py b/activities/web/stylesheet.py index bd0a6a6..dd15e54 100644 --- a/activities/web/stylesheet.py +++ b/activities/web/stylesheet.py @@ -2,7 +2,11 @@ import gtk _screen_factor = gtk.gdk.screen_width() / 1200.0 -bubble_Box = { - 'box-width' : int(150.0 * _screen_factor), - 'box-height' : int(50.0 * _screen_factor) +bubble_Bubble = { + 'box-width' : int(250.0 * _screen_factor) +} + +bubble_Text = { + 'color' : 0x000000FF, + 'font' : '14px' } diff --git a/activities/web/webactivity.py b/activities/web/webactivity.py index 8ef4189..4bad200 100644 --- a/activities/web/webactivity.py +++ b/activities/web/webactivity.py @@ -26,7 +26,7 @@ class WebActivity(Activity): self._browser.connect('notify::title', self._title_changed_cb) self._links_model = LinksModel() - links_view = LinksView(self._links_model) + links_view = LinksView(self._links_model, self._browser) self._toolbar = Toolbar(self._browser) vbox.pack_start(self._toolbar, False) diff --git a/shell/view/frame/PanelWindow.py b/shell/view/frame/PanelWindow.py index 0c2930c..a7f02be 100644 --- a/shell/view/frame/PanelWindow.py +++ b/shell/view/frame/PanelWindow.py @@ -10,7 +10,7 @@ class PanelWindow(gtk.Window): canvas = hippo.Canvas() - self._bg = hippo.CanvasBox(background_color=0x4f4f4fff) + self._bg = hippo.CanvasBox(background_color=0x414141ff) canvas.set_root(self._bg) self.add(canvas) |