From fafa1ae35ed73141131e445f4a883d71f9ef278d Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 19 Oct 2006 09:54:51 +0000 Subject: Refactor stylsheets code a bit to load the global stylsheet for all modules. Implement the links sidebar per discussion with Eben. --- (limited to 'activities') diff --git a/activities/web/linksview.py b/activities/web/linksview.py index 92d7026..70af786 100644 --- a/activities/web/linksview.py +++ b/activities/web/linksview.py @@ -17,16 +17,31 @@ import gtk import hippo -from sugar.graphics.bubble import Bubble +from sugar.graphics.menu import Menu +from sugar.graphics.menushell import MenuShell +from sugar.graphics.menuicon import MenuIcon from sugar.graphics.iconcolor import IconColor from sugar.graphics import style +class LinkIcon(MenuIcon): + def __init__(self, menu_shell, link): + color = IconColor(link.buddy.get_color()) + MenuIcon.__init__(self, menu_shell, color=color, + icon_name='activity-web') + + self._link = link + + def create_menu(self): + menu = Menu(self._link.title) + return menu + class LinksView(hippo.Canvas): def __init__(self, model, browser): hippo.Canvas.__init__(self) - self._bubbles = {} + self._icons = {} self._browser = browser + self._menu_shell = MenuShell(self) self._box = hippo.CanvasBox() style.apply_stylesheet(self._box, 'links.Box') @@ -39,36 +54,30 @@ class LinksView(hippo.Canvas): model.connect('link_removed', self._link_removed_cb) def _add_link(self, link): - if len(self._bubbles) == 0: + if len(self._icons) == 0: self.show() - color = IconColor(link.buddy.get_color()) - - bubble = Bubble(color=color) - style.apply_stylesheet(bubble, 'links.Bubble') - self._box.append(bubble) - - text = hippo.CanvasLink(text=link.title) - text.connect('activated', self._link_activated_cb, link) - style.apply_stylesheet(text, 'links.Text') - bubble.append(text, hippo.PACK_EXPAND) + icon = LinkIcon(self._menu_shell, link) + icon.connect('activated', self._link_activated_cb, link) + style.apply_stylesheet(icon, 'links.Icon') + self._box.append(icon) - self._bubbles[link] = bubble + self._icons[link] = icon def _remove_link(self, link): - bubble = self._bubbles[link] - self._box.remove(bubble) + icon = self._icons[link] + self._box.remove(icon) - del self._bubbles[link] + del self._icons[link] - if len(self._bubbles) == 0: + if len(self._icons) == 0: self.hide() def _link_added_cb(self, model, link): self._add_link(link) def _link_removed_cb(self, model, link): - self._removed_link(link) + self._remove_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 b513c14..3628818 100644 --- a/activities/web/stylesheet.py +++ b/activities/web/stylesheet.py @@ -16,19 +16,12 @@ import gtk -_screen_factor = gtk.gdk.screen_width() / 1200.0 +from sugar.graphics import style -links_Bubble = { - 'box-width' : int(250.0 * _screen_factor) -} - -links_Text = { - 'color' : 0x000000FF, - 'font' : '14px', - 'padding' : 6 +links_Icon = { + 'size' : style.standard_icon_size } links_Box = { - 'background_color' : 0x646464ff, - 'padding' : 4 + 'background_color' : 0x414141ff, } -- cgit v0.9.1