Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-02-21 18:31:33 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-02-21 18:31:33 (GMT)
commit411b3936b4afc7d6ce85db938e8e8115506633cc (patch)
treed63fc6f85fc6081ff42f132904d730e7416a438e
parent6688e13e955153924c1919a644ac46e3e3adff6a (diff)
rearranging palette toolbars for Sugar 0.86+
-rw-r--r--TurtleArtActivity.py113
-rw-r--r--icons/paletteoff.svg40
-rw-r--r--icons/paletteon.svg24
-rw-r--r--icons/trashoff.svg (renamed from images/trashoff.svg)0
-rw-r--r--icons/trashon.svg (renamed from images/trashon.svg)0
-rw-r--r--images/palettehorizontal.svg25
-rw-r--r--images/palettevertical.svg26
-rw-r--r--taconstants.py18
-rw-r--r--tawindow.py110
9 files changed, 223 insertions, 133 deletions
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 1363040..52de41a 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -78,7 +78,8 @@ class TurtleArtActivity(activity.Activity):
self._setup_visibility_handler()
- self._setup_toolbar(_new_sugar_system)
+ self.new_sugar_system = _new_sugar_system
+ self._setup_toolbar()
canvas = self._setup_scrolled_window()
@@ -289,19 +290,33 @@ class TurtleArtActivity(activity.Activity):
self.tw.hideshow_palette(False)
self.palette_button.set_icon("paletteon")
self.palette_button.set_tooltip(_('Show palette'))
+ if self.new_sugar_system and self.tw.selected_palette is not None:
+ self.palette_buttons[self.tw.selected_palette].set_icon(
+ PALETTE_NAMES[self.tw.selected_palette]+'off')
else:
self.tw.hideshow_palette(True)
self.palette_button.set_icon("paletteoff")
self.palette_button.set_tooltip(_('Hide palette'))
+ if self.new_sugar_system:
+ self.palette_buttons[0].set_icon(PALETTE_NAMES[0]+'on')
+
+ """ Palette selector buttons """
+ def _do_palette_buttons_cb(self, button, i):
+ if self.tw.selected_palette is not None:
+ if self.tw.selected_palette != i:
+ self.palette_buttons[self.tw.selected_palette].set_icon(
+ PALETTE_NAMES[self.tw.selected_palette]+'off')
+ self.palette_buttons[i].set_icon(PALETTE_NAMES[i]+'on')
+ self.tw.show_palette(i)
+ self.palette_button.set_icon("paletteoff")
+ self.palette_button.set_tooltip(_('Hide palette'))
""" These methods are called both from buttons and palette """
def do_hidepalette(self):
- # print "in do_hidepalette"
self.palette_button.set_icon("paletteon")
self.palette_button.set_tooltip(_('Show palette'))
def do_showpalette(self):
- # print "in do_showpalette"
self.palette_button.set_icon("paletteoff")
self.palette_button.set_tooltip(_('Hide palette'))
@@ -376,11 +391,9 @@ class TurtleArtActivity(activity.Activity):
"""
def recenter(self):
hadj = self.sw.get_hadjustment()
- # print hadj
hadj.set_value(0)
self.sw.set_hadjustment(hadj)
vadj = self.sw.get_vadjustment()
- # print vadj
vadj.set_value(0)
self.sw.set_vadjustment(vadj)
@@ -594,9 +607,9 @@ class TurtleArtActivity(activity.Activity):
"""
Setup toolbar according to Sugar version
"""
- def _setup_toolbar(self, new_sugar_system):
+ def _setup_toolbar(self):
- if new_sugar_system:
+ if self.new_sugar_system:
# Use 0.86 toolbar design
toolbar_box = ToolbarBox()
# Buttons added to the Activity toolbar
@@ -659,12 +672,6 @@ class TurtleArtActivity(activity.Activity):
# The view toolbar
view_toolbar = gtk.Toolbar()
- fullscreen_button = ToolButton('view-fullscreen')
- fullscreen_button.set_tooltip(_("Fullscreen"))
- fullscreen_button.props.accelerator = '<Alt>Enter'
- fullscreen_button.connect('clicked', self._do_fullscreen_cb)
- view_toolbar.insert(fullscreen_button,-1)
- fullscreen_button.show()
self.blocks_button = ToolButton( "hideshowoff" )
self.blocks_button.set_tooltip(_('Hide blocks'))
@@ -674,6 +681,13 @@ class TurtleArtActivity(activity.Activity):
view_toolbar.insert(self.blocks_button, -1)
self.blocks_button.show()
+ fullscreen_button = ToolButton('view-fullscreen')
+ fullscreen_button.set_tooltip(_("Fullscreen"))
+ fullscreen_button.props.accelerator = '<Alt>Enter'
+ fullscreen_button.connect('clicked', self._do_fullscreen_cb)
+ view_toolbar.insert(fullscreen_button,-1)
+ fullscreen_button.show()
+
cartesian_button = ToolButton('view-Cartesian')
cartesian_button.set_tooltip(_("Cartesian coordinates"))
cartesian_button.connect('clicked', self._do_cartesian_cb)
@@ -701,13 +715,6 @@ class TurtleArtActivity(activity.Activity):
view_toolbar.insert(self.coordinates_toolitem,-1)
self.coordinates_toolitem.show()
- view_toolbar_button = ToolbarButton(
- page=view_toolbar,
- icon_name='toolbar-view')
- view_toolbar.show()
- toolbar_box.toolbar.insert(view_toolbar_button, -1)
- view_toolbar_button.show()
-
separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
@@ -734,15 +741,49 @@ class TurtleArtActivity(activity.Activity):
view_toolbar.insert(self.resize_down_button,-1)
self.resize_down_button.show()
- # palette button (blocks)
+ view_toolbar_button = ToolbarButton(
+ page=view_toolbar,
+ icon_name='toolbar-view')
+ view_toolbar.show()
+ toolbar_box.toolbar.insert(view_toolbar_button, -1)
+ view_toolbar_button.show()
+
+ # palette toolbar
+ palette_toolbar = gtk.Toolbar()
+ self.palette_buttons = []
+ for i, name in enumerate(PALETTE_NAMES):
+ if i > 0:
+ self.palette_buttons.append(ToolButton(name+'off'))
+ else:
+ self.palette_buttons.append(ToolButton(name+'on'))
+ self.palette_buttons[i].set_tooltip(HELP_STRINGS[name])
+ self.palette_buttons[i].props.sensitive = True
+ self.palette_buttons[i].connect('clicked',
+ self._do_palette_buttons_cb, i)
+ palette_toolbar.insert(self.palette_buttons[i], -1)
+ self.palette_buttons[i].show()
+
+ separator = gtk.SeparatorToolItem()
+ separator.props.draw = False
+ separator.set_expand(True)
+ palette_toolbar.insert(separator, -1)
+ separator.show()
+
self.palette_button = ToolButton( "paletteoff" )
self.palette_button.set_tooltip(_('Hide palette'))
self.palette_button.props.sensitive = True
self.palette_button.connect('clicked', self._do_palette_cb)
self.palette_button.props.accelerator = _('<Ctrl>p')
- toolbar_box.toolbar.insert(self.palette_button, -1)
+ palette_toolbar.insert(self.palette_button, -1)
self.palette_button.show()
+ palette_toolbar_button = ToolbarButton(
+ page=palette_toolbar,
+ icon_name='paletteoff')
+ palette_toolbar.show()
+ toolbar_box.toolbar.insert(palette_toolbar_button, -1)
+ palette_toolbar_button.show()
+
# eraser button
self.eraser_button = ToolButton( "eraseron" )
self.eraser_button.set_tooltip(_('Clean'))
@@ -937,7 +978,7 @@ class TurtleArtActivity(activity.Activity):
bundle_path = activity.get_bundle_path()
self.tw = TurtleArtWindow(canvas, bundle_path, lang, self,
profile.get_color().to_string())
- self.tw.activity = self
+ # self.tw.activity = self
self.tw.window.grab_focus()
path = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'], 'data')
self.tw.save_folder= path
@@ -1100,6 +1141,19 @@ class ViewToolbar(gtk.Toolbar):
gtk.Toolbar.__init__(self)
self.activity = pc
+ # blocks button (hideshow)
+ self.activity.blocks_button = ToolButton( "hideshowoff" )
+ self.activity.blocks_button.set_tooltip(_('Hide blocks'))
+ self.activity.blocks_button.props.sensitive = True
+ self.activity.blocks_button.connect('clicked', \
+ self.activity._do_hideshow_cb)
+ try:
+ self.activity.blocks_button.props.accelerator = _('<Ctrl>b')
+ except:
+ pass
+ self.insert(self.activity.blocks_button, -1)
+ self.activity.blocks_button.show()
+
# full screen
self.activity.fullscreen_button = ToolButton( "view-fullscreen" )
self.activity.fullscreen_button.set_tooltip(_('Fullscreen'))
@@ -1334,19 +1388,6 @@ class ProjectToolbar(gtk.Toolbar):
self.insert(self.activity.palette_button, -1)
self.activity.palette_button.show()
- # blocks button (hideshow)
- self.activity.blocks_button = ToolButton( "hideshowoff" )
- self.activity.blocks_button.set_tooltip(_('Hide blocks'))
- self.activity.blocks_button.props.sensitive = True
- self.activity.blocks_button.connect('clicked', \
- self.activity._do_hideshow_cb)
- try:
- self.activity.blocks_button.props.accelerator = _('<Ctrl>b')
- except:
- pass
- self.insert(self.activity.blocks_button, -1)
- self.activity.blocks_button.show()
-
separator = gtk.SeparatorToolItem()
separator.set_draw(True)
self.insert(separator, -1)
diff --git a/icons/paletteoff.svg b/icons/paletteoff.svg
index 2d32eef..35efded 100644
--- a/icons/paletteoff.svg
+++ b/icons/paletteoff.svg
@@ -8,19 +8,29 @@
width="45"
height="45"
id="svg2">
- <path
- d="M 0.5,44.5 C 0.75,35.5 0.5,17.5 0.5,17.5 l 44,0 0,27 -44,0 z"
- style="fill:#FFFFFF;fill-opacity:1;stroke:#FFFFFF;stroke-width:1px;stroke-opacity:1" />
- <path
- d="m 30.875,30.999999 c 0,4.62493 -3.74962,8.374182 -8.375,8.374182 -4.62538,0 -8.375,-3.749252 -8.375,-8.374182 0,-4.624929 3.74962,-8.374182 8.375,-8.374182 4.62538,0 8.375,3.749253 8.375,8.374182 l 0,0 z"
- style="fill:#404040;fill-opacity:1;stroke:#404040;stroke-width:1px;stroke-opacity:1" />
- <text
- x="0"
- y="0"
- style="font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans">
- <tspan
- x="18.3"
- y="35"
- style="font-size:12px;font-weight:bold;fill:#FFFFFF">X</tspan>
- </text>
+ <defs
+ id="defs13" />
+ <g
+ transform="translate(0,-8)"
+ id="g2823">
+ <path
+ d="m 0.5,44.5 c 0.25,-9 0,-27 0,-27 l 44,0 0,27 -44,0 z"
+ id="path3"
+ style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1px;stroke-opacity:1" />
+ <path
+ d="m 30.875,30.999999 c 0,4.62493 -3.74962,8.374182 -8.375,8.374182 -4.62538,0 -8.375,-3.749252 -8.375,-8.374182 0,-4.624929 3.74962,-8.374182 8.375,-8.374182 4.62538,0 8.375,3.749253 8.375,8.374182 l 0,0 z"
+ id="path5"
+ style="fill:#404040;fill-opacity:1;stroke:#404040;stroke-width:1px;stroke-opacity:1" />
+ <text
+ x="0"
+ y="0"
+ id="text7"
+ style="font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans">
+ <tspan
+ x="18.299999"
+ y="35"
+ id="tspan9"
+ style="font-size:12px;font-weight:bold;fill:#ffffff">X</tspan>
+ </text>
+ </g>
</svg>
diff --git a/icons/paletteon.svg b/icons/paletteon.svg
index 2ae1eb8..0a1ebf7 100644
--- a/icons/paletteon.svg
+++ b/icons/paletteon.svg
@@ -8,19 +8,25 @@
width="45"
height="45"
id="svg2">
+ <defs
+ id="defs13" />
<path
- d="M 0.5,44.5 C 0.75,35.5 0.5,17.5 0.5,17.5 l 44,0 0,27 -44,0 z"
- style="fill:#FFD000;fill-opacity:1;stroke:#A08000;stroke-width:1px;stroke-opacity:1" />
+ d="m 0.5,36.5 c 0.25,-9 0,-27 0,-27 l 44,0 0,27 -44,0 z"
+ id="path3"
+ style="fill:#ffd000;fill-opacity:1;stroke:#a08000;stroke-width:1px;stroke-opacity:1" />
<path
- d="m 30.875,30.999999 c 0,4.62493 -3.74962,8.374182 -8.375,8.374182 -4.62538,0 -8.375,-3.749252 -8.375,-8.374182 0,-4.624929 3.74962,-8.374182 8.375,-8.374182 4.62538,0 8.375,3.749253 8.375,8.374182 l 0,0 z"
- style="fill:#00FF00;fill-opacity:1;stroke:#00FF00;stroke-width:1px;stroke-opacity:1" />
+ d="m 30.875,22.999999 c 0,4.62493 -3.74962,8.374182 -8.375,8.374182 -4.62538,0 -8.375,-3.749252 -8.375,-8.374182 0,-4.624929 3.74962,-8.374182 8.375,-8.374182 4.62538,0 8.375,3.749253 8.375,8.374182 l 0,0 z"
+ id="path5"
+ style="fill:#00ff00;fill-opacity:1;stroke:#00ff00;stroke-width:1px;stroke-opacity:1" />
<text
- x="0"
- y="0"
+ x="-0.82734299"
+ y="-8"
+ id="text7"
style="font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans">
<tspan
- x="18.3"
- y="35"
- style="font-size:12px;font-weight:bold;fill:#FFFFFF">+</tspan>
+ x="17.472656"
+ y="27"
+ id="tspan9"
+ style="font-size:12px;font-weight:bold;fill:#ffffff">+</tspan>
</text>
</svg>
diff --git a/images/trashoff.svg b/icons/trashoff.svg
index 8ebfb39..8ebfb39 100644
--- a/images/trashoff.svg
+++ b/icons/trashoff.svg
diff --git a/images/trashon.svg b/icons/trashon.svg
index 01e9cd2..01e9cd2 100644
--- a/images/trashon.svg
+++ b/icons/trashon.svg
diff --git a/images/palettehorizontal.svg b/images/palettehorizontal.svg
index 67e7f4b..bd0e0e6 100644
--- a/images/palettehorizontal.svg
+++ b/images/palettehorizontal.svg
@@ -8,15 +8,18 @@
width="16"
height="16"
id="svg2">
-
- <rect style="fill:#FFFFFF;stroke:#FFFFFF;stroke_width=1;"
- width="16"
- height="8"
- x="0"
- y="0"/>
- <rect style="fill:#000000;stroke:#000000;stroke_width=1;"
- width="8"
- height="16"
- x="0"
- y="0"/>
+ <defs
+ id="defs9" />
+ <path
+ d="m 18.983051,7.5932202 a 10.915255,10.169492 0 1 1 -21.8305089,0 10.915255,10.169492 0 1 1 21.8305089,0 z"
+ transform="matrix(0.68421284,0,0,0.73438846,2.4799099,2.4236267)"
+ id="path2819"
+ style="fill:#ffd000;fill-opacity:1;fill-rule:nonzero;stroke:#a08000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <rect
+ width="5.3145914"
+ height="11.314592"
+ x="5.3427043"
+ y="2.3427038"
+ id="rect5"
+ style="fill:#000000;stroke:#000000;stroke-width:0.68540835" />
</svg>
diff --git a/images/palettevertical.svg b/images/palettevertical.svg
index b0e3652..a7c96dd 100644
--- a/images/palettevertical.svg
+++ b/images/palettevertical.svg
@@ -8,15 +8,19 @@
width="16"
height="16"
id="svg2">
-
- <rect style="fill:#FFFFFF;stroke:#FFFFFF;stroke_width=1;"
- width="8"
- height="16"
- x="0"
- y="0"/>
- <rect style="fill:#000000;stroke:#000000;stroke_width=1;"
- width="16"
- height="8"
- x="0"
- y="0"/>
+ <defs
+ id="defs9" />
+ <path
+ d="m 18.983051,7.5932202 a 10.915255,10.169492 0 1 1 -21.8305089,0 10.915255,10.169492 0 1 1 21.8305089,0 z"
+ transform="matrix(0.68421284,0,0,0.73438846,2.4799099,2.4236267)"
+ id="path2819"
+ style="fill:#ffd000;fill-opacity:1;fill-rule:nonzero;stroke:#a08000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <rect
+ width="5.3145914"
+ height="11.314592"
+ x="-10.657295"
+ y="2.3427038"
+ transform="matrix(0,-1,1,0,0,0)"
+ id="rect5"
+ style="fill:#000000;stroke:#000000;stroke-width:0.68540835" />
</svg>
diff --git a/taconstants.py b/taconstants.py
index 1d2e116..0ed4c81 100644
--- a/taconstants.py
+++ b/taconstants.py
@@ -629,7 +629,7 @@ HELP_STRINGS = {
'arc':_("moves turtle along an arc"),
'audio':_("Sugar Journal audio object"),
'back':_("moves turtle backward"),
- 'blocks':_("palette of variable blocks"),
+ 'blocks':_("Palette of variable blocks"),
'bottompos':_("ycor of bottom of screen"),
'box1':_("Variable 1 (numeric value)"),
'box2':_("Variable 2 (numeric value)"),
@@ -638,7 +638,7 @@ HELP_STRINGS = {
'clean':_("clears the screen and reset the turtle"),
'clearheap':_("emptys FILO (first-in-last-out heap)"),
'color':_("holds current pen color (can be used in place of a number block)"),
- 'colors':_("a palette of pen colors"),
+ 'colors':_("Palette of pen colors"),
'comment':_("places a comment in your code"),
'debugoff':_("Debug"),
'description':_("Sugar Journal description field"),
@@ -646,9 +646,9 @@ HELP_STRINGS = {
'empty':_("permanently deletes items in trash"),
'eraseron':_("Clean"),
'equal2':_("logical equal-to operator"),
- 'extras':_("palette of extra options"),
+ 'extras':_("Palette of extra options"),
'fillscreen':_("fills the background with (color, shade)"),
- 'flow':_("palette of flow operators"),
+ 'flow':_("Palette of flow operators"),
'forever':_("loops forever"),
'forward':_("moves turtle forward"),
'fullscreen':_("hides the Sugar toolbars"),
@@ -675,12 +675,12 @@ HELP_STRINGS = {
'myfunc2':_("a programmable block: used to add advanced math equations, e.g., sin(x)"),
'nop':_("runs code found in the tamyblock.py module found in the Journal"),
'not':_("logical NOT operator"),
- 'numbers':_("palette of numeric operators"),
+ 'numbers':_("Palette of numeric operators"),
'number':_("used as numeric input in mathematic operators"),
'or':_("logical OR operator"),
'orientation':_("changes the orientation of the palette of blocks"),
'pendown':_("Turtle will draw when moved."),
- 'pen':_("palette of pen commands"),
+ 'pen':_("Palette of pen commands"),
'pensize':_("holds current pen size (can be used in place of a number block)"),
'penup':_("Turtle will not draw when moved."),
'picture1x1':_("presentation template: select Journal object (with description)"),
@@ -692,7 +692,7 @@ HELP_STRINGS = {
'plus2':_("adds two alphanumeric inputs"),
'polar':_("displays polar coordinates"),
'pop':_("pops value off FILO (first-in last-out heap)"),
- 'portfolio':_("palette of presentation templates"),
+ 'portfolio':_("Palette of presentation templates"),
'print':_("prints value in status block at bottom of the screen"),
'printheap':_("shows values in FILO (first-in last-out heap)"),
'product2':_("multiplies two numeric inputs"),
@@ -739,8 +739,8 @@ HELP_STRINGS = {
'textcolor':_("holds current text color (can be used in place of a number block)"),
'textsize':_("holds current text size (can be used in place of a number block)"),
'toppos':_("ycor of top of screen"),
- 'trash':_("a place to throw away blocks"),
- 'turtle':_("palette of turtle commands"),
+ 'trash':_("Trashcan"),
+ 'turtle':_("Palette of turtle commands"),
'until':_("do-until-True operator that uses boolean operators from Numbers palette"),
'vspace':_("jogs stack down"),
'wait':_("pauses program execution a specified number of seconds"),
diff --git a/tawindow.py b/tawindow.py
index 703c668..ea40f95 100644
--- a/tawindow.py
+++ b/tawindow.py
@@ -105,9 +105,11 @@ class TurtleArtWindow():
if parent is not None:
parent.show_all()
self.running_sugar = True
+ self.activity = parent
else:
self.window.show_all()
self.running_sugar = False
+ self.activity = None
self._setup_events()
self.keypress = ""
self.keyvalue = 0
@@ -145,6 +147,7 @@ class TurtleArtWindow():
self.polar = False
self.overlay_shapes = {}
self.toolbar_shapes = {}
+ self.toolbar_offset = 0
self.status_spr = None
self.status_shapes = {}
self.toolbar_spr = None
@@ -362,6 +365,8 @@ class TurtleArtWindow():
if blk.status != 'collapsed':
blk.spr.set_layer(BLOCK_LAYER)
self.show_palette()
+ if self.activity is not None and self.activity.new_sugar_system:
+ self.activity.palette_buttons[0].set_icon(PALETTE_NAMES[0]+'on')
self.hide = False
self.canvas.canvas.inval()
@@ -386,7 +391,8 @@ class TurtleArtWindow():
def show_palette(self, n=0):
self._show_toolbar_palette(n)
self.palette_button[self.orientation].set_layer(TAB_LAYER)
- self.toolbar_spr.set_layer(CATEGORY_LAYER)
+ if self.activity is None or not self.activity.new_sugar_system:
+ self.toolbar_spr.set_layer(CATEGORY_LAYER)
self.palette = True
"""
@@ -395,7 +401,8 @@ class TurtleArtWindow():
def hide_palette(self):
self._hide_toolbar_palette()
self.palette_button[self.orientation].hide()
- self.toolbar_spr.hide()
+ if self.activity is None or not self.activity.new_sugar_system:
+ self.toolbar_spr.hide()
self.palette = False
"""
@@ -452,8 +459,9 @@ class TurtleArtWindow():
Show the toolbar palettes, creating them on init_only
"""
def _show_toolbar_palette(self, n, init_only=False):
- # Create the selectors the first time through.
- if self.selectors == []:
+ if (self.activity is None or not self.activity.new_sugar_system) and\
+ self.selectors == []:
+ # Create the selectors
svg = SVG()
x, y = 50, 0
for i, name in enumerate(PALETTE_NAMES):
@@ -468,32 +476,39 @@ class TurtleArtWindow():
self.selectors[i].set_layer(TAB_LAYER)
w, h = self.selectors[i].get_dimensions()
x += int(w)
- self.palette_sprs.append([None,None])
- # Create the palette orientation button
- self.palette_button.append(Sprite(self.sprite_list, 0, ICON_SIZE,
- svg_str_to_pixbuf(svg_from_file(
- "%s/images/palettehorizontal.svg" %(self.path)))))
- self.palette_button.append(Sprite(self.sprite_list, 0, ICON_SIZE,
- svg_str_to_pixbuf(svg_from_file(
- "%s/images/palettevertical.svg" % (self.path)))))
- self.palette_button[0].name = 'orientation'
- self.palette_button[1].name = 'orientation'
- self.palette_button[0].type = 'palette'
- self.palette_button[1].type = 'palette'
- self.palette_button[self.orientation].set_layer(TAB_LAYER)
- self.palette_button[1-self.orientation].hide()
# Create the toolbar background
+ self.toolbar_offset = ICON_SIZE
self.toolbar_spr = Sprite(self.sprite_list, 0, 0,
svg_str_to_pixbuf(svg.toolbar(self.width, ICON_SIZE)))
self.toolbar_spr.type = 'toolbar'
self.toolbar_spr.set_layer(CATEGORY_LAYER)
+
+ if self.palette_sprs == []:
# Create the empty palettes
if len(self.palettes) == 0:
for i in range(len(PALETTES)):
self.palettes.append([]);
+ # Create empty palette backgrounds
+ for i in PALETTE_NAMES:
+ self.palette_sprs.append([None,None])
+
+ # Create the palette orientation button
+ self.palette_button.append(Sprite(self.sprite_list, 0,
+ self.toolbar_offset, svg_str_to_pixbuf(svg_from_file(
+ "%s/images/palettehorizontal.svg" %(self.path)))))
+ self.palette_button.append(Sprite(self.sprite_list, 0,
+ self.toolbar_offset, svg_str_to_pixbuf(svg_from_file(
+ "%s/images/palettevertical.svg" % (self.path)))))
+ self.palette_button[0].name = 'orientation'
+ self.palette_button[1].name = 'orientation'
+ self.palette_button[0].type = 'palette'
+ self.palette_button[1].type = 'palette'
+ self.palette_button[self.orientation].set_layer(TAB_LAYER)
+ self.palette_button[1-self.orientation].hide()
+
if init_only:
return
@@ -502,12 +517,13 @@ class TurtleArtWindow():
self.selected_palette = n
self.previous_palette = self.selected_palette
- self.selected_selector = self.selectors[n]
- # Make sure all of the selectors are visible.
- self.selectors[n].set_shape(self.selector_shapes[n][1])
- for i in range(len(PALETTES)):
- self.selectors[i].set_layer(TAB_LAYER)
+ if self.activity is None or not self.activity.new_sugar_system:
+ self.selected_selector = self.selectors[n]
+ # Make sure all of the selectors are visible.
+ self.selectors[n].set_shape(self.selector_shapes[n][1])
+ for i in range(len(PALETTES)):
+ self.selectors[i].set_layer(TAB_LAYER)
# Show the palette with the current orientation.
if self.palette_sprs[n][self.orientation] is not None:
@@ -546,9 +562,13 @@ class TurtleArtWindow():
"""
def _hide_toolbar_palette(self):
self._hide_previous_palette()
- # Hide the selectors
- for i in range(len(PALETTES)):
- self.selectors[i].hide()
+ if self.activity is None or not self.activity.new_sugar_system:
+ # Hide the selectors
+ for i in range(len(PALETTES)):
+ self.selectors[i].hide()
+ elif self.selected_palette is not None:
+ self.activity.palette_buttons[self.selected_palette].set_icon(
+ PALETTE_NAMES[self.selected_palette]+'off')
self.selected_palette = None
self.previous_palette = None
@@ -562,8 +582,13 @@ class TurtleArtWindow():
self.palettes[self.previous_palette][i].spr.hide()
self.palette_sprs[self.previous_palette][
self.orientation].hide()
- self.selectors[self.previous_palette].set_shape(
- self.selector_shapes[self.previous_palette][0])
+ if self.activity is None or not self.activity.new_sugar_system:
+ self.selectors[self.previous_palette].set_shape(
+ self.selector_shapes[self.previous_palette][0])
+ elif self.previous_palette is not None and\
+ self.previous_palette != self.selected_palette:
+ self.activity.palette_buttons[self.previous_palette].set_icon(
+ PALETTE_NAMES[self.previous_palette]+'off')
if self.previous_palette == PALETTE_NAMES.index('trash'):
for b in self.trash_stack:
for bb in self._find_group(b):
@@ -576,9 +601,9 @@ class TurtleArtWindow():
_max_w = 0
for b in blocks:
_w, _h = self._width_and_height(b)
- if y+_h > PALETTE_HEIGHT+ICON_SIZE:
+ if y+_h > PALETTE_HEIGHT+self.toolbar_offset:
x += int(_max_w+3)
- y = ICON_SIZE+3
+ y = self.toolbar_offset+3
_max_w = 0
(_bx, _by) = b.spr.get_xy()
_dx = x-_bx
@@ -633,7 +658,7 @@ class TurtleArtWindow():
def _layout_palette(self, n):
if n is not None:
if self.orientation == 0:
- _x, _y = 20, ICON_SIZE+5
+ _x, _y = 20, self.toolbar_offset+5
_x, _y, _max = self._horizontal_layout(_x, _y, self.palettes[n])
if n == PALETTE_NAMES.index('trash'):
_x, _y, _max = self._horizontal_layout(_x+_max, _y,
@@ -642,7 +667,7 @@ class TurtleArtWindow():
if self.palette_sprs[n][self.orientation] is None:
svg = SVG()
self.palette_sprs[n][self.orientation] = Sprite(
- self.sprite_list, 0, ICON_SIZE,
+ self.sprite_list, 0, self.toolbar_offset,
svg_str_to_pixbuf(svg.palette(_w, PALETTE_HEIGHT)))
self.palette_sprs[n][self.orientation].type = 'category'
if n == PALETTE_NAMES.index('trash'):
@@ -650,7 +675,7 @@ class TurtleArtWindow():
self.palette_sprs[n][self.orientation].set_shape(
svg_str_to_pixbuf(svg.palette(_w, PALETTE_HEIGHT)))
else:
- _x, _y = 5, ICON_SIZE+15
+ _x, _y = 5, self.toolbar_offset+15
_x, _y, _max = self._vertical_layout(_x, _y, self.palettes[n])
if n == PALETTE_NAMES.index('trash'):
_x, _y, _max = self._vertical_layout(_x, _y+_max,
@@ -659,7 +684,7 @@ class TurtleArtWindow():
if self.palette_sprs[n][self.orientation] is None:
svg = SVG()
self.palette_sprs[n][self.orientation] =\
- Sprite(self.sprite_list, 0, ICON_SIZE,
+ Sprite(self.sprite_list, 0, self.toolbar_offset,
svg_str_to_pixbuf(svg.palette(PALETTE_WIDTH, _h)))
self.palette_sprs[n][self.orientation].type = 'category'
if n == PALETTE_NAMES.index('trash'):
@@ -757,7 +782,7 @@ class TurtleArtWindow():
return True
"""
- Select a category from the toolbar.
+ Select a category from the toolbar (Not used in new Sugar systems).
"""
def _select_category(self, spr):
i = self.selectors.index(spr)
@@ -822,7 +847,6 @@ class TurtleArtWindow():
for b in group:
if b.name in BLOCKS_WITH_SKIN:
self._resize_skin(b)
-
self.show_palette(PALETTE_NAMES.index('trash'))
"""
@@ -848,7 +872,7 @@ class TurtleArtWindow():
b.spr.set_layer(BLOCK_LAYER)
x,y = b.spr.get_xy()
if self.orientation == 0:
- b.spr.move((x,y+PALETTE_HEIGHT+ICON_SIZE))
+ b.spr.move((x,y+PALETTE_HEIGHT+self.toolbar_offset))
else:
b.spr.move((x+PALETTE_WIDTH,y))
b.type = 'block'
@@ -1149,10 +1173,11 @@ class TurtleArtWindow():
w, h = self.palette_sprs[self.selected_palette][
self.orientation].get_dimensions()
if self.orientation == 0:
- if bx < w and by+dy < ICON_SIZE+PALETTE_HEIGHT:
- dy += -(by+dy)+ICON_SIZE+PALETTE_HEIGHT
+ if bx < w and\
+ by+dy < self.toolbar_offset+PALETTE_HEIGHT:
+ dy += -(by+dy)+self.toolbar_offset+PALETTE_HEIGHT
else:
- if by < h+ICON_SIZE and bx+dx < PALETTE_WIDTH:
+ if by < h+self.toolbar_offset and bx+dx < PALETTE_WIDTH:
dx += -(bx+dx)+PALETTE_WIDTH
# Move the stack.
@@ -1278,7 +1303,7 @@ class TurtleArtWindow():
for b in self.drag_group:
(bx, by) = b.spr.get_xy()
if self.orientation == 0:
- b.spr.move((bx+20, by+PALETTE_HEIGHT+ICON_SIZE))
+ b.spr.move((bx+20, by+PALETTE_HEIGHT+self.toolbar_offset))
else:
b.spr.move((bx+PALETTE_WIDTH, by+20))
@@ -2347,7 +2372,8 @@ class TurtleArtWindow():
"""
def load_start(self):
top = self.process_data([[0, "start", PALETTE_WIDTH+20,
- ICON_SIZE+PALETTE_HEIGHT+20, [None, None]]])
+ self.toolbar_offset+PALETTE_HEIGHT+20,
+ [None, None]]])
"""
Start a project to a file