Actually make theme object a singleton
This commit is contained in:
parent
3b9d3daa3b
commit
4eb5a61276
@ -5,12 +5,12 @@ import goocanvas
|
||||
from sugar.canvas.IconItem import IconItem
|
||||
from sugar.canvas.IconItem import IconColor
|
||||
|
||||
from Theme import Theme
|
||||
import Theme
|
||||
|
||||
class Model(goocanvas.CanvasModelSimple):
|
||||
def __init__(self, data_model):
|
||||
goocanvas.CanvasModelSimple.__init__(self)
|
||||
self._theme = Theme()
|
||||
self._theme = Theme.get_instance()
|
||||
self._theme.connect("theme-changed", self.__theme_changed_cb)
|
||||
|
||||
root = self.get_root_item()
|
||||
|
@ -8,7 +8,7 @@ from sugar.canvas.DonutItem import DonutItem
|
||||
from sugar.canvas.DonutItem import PieceItem
|
||||
from sugar.canvas.DonutItem import PieceIcon
|
||||
|
||||
from Theme import Theme
|
||||
import Theme
|
||||
|
||||
class TasksItem(DonutItem):
|
||||
def __init__(self, shell):
|
||||
@ -43,7 +43,7 @@ class TasksItem(DonutItem):
|
||||
class Background(goocanvas.Group):
|
||||
def __init__(self):
|
||||
goocanvas.Group.__init__(self)
|
||||
self._theme = Theme()
|
||||
self._theme = Theme.get_instance()
|
||||
self._theme.connect("theme-changed", self.__theme_changed_cb)
|
||||
|
||||
color = self._theme.get_home_colors()[1]
|
||||
|
@ -39,3 +39,12 @@ class Theme(gobject.GObject):
|
||||
|
||||
def get_home_colors(self):
|
||||
return self.__colors[self._cur_theme]
|
||||
|
||||
|
||||
# Use this accessor, don't create more than one theme object
|
||||
_theme = None
|
||||
def get_instance():
|
||||
global _theme
|
||||
if not _theme:
|
||||
_theme = Theme()
|
||||
return _theme
|
||||
|
Loading…
Reference in New Issue
Block a user