Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/toolbox.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@sugarlabs.org>2011-04-03 21:51:56 (GMT)
committer Gonzalo Odiard <godiard@sugarlabs.org>2011-04-03 21:51:56 (GMT)
commitf8bc7b4f142329b650a88f62749c00337b942a5e (patch)
tree85d3e17b8133724bb92ab07837640f8255eb857e /toolbox.py
parent3131efe5c3198b8279ae15674cb80abf25501333 (diff)
Remove support to old color buttons
Diffstat (limited to 'toolbox.py')
-rw-r--r--toolbox.py116
1 files changed, 35 insertions, 81 deletions
diff --git a/toolbox.py b/toolbox.py
index 0e323c9..bcac9f0 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -75,96 +75,53 @@ from sugar.graphics.radiotoolbutton import RadioToolButton
from sugar.graphics.toggletoolbutton import ToggleToolButton
from sugar.graphics.objectchooser import ObjectChooser
-WITH_COLOR_BUTTON = True
-try:
- from sugar.graphics.colorbutton import ColorToolButton
+from sugar.graphics.colorbutton import ColorToolButton
- ##Class to manage the Fill Color of a Button
- class ButtonFillColor(ColorToolButton):
- def __init__(self, activity):
- ColorToolButton.__init__(self)
- self._activity = activity
- self.connect('notify::color', self._color_button_cb)
+class ButtonFillColor(ColorToolButton):
+ """Class to manage the Fill Color of a Button"""
- def _color_button_cb(self, widget, pspec):
- color = self.get_color()
- self.set_fill_color(color)
-
- def alloc_color(self, color):
- colormap = self._activity.area.get_colormap()
- return colormap.alloc_color(color.red, color.green, color.blue)
-
- def set_fill_color(self, color):
- new_color = self.alloc_color(color)
- self._activity.area.set_fill_color(new_color)
-
- ##Class to manage the Stroke Color of a Button
- class ButtonStrokeColor(ColorToolButton):
-
- def __init__(self, activity):
- ColorToolButton.__init__(self)
- self._activity = activity
- self.connect('notify::color', self._color_button_cb)
-
- def _color_button_cb(self, widget, pspec):
- color = self.get_color()
- self.set_stroke_color(color)
-
- def alloc_color(self, color):
- colormap = self._activity.area.get_colormap()
- return colormap.alloc_color(color.red, color.green, color.blue)
-
- def set_stroke_color(self, color):
- new_color = self.alloc_color(color)
- self._activity.area.set_stroke_color(new_color)
-
-except:
- WITH_COLOR_BUTTON = False
-
- ##Class to manage the Fill Color of a Button
- class ButtonFillColor(gtk.ColorButton):
+ def __init__(self, activity):
+ ColorToolButton.__init__(self)
+ self._activity = activity
+ self.connect('notify::color', self._color_button_cb)
- def __init__(self, activity):
- gtk.ColorButton.__init__(self)
- self._activity = activity
- self.connect('color-set', self._color_button_cb)
+ def _color_button_cb(self, widget, pspec):
+ color = self.get_color()
+ self.set_fill_color(color)
- def _color_button_cb(self, widget):
- color = self.get_color()
- self.set_fill_color(color)
+ def alloc_color(self, color):
+ colormap = self._activity.area.get_colormap()
+ return colormap.alloc_color(color.red, color.green, color.blue)
- def alloc_color(self, color):
- colormap = self._activity.area.get_colormap()
- return colormap.alloc_color(color.red, color.green, color.blue)
+ def set_fill_color(self, color):
+ new_color = self.alloc_color(color)
+ self._activity.area.set_fill_color(new_color)
- def set_fill_color(self, color):
- new_color = self.alloc_color(color)
- self._activity.area.set_fill_color(new_color)
- ##Class to manage the Stroke Color of a Button
- class ButtonStrokeColor(gtk.ColorButton):
+class ButtonStrokeColor(ColorToolButton):
+ """Class to manage the Stroke Color of a Button"""
- def __init__(self, activity):
- gtk.ColorButton.__init__(self)
- self._activity = activity
- self.connect('color-set', self._color_button_cb)
+ def __init__(self, activity):
+ ColorToolButton.__init__(self)
+ self._activity = activity
+ self.connect('notify::color', self._color_button_cb)
- def _color_button_cb(self, widget):
- color = self.get_color()
- self.set_stroke_color(color)
+ def _color_button_cb(self, widget, pspec):
+ color = self.get_color()
+ self.set_stroke_color(color)
- def alloc_color(self, color):
- colormap = self._activity.area.get_colormap()
- return colormap.alloc_color(color.red, color.green, color.blue)
+ def alloc_color(self, color):
+ colormap = self._activity.area.get_colormap()
+ return colormap.alloc_color(color.red, color.green, color.blue)
- def set_stroke_color(self, color):
- new_color = self.alloc_color(color)
- self._activity.area.set_stroke_color(new_color)
+ def set_stroke_color(self, color):
+ new_color = self.alloc_color(color)
+ self._activity.area.set_stroke_color(new_color)
-##Create toolbars for the activity
class Toolbox(ActivityToolbox):
+ """Create toolbars for the activity"""
def __init__(self, activity):
ActivityToolbox.__init__(self, activity)
@@ -360,8 +317,7 @@ class ToolsToolbar(gtk.Toolbar):
self._activity = activity
self._stroke_color = ButtonStrokeColor(activity)
- if WITH_COLOR_BUTTON:
- self._stroke_color.set_icon_name('icon-stroke')
+ self._stroke_color.set_icon_name('icon-stroke')
self._stroke_color.set_title(_('Stroke Color'))
item = gtk.ToolItem()
item.add(self._stroke_color)
@@ -701,16 +657,14 @@ class ShapesToolbar(gtk.Toolbar):
self._activity = activity
self._fill_color = ButtonFillColor(activity)
- if WITH_COLOR_BUTTON:
- self._fill_color.set_icon_name('icon-fill')
+ self._fill_color.set_icon_name('icon-fill')
self._fill_color.set_title(_('Fill Color'))
item = gtk.ToolItem()
item.add(self._fill_color)
self.insert(item, -1)
self._stroke_color = ButtonStrokeColor(activity)
- if WITH_COLOR_BUTTON:
- self._stroke_color.set_icon_name('icon-stroke')
+ self._stroke_color.set_icon_name('icon-stroke')
self._stroke_color.set_title(_('Stroke Color'))
item = gtk.ToolItem()
item.add(self._stroke_color)