bigboard r7358 - in trunk: . bigboard
- From: marco svn gnome org
- To: svn-commits-list gnome org
- Subject: bigboard r7358 - in trunk: . bigboard
- Date: Wed, 11 Jun 2008 17:37:02 +0000 (UTC)
Author: marco
Date: Wed Jun 11 17:37:02 2008
New Revision: 7358
URL: http://svn.gnome.org/viewvc/bigboard?rev=7358&view=rev
Log:
Move stock stylesheet handling to the StockManager
Modified:
trunk/bigboard/stock.py
trunk/main.py
Modified: trunk/bigboard/stock.py
==============================================================================
--- trunk/bigboard/stock.py (original)
+++ trunk/bigboard/stock.py Wed Jun 11 17:37:02 2008
@@ -132,23 +132,6 @@
self.__cursize = None
self.__box = hippo.CanvasBox()
- self.__stylesheet = None
-
- from bigboard.big_widgets import ThemeManager
-
- self.__theme_mgr = ThemeManager.getInstance()
- self.__theme_mgr.connect('theme-changed', self.__sync_theme)
-
- def set_stylesheet(self, stylesheet):
- self.__stylesheet = stylesheet
- self.__sync_theme()
-
- def __sync_theme(self, *args):
- if self.__stylesheet:
- theme = self.__theme_mgr.make_stock_theme(self.__stylesheet)
- self.__box.set_theme(theme)
- else:
- self.__box.set_theme(None)
def __sync_content(self):
self.__box.remove_all()
Modified: trunk/main.py
==============================================================================
--- trunk/main.py (original)
+++ trunk/main.py Wed Jun 11 17:37:02 2008
@@ -224,7 +224,14 @@
pymodule = self.__load_builtin(module, **kwargs)
if not pymodule:
return None
- return Exchange(module, self.__widget_environ, pymodule=pymodule, is_notitle=(module.srcurl in self.__hardcoded_urls), panel=kwargs['panel'])
+
+ stylesheet = os.path.join(self.__get_moddir_for_builtin(module.srcurl), 'stock.css')
+ if not os.path.exists(stylesheet):
+ stylesheet = None
+
+ return Exchange(module, self.__widget_environ, pymodule=pymodule,
+ is_notitle=(module.srcurl in self.__hardcoded_urls),
+ panel=kwargs['panel'], stylesheet=stylesheet)
def render_url(self, url, **kwargs):
return self.render(self.load_metainfo(url), **kwargs)
@@ -259,10 +266,6 @@
title = metainfo.title
stock = class_constructor(metainfo, title=title, panel=panel)
- stylesheet = os.path.join(dirpath, 'stock.css')
- if os.path.exists(stylesheet):
- stock.set_stylesheet(stylesheet)
-
return stock
except:
_logger.exception("failed to add stock %s", classname)
@@ -297,7 +300,7 @@
class Exchange(hippo.CanvasBox, ThemedWidgetMixin):
"""A renderer for stocks."""
- def __init__(self, metainfo, env, pymodule=None, is_notitle=False, panel=None):
+ def __init__(self, metainfo, env, pymodule=None, is_notitle=False, panel=None, stylesheet=None):
hippo.CanvasBox.__init__(self,
orientation=hippo.ORIENTATION_VERTICAL,
spacing=4)
@@ -306,6 +309,8 @@
self.__env = env
self.__pymodule = pymodule
self.__panel = panel
+ self.__stylesheet = stylesheet
+ self.__content = None
self.__ticker_text = None
self.__ticker_container = None
self.__mini_more_button = None
@@ -330,6 +335,9 @@
self.append(self.__ticker_container)
+ self.__theme_mgr = ThemeManager.getInstance()
+ self.__theme_mgr.connect('theme-changed', self.__sync_theme)
+
self.__stockbox = hippo.CanvasBox()
self.append(self.__stockbox)
if pymodule:
@@ -340,6 +348,12 @@
self.__sync_visibility()
+ def __sync_theme(self, *args):
+ if self.__content:
+ if self.__stylesheet:
+ theme = self.__theme_mgr.make_stock_theme(self.__stylesheet)
+ self.__content.set_theme(theme)
+
def on_delisted(self):
_logger.debug("on_delisted exchange %s" % (str(self)))
self.__unrender_pymodule()
@@ -370,21 +384,24 @@
self.__size = size = Stock.SIZE_BULL
self.__stockbox.remove_all()
self.__pymodule.set_size(size)
- content = self.__pymodule.get_content(size)
+
+ self.__content = self.__pymodule.get_content(size)
+ self.__sync_theme()
+
if self.__ticker_container:
- self.set_child_visible(self.__ticker_container, not not content)
+ self.set_child_visible(self.__ticker_container, not not self.__content)
self.set_child_visible(self.__sep,
- (not not content) and \
+ (not not self.__content) and \
((self.__ticker_container and size == Stock.SIZE_BEAR) \
or (size == Stock.SIZE_BULL
and ((not self.__ticker_container) or (self.__pymodule.get_ticker() == "-")))))
if self.__mini_more_button:
self.set_child_visible(self.__mini_more_button, size == Stock.SIZE_BEAR)
- self.set_child_visible(self.__stockbox, not not content)
- if not content:
+ self.set_child_visible(self.__stockbox, not not self.__content)
+ if not self.__content:
_logger.debug("no content for stock %s", self.__pymodule)
return
- self.__stockbox.append(content)
+ self.__stockbox.append(self.__content)
padding = 4
self.__stockbox.set_property("padding_left", padding)
self.__stockbox.set_property("padding_right", padding)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]