bigboard r7400 - in trunk/bigboard: . core stocks/search themes themes/default themes/fedora



Author: otaylor
Date: Tue Jun 24 18:59:29 2008
New Revision: 7400
URL: http://svn.gnome.org/viewvc/bigboard?rev=7400&view=rev

Log:
Move themes into subdirectories to make it cleaner to have image files in a theme.
Split ThemeManager into a separate file


Added:
   trunk/bigboard/theme_manager.py
   trunk/bigboard/themes/default/
   trunk/bigboard/themes/default/__init__.py
      - copied unchanged from r7398, /trunk/bigboard/themes/default.py
   trunk/bigboard/themes/default/theme.css
      - copied unchanged from r7398, /trunk/bigboard/themes/default.css
   trunk/bigboard/themes/fedora/
   trunk/bigboard/themes/fedora/__init__.py
      - copied unchanged from r7398, /trunk/bigboard/themes/fedora.py
   trunk/bigboard/themes/fedora/theme.css
      - copied unchanged from r7398, /trunk/bigboard/themes/fedora.css
Removed:
   trunk/bigboard/themes/default.css
   trunk/bigboard/themes/default.py
   trunk/bigboard/themes/fedora.css
   trunk/bigboard/themes/fedora.py
Modified:
   trunk/bigboard/big_widgets.py
   trunk/bigboard/core/panel.py
   trunk/bigboard/stocks/search/SearchStock.py

Modified: trunk/bigboard/big_widgets.py
==============================================================================
--- trunk/bigboard/big_widgets.py	(original)
+++ trunk/bigboard/big_widgets.py	Tue Jun 24 18:59:29 2008
@@ -1,4 +1,5 @@
-import os, code, sys, traceback, logging, StringIO, re, threading, urlparse, weakref, math
+import logging
+import urlparse
 
 import cairo
 import pango
@@ -14,6 +15,7 @@
 import libbig, stock, globals, bigboard
 from bigboard.libbig.signalobject import SignalObject
 from bigboard.libbig.singletonmixin import Singleton
+from bigboard.theme_manager import ThemeManager
 from table_layout import TableLayout
 
 _logger = logging.getLogger("bigboard.BigWidgets")
@@ -34,77 +36,6 @@
         self.spinner = gtk.SpinButton()
         self.set_property('widget', self.spinner)
 
-class ThemeManager(gobject.GObject):
-    __gsignals__ = {
-                    'theme-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
-                   }
-    def __init__(self):
-        super(ThemeManager, self).__init__()
-        self.__class__.instance = weakref.ref(self)
-        self.__default_theme = None
-        self.__theme = None
-        gconf.client_get_default().notify_add('/apps/bigboard/theme', self.__sync_theme)
-        self.__sync_theme()
-        
-    @staticmethod
-    def getInstance():
-        needinst = False
-        if not hasattr(ThemeManager, 'instance'):
-            instvalue = None
-        else:
-            instref = getattr(ThemeManager, 'instance')
-            instvalue = instref()
-            needinst = instvalue is None
-        if instvalue is None:
-            inst = ThemeManager()
-        else:
-            inst = instvalue
-        return inst
-
-    def __make_theme(self, themename):
-        is_default = False
-        if themename == 'Fedora':
-            import bigboard.themes.fedora as package
-        else:
-            if self.__default_theme != None:
-                return self.__default_theme
-            
-            import bigboard.themes.default as package
-            is_default = True
-
-        theme_engine = package.getInstance()
-        stylesheet_name = re.sub(r"\.[^.]*$", ".css", package.__file__)
-
-        theme = hippo.CanvasTheme(theme_engine = theme_engine, theme_stylesheet = stylesheet_name)
-        if is_default and self.__default_theme == None:
-            self.__default_theme = theme
-
-        return theme
-
-    def make_stock_theme(self, application_stylesheet, default=False):
-        if default:
-            theme = self.get_default_theme()
-        else:
-            theme = self.get_theme()
-
-        return hippo.CanvasTheme(theme_engine = theme.props.theme_engine,
-                                 theme_stylesheet = theme.props.theme_stylesheet,
-                                 application_stylesheet = application_stylesheet)
-        
-    def get_theme(self):
-        return self.__theme
-
-    def get_default_theme(self):
-        return self.__make_theme('default')
-        
-    @log_except(_logger)
-    def __sync_theme(self, *args):
-        themename = gconf.client_get_default().get_string('/apps/bigboard/theme')
-        _logger.debug("doing theme sync: <THEMENAME>%r</THEMENAME>", themename)
-        
-        self.__theme = self.__make_theme(themename)
-        self.emit('theme-changed')            
-         
 class BigWindow(hippo.CanvasWindow):
     __gsignals__ = {
         'destroy' : 'override',
@@ -146,23 +77,6 @@
             self.__connection = None
         hippo.CanvasWindow.destroy(self)
 
-class ThemedWidgetMixin(object):
-    def __init__(self):
-        super(ThemedWidgetMixin, self).__init__()
-        mgr = ThemeManager.getInstance()
-        mgr.connect('theme-changed', self.__sync_theme)
-        self.__sync_theme(mgr)
-        
-    def get_theme(self):
-        return ThemeManager.getInstance().get_theme()
-    
-    def _on_theme_changed(self, theme):
-        pass
-
-    def __sync_theme(self, tm):
-        theme = tm.get_theme()
-        self._on_theme_changed(theme)             
-        
 class CanvasCheckbox(hippo.CanvasWidget):
     def __init__(self, label):
         super(CanvasCheckbox, self).__init__()

Modified: trunk/bigboard/core/panel.py
==============================================================================
--- trunk/bigboard/core/panel.py	(original)
+++ trunk/bigboard/core/panel.py	Tue Jun 24 18:59:29 2008
@@ -7,12 +7,13 @@
 import gtk
 import hippo
 
-from bigboard.big_widgets import Button, Header, Sidebar, ThemeManager
+from bigboard.big_widgets import Button, Header, Sidebar
 from bigboard.globals import BUS_NAME_STR, GCONF_PREFIX
 from bigboard.libbig.gutil import *
 import bigboard.keybinder
 from bigboard.libbig.logutil import log_except
 from bigboard.stock import Stock
+from bigboard.theme_manager import ThemeManager
 
 from exchange import Exchange
 

Modified: trunk/bigboard/stocks/search/SearchStock.py
==============================================================================
--- trunk/bigboard/stocks/search/SearchStock.py	(original)
+++ trunk/bigboard/stocks/search/SearchStock.py	Tue Jun 24 18:59:29 2008
@@ -8,7 +8,7 @@
 from bigboard.libbig.imagecache import URLImageCache
 from bigboard.libbig.http import AsyncHTTPFetcher
 from bigboard.stock import Stock
-from bigboard.big_widgets import CanvasMugshotURLImage, CanvasVBox, ThemeManager, ThemeManager, BigWindow
+from bigboard.big_widgets import CanvasMugshotURLImage, CanvasVBox, BigWindow
 import bigboard.search as search
 
 if __name__ == '__main__':
@@ -26,8 +26,7 @@
     }
     def __init__(self, *args, **kwargs):
         gtk.CellRendererText.__init__(self, *args, **kwargs)
