More work on links
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from sugar.p2p.Stream import Stream
|
||||
from sugar.presence import PresenceService
|
||||
|
||||
class LinksController(object):
|
||||
|
||||
@@ -18,13 +18,13 @@ class LinksModel(gobject.GObject):
|
||||
gobject.GObject.__init__(self)
|
||||
self._links = {}
|
||||
|
||||
def add_link(buddy, title, url):
|
||||
def add_link(self, buddy, title, url):
|
||||
link = Link(buddy, title, url)
|
||||
self._links[(buddy.get_name(), url)] = link
|
||||
|
||||
self.emit('link-added', link)
|
||||
|
||||
def remove_link(buddy, url):
|
||||
def remove_link(self, buddy, url):
|
||||
key = (buddy.get_name(), url)
|
||||
if self._links.haskey(key):
|
||||
link = self._links[key]
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import gtk
|
||||
import hippo
|
||||
|
||||
from sugar.graphics.bubble import Bubble
|
||||
from sugar.graphics.iconcolor import IconColor
|
||||
from sugar.graphics import style
|
||||
|
||||
class LinksView(hippo.Canvas):
|
||||
def __init__(self, model):
|
||||
@@ -18,8 +21,10 @@ class LinksView(hippo.Canvas):
|
||||
model.connect('link_removed', self._link_removed_cb)
|
||||
|
||||
def _add_link(self, link):
|
||||
bubble = Bubble(color=link.buddy.get_color())
|
||||
self._box.append(link)
|
||||
color = IconColor(link.buddy.get_color())
|
||||
bubble = Bubble(color=color)
|
||||
style.apply_stylesheet(bubble, 'bubble.Box')
|
||||
self._box.append(bubble)
|
||||
|
||||
self._bubbles[link] = bubble
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
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)
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class Toolbar(gtk.Toolbar):
|
||||
|
||||
def set_links_controller(self, links_controller):
|
||||
self._links_controller = links_controller
|
||||
self._post.props.sensitive = False
|
||||
self._post.props.sensitive = True
|
||||
|
||||
def _progress_changed_cb(self, embed, spec):
|
||||
self._entry.props.progress = embed.props.progress
|
||||
|
||||
@@ -4,6 +4,8 @@ import gtkmozembed
|
||||
|
||||
from sugar.activity.Activity import Activity
|
||||
from sugar import env
|
||||
from sugar.graphics import style
|
||||
import web.stylesheet
|
||||
from webbrowser import WebBrowser
|
||||
from toolbar import Toolbar
|
||||
from linksmodel import LinksModel
|
||||
@@ -23,8 +25,8 @@ class WebActivity(Activity):
|
||||
self._browser = WebBrowser()
|
||||
self._browser.connect('notify::title', self._title_changed_cb)
|
||||
|
||||
links_model = LinksModel()
|
||||
links_view = LinksView(links_model)
|
||||
self._links_model = LinksModel()
|
||||
links_view = LinksView(self._links_model)
|
||||
|
||||
self._toolbar = Toolbar(self._browser)
|
||||
vbox.pack_start(self._toolbar, False)
|
||||
@@ -46,11 +48,14 @@ class WebActivity(Activity):
|
||||
|
||||
self._browser.load_url(_HOMEPAGE)
|
||||
|
||||
def _setup_links_controller(self):
|
||||
links_controller = LinksController(self._service, self._links_model)
|
||||
self._toolbar.set_links_controller(links_controller)
|
||||
|
||||
def join(self, activity_ps):
|
||||
Activity.join(self, activity_ps)
|
||||
|
||||
links_controller = LinksController(service, links_model)
|
||||
self._toolbar.set_links_controller(links_controller)
|
||||
self._setup_links_controller()
|
||||
|
||||
url = self._service.get_published_value('URL')
|
||||
if url:
|
||||
@@ -59,6 +64,8 @@ class WebActivity(Activity):
|
||||
def share(self):
|
||||
Activity.share(self)
|
||||
|
||||
self._setup_links_controller()
|
||||
|
||||
url = self._browser.get_location()
|
||||
if url:
|
||||
self._service.set_published_value('URL', url)
|
||||
@@ -68,3 +75,4 @@ class WebActivity(Activity):
|
||||
|
||||
def start():
|
||||
gtkmozembed.set_profile_path(env.get_profile_path(), 'gecko')
|
||||
style.load_stylesheet(web.stylesheet)
|
||||
|
||||
Reference in New Issue
Block a user