Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-01-17 19:14:54 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-01-17 19:14:54 (GMT)
commitdf9c25835bdf3aba9c85e45d665917df3d433e17 (patch)
tree27a1af6f846e33b5e99314cb5145268986ef0971 /src
parent36ca4ac6259093b70b290213ee0319154dd8a724 (diff)
Simplify the constants used to identify favorite layouts
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/desktop/favoriteslayout.py10
-rw-r--r--src/jarabe/desktop/favoritesview.py32
2 files changed, 13 insertions, 29 deletions
diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py
index e9cd2b2..a82f6bf 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -98,7 +98,7 @@ class RandomLayout(FavoritesLayout):
icon_name = 'view-freeform'
"""Name of icon used in home view dropdown palette."""
- profile_key = 'random-layout'
+ key = 'random-layout'
"""String used in profile to represent this view."""
# TRANS: label for the freeform layout in the favorites view
@@ -181,7 +181,7 @@ class RingLayout(FavoritesLayout):
__gtype_name__ = 'RingLayout'
icon_name = 'view-radial'
"""Name of icon used in home view dropdown palette."""
- profile_key = 'ring-layout'
+ key = 'ring-layout'
"""String used in profile to represent this view."""
# TRANS: label for the ring layout in the favorites view
palette_name = _('Ring')
@@ -325,7 +325,7 @@ class SunflowerLayout(RingLayout):
icon_name = 'view-spiral'
"""Name of icon used in home view dropdown palette."""
- profile_key = 'spiral-layout'
+ key = 'spiral-layout'
"""String used in profile to represent this view."""
# TRANS: label for the spiral layout in the favorites view
@@ -392,7 +392,7 @@ class BoxLayout(RingLayout):
icon_name = 'view-box'
"""Name of icon used in home view dropdown palette."""
- profile_key = 'box-layout'
+ key = 'box-layout'
"""String used in profile to represent this view."""
# TRANS: label for the box layout in the favorites view
@@ -433,7 +433,7 @@ class TriangleLayout(RingLayout):
icon_name = 'view-triangle'
"""Name of icon used in home view dropdown palette."""
- profile_key = 'triangle-layout'
+ key = 'triangle-layout'
"""String used in profile to represent this view."""
# TRANS: label for the box layout in the favorites view
diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py
index 228d6ac..e4badfb 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -50,17 +50,11 @@ _logger = logging.getLogger('FavoritesView')
_ICON_DND_TARGET = ('activity-icon', gtk.TARGET_SAME_WIDGET, 0)
-# enumerate the various layout types we will display in the dropdown palette.
-# add a constant for your layout here, and add it to the LAYOUT_MAP to get
-# it to appear in the palette.
-RING_LAYOUT, BOX_LAYOUT, TRIANGLE_LAYOUT, SUNFLOWER_LAYOUT, RANDOM_LAYOUT = \
- xrange(5)
-
-LAYOUT_MAP = {RING_LAYOUT: favoriteslayout.RingLayout,
- #BOX_LAYOUT: favoriteslayout.BoxLayout,
- #TRIANGLE_LAYOUT: favoriteslayout.TriangleLayout,
- #SUNFLOWER_LAYOUT: favoriteslayout.SunflowerLayout,
- RANDOM_LAYOUT: favoriteslayout.RandomLayout}
+LAYOUT_MAP = {favoriteslayout.RingLayout.key: favoriteslayout.RingLayout,
+ #favoriteslayout.BoxLayout.key: favoriteslayout.BoxLayout,
+ #favoriteslayout.TriangleLayout.key: favoriteslayout.TriangleLayout,
+ #favoriteslayout.SunflowerLayout.key: favoriteslayout.SunflowerLayout,
+ favoriteslayout.RandomLayout.key: favoriteslayout.RandomLayout}
"""Map numeric layout identifiers to uninstantiated subclasses of
`FavoritesLayout` which implement the layouts. Additional information
about the layout can be accessed with fields of the class."""
@@ -667,22 +661,13 @@ class FavoritesSetting(object):
def __init__(self):
client = gconf.client_get_default()
- layout_constant = client.get_string(self._FAVORITES_KEY)
- self._layout = self._convert_layout_constant(layout_constant)
+ self._layout = client.get_string(self._FAVORITES_KEY)
logging.debug('FavoritesSetting layout %r' % (self._layout))
self._mode = None
self.changed = dispatch.Signal()
- def _convert_layout_constant(self, profile_constant):
- for layoutid, layoutclass in LAYOUT_MAP.items():
- if profile_constant == layoutclass.profile_key:
- return layoutid
- logging.warning('Incorrect favorites_layout value: %r' % \
- profile_constant)
- return RING_LAYOUT
-
def get_layout(self):
return self._layout
@@ -691,9 +676,8 @@ class FavoritesSetting(object):
if layout != self._layout:
self._layout = layout
- client = gconf.client_get_default()
- profile_key = LAYOUT_MAP[layout].profile_key
- client.set_string(self._FAVORITES_KEY, profile_key)
+ client = gconf.client_get_default()
+ client.set_string(self._FAVORITES_KEY, layout)
self.changed.send(self)