-        self.__tm = ThemeManager.getInstance()
-        self.__theme_part = False
+        self.__theme_part = None
         
     def do_render(self, window, widget, background_area, cell_area, expose_area, flags):
         if self.__theme_part:
@@ -58,8 +57,7 @@
     }
     def __init__(self, *args, **kwargs):
         gtk.CellRendererPixbuf.__init__(self, *args, **kwargs)
-        self.__tm = ThemeManager.getInstance()
-        self.__theme_part = False
+        self.__theme_part = None
         
     def do_render(self, window, widget, background_area, cell_area, expose_area, flags):
         if self.__theme_part:
@@ -137,8 +135,6 @@
         self.__view = gtk.TreeView(self.__store)
         self.__view.set_headers_visible(False)
         
-        self.__tm = ThemeManager.getInstance()
-        
         self.__view.insert_column_with_data_func(-1, '',
                                                  ThemedPixbufRenderer(),
                                                  self.__render_icon)

Added: trunk/bigboard/theme_manager.py
==============================================================================
--- (empty file)
+++ trunk/bigboard/theme_manager.py	Tue Jun 24 18:59:29 2008
@@ -0,0 +1,84 @@
+import logging
+import re
+import weakref
+
+import gconf
+import gobject
+import hippo
+
+from bigboard.globals import GCONF_PREFIX
+from bigboard.libbig.logutil import log_except
+
+_logger = logging.getLogger("bigboard.ThemeManager")
+
+class ThemeManager(gobject.GObject):
+    __gsignals__ = {
+                    'theme-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+                   }
+    def __init__(self):
+        super(ThemeManager, self).__init__()
+        self.__class__.instance = weakref.ref(self)
+        self.__default_theme = None
+        self.__theme = None
+        gconf.client_get_default().notify_add(GCONF_PREFIX + 'theme', self.__sync_theme)
+        self.__sync_theme()
+        
+    @staticmethod
+    def getInstance():
+        needinst = False
+        if not hasattr(ThemeManager, 'instance'):
+            instvalue = None
+        else:
+            instref = getattr(ThemeManager, 'instance')
+            instvalue = instref()
+            needinst = instvalue is None
+        if instvalue is None:
+            inst = ThemeManager()
+        else:
+            inst = instvalue
+        return inst
+
+    def __make_theme(self, themename):
+        is_default = False
+        if themename == 'Fedora':
+            import bigboard.themes.fedora as package
+        else:
+            if self.__default_theme != None:
+                return self.__default_theme
+            
+            import bigboard.themes.default as package
+            is_default = True
+
+        theme_engine = package.getInstance()
+        stylesheet_name = re.sub(r"__init__.pyc?$", "theme.css", package.__file__)
+
+        theme = hippo.CanvasTheme(theme_engine = theme_engine, theme_stylesheet = stylesheet_name)
+        if is_default and self.__default_theme == None:
+            self.__default_theme = theme
+
+        return theme
+
+    def make_stock_theme(self, application_stylesheet, default=False):
+        if default:
+            theme = self.get_default_theme()
+        else:
+            theme = self.get_theme()
+
+        return hippo.CanvasTheme(theme_engine = theme.props.theme_engine,
+                                 theme_stylesheet = theme.props.theme_stylesheet,
+                                 application_stylesheet = application_stylesheet)
+        
+    def get_theme(self):
+        return self.__theme
+
+    def get_default_theme(self):
+        return self.__make_theme('default')
+        
+    @log_except(_logger)
+    def __sync_theme(self, *args):
+        themename = gconf.client_get_default().get_string(GCONF_PREFIX + 'theme')
+        _logger.debug("doing theme sync: <THEMENAME>%r</THEMENAME>", themename)
+        
+        self.__theme = self.__make_theme(themename)
+        self.emit('theme-changed')            
+         



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]