Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TurtleArt/taconstants.py2
-rw-r--r--TurtleArt/tapalette.py47
-rw-r--r--TurtleArt/tawindow.py69
-rw-r--r--TurtleArtActivity.py140
-rw-r--r--images/palettehshift.svg86
-rw-r--r--images/palettevshift.svg86
-rw-r--r--util/helpbutton.py71
7 files changed, 432 insertions, 69 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index 6bbaf69..0cfb242 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#Copyright (c) 2010-11 Walter Bender
+#Copyright (c) 2010-12 Walter Bender
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
diff --git a/TurtleArt/tapalette.py b/TurtleArt/tapalette.py
index 86a3bda..7678f7e 100644
--- a/TurtleArt/tapalette.py
+++ b/TurtleArt/tapalette.py
@@ -86,6 +86,8 @@ from sugar.graphics import style
from taconstants import EXPANDABLE_STYLE
from tautils import debug_output
+from util.helpbutton import add_section, add_paragraph
+
from gettext import gettext as _
help_strings = {
@@ -150,49 +152,11 @@ class Palette():
else:
help_strings[self._name] = ''
- def add_section(self, section_text, icon=None):
- ''' Add a section to the help palette. From helpbutton.py by
- Gonzalo Odiard '''
- hbox = gtk.HBox()
- label = gtk.Label()
- label.set_use_markup(True)
- label.set_markup('<b>%s</b>' % section_text)
- label.set_line_wrap(True)
- label.set_size_request(self._max_text_width, -1)
- hbox.add(label)
- if icon is not None:
- _icon = Icon(icon_name=icon)
- hbox.add(_icon)
- label.set_size_request(self._max_text_width - 20, -1)
- else:
- label.set_size_request(self._max_text_width, -1)
-
- hbox.show_all()
- self._help_box.pack_start(hbox, False, False, padding=5)
-
- def add_paragraph(self, text, icon=None):
- ''' Add an entry to the help palette. From helpbutton.py by
- Gonzalo Odiard '''
- hbox = gtk.HBox()
- label = gtk.Label(text)
- label.set_justify(gtk.JUSTIFY_LEFT)
- label.set_line_wrap(True)
- hbox.add(label)
- if icon is not None:
- _icon = Icon(icon_name=icon)
- hbox.add(_icon)
- label.set_size_request(self._max_text_width - 20, -1)
- else:
- label.set_size_request(self._max_text_width, -1)
-
- hbox.show_all()
- self._help_box.pack_start(hbox, False, False, padding=5)
-
def set_help(self, help):
if self._help is None:
self._help = help
if hasattr(self, '_help_box'):
- self.add_section(self._help, icon=self._name + 'off')
+ add_section(self._help_box, self._help, icon=self._name + 'off')
def set_special_name(self, name):
self._special_name = name
@@ -229,9 +193,10 @@ class Palette():
else:
first_arg = special_name
if first_arg is None or first_arg == '' or first_arg == ' ':
- self.add_paragraph('%s' % (help_string))
+ add_paragraph(self._help_box, '%s' % (help_string))
else:
- self.add_paragraph('%s: %s' % (first_arg, help_string))
+ add_paragraph(self._help_box, '%s: %s' % (first_arg,
+ help_string))
if colors is not None:
block.set_colors(colors)
block.set_value_block(value_block)
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 499eefb..e28984b 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -630,6 +630,7 @@ class TurtleArtWindow():
self.show_toolbar_palette(n)
self.palette_button[self.orientation].set_layer(TAB_LAYER)
self.palette_button[2].set_layer(TAB_LAYER)
+ self._display_palette_shift_button(n)
if self.activity is None or not self.activity.has_toolbarbox:
self.toolbar_spr.set_layer(CATEGORY_LAYER)
self.palette = True
@@ -639,6 +640,8 @@ class TurtleArtWindow():
self._hide_toolbar_palette()
self.palette_button[self.orientation].hide()
self.palette_button[2].hide()
+ self.palette_button[3].hide()
+ self.palette_button[4].hide()
if self.activity is None or not self.activity.has_toolbarbox:
self.toolbar_spr.hide()
self.palette = False
@@ -716,6 +719,25 @@ class TurtleArtWindow():
if blk.name in BLOCKS_WITH_SKIN:
self._resize_skin(blk)
+ def _shift_toolbar_palette(self, n):
+ ''' Shift blocks on specified palette '''
+ x, y = self.palette_sprs[n][self.orientation].get_xy()
+ w, h = self.palette_sprs[n][self.orientation].get_dimensions()
+ bx, by = self.palettes[n][0].spr.get_xy()
+ if self.orientation == 0:
+ dx = w - self.width
+ dy = 0
+ if bx - x > 0:
+ dx *= -1
+ else:
+ dx = 0
+ dy = h - self.height + ICON_SIZE
+ if by - y > 0:
+ dy *= -1
+ for blk in self.palettes[n]:
+ if blk.get_visibility():
+ blk.spr.move_relative((dx, dy))
+
def show_toolbar_palette(self, n, init_only=False, regenerate=False,
show=True):
""" Show the toolbar palettes, creating them on init_only """
@@ -756,6 +778,7 @@ class TurtleArtWindow():
# Show the palette with the current orientation.
if self.palette_sprs[n][self.orientation] is not None:
self.palette_sprs[n][self.orientation].set_layer(CATEGORY_LAYER)
+ self._display_palette_shift_button(n)
# Create 'proto' blocks for each palette entry
self._create_proto_blocks(n)
@@ -785,6 +808,20 @@ class TurtleArtWindow():
self.selected_palette = save_selected
self.previous_palette = save_previous
+ def _display_palette_shift_button(self, n):
+ ''' Palettes too wide (or tall) for the screen get a shift button '''
+ if self.palette_sprs[n][self.orientation].type == \
+ 'category-shift-horizontal':
+ self.palette_button[3].set_layer(CATEGORY_LAYER)
+ self.palette_button[4].hide()
+ elif self.palette_sprs[n][self.orientation].type == \
+ 'category-shift-vertical':
+ self.palette_button[3].hide()
+ self.palette_button[4].set_layer(CATEGORY_LAYER)
+ else:
+ self.palette_button[3].hide()
+ self.palette_button[4].hide()
+
def _create_the_selectors(self):
''' Create the palette selector buttons: only when running
old-style Sugar toolbars or from GNOME '''
@@ -861,6 +898,21 @@ class TurtleArtWindow():
self.palette_button[2].type = 'palette'
self.palette_button[2].set_layer(TAB_LAYER)
+ # Create the palette shift buttons
+ dims = self.palette_button[0].get_dimensions()
+ self.palette_button.append(Sprite(self.sprite_list, 0,
+ self.toolbar_offset + dims[1], svg_str_to_pixbuf(svg_from_file(
+ "%s/images/palettehshift.svg" % (self.path)))))
+ self.palette_button.append(Sprite(self.sprite_list, dims[0],
+ self.toolbar_offset, svg_str_to_pixbuf(svg_from_file(
+ "%s/images/palettevshift.svg" % (self.path)))))
+ self.palette_button[3].name = _('shift')
+ self.palette_button[4].name = _('shift')
+ self.palette_button[3].type = 'palette'
+ self.palette_button[4].type = 'palette'
+ self.palette_button[3].hide()
+ self.palette_button[4].hide()
+
def _create_proto_blocks(self, n):
''' Create the protoblocks that will populate a palette. '''
# Reload the palette, but reuse the existing blocks
@@ -1048,6 +1100,7 @@ class TurtleArtWindow():
self.palette_button[2].move_relative(
(self.activity.hadj_value, self.activity.vadj_value))
self.palette_sprs[n][self.orientation].set_layer(CATEGORY_LAYER)
+ self._display_palette_shift_button(n)
def _make_palette_spr(self, n, x, y, w, h, regenerate=False):
''' Make the background for the palette. '''
@@ -1063,7 +1116,16 @@ class TurtleArtWindow():
if self.running_sugar and not self.hw in [XO1]:
self.palette_sprs[n][self.orientation].move_relative(
(self.activity.hadj_value, self.activity.vadj_value))
- self.palette_sprs[n][self.orientation].type = 'category'
+ if self.orientation == 0 and w > self.width:
+ debug_output('setting to shiftable horizontal', True)
+ self.palette_sprs[n][self.orientation].type = \
+ 'category-shift-horizontal'
+ elif self.orientation == 1 and h > self.height - ICON_SIZE:
+ debug_output('setting to shiftable vertical', True)
+ self.palette_sprs[n][self.orientation].type = \
+ 'category-shift-vertical'
+ else:
+ self.palette_sprs[n][self.orientation].type = 'category'
if n == palette_names.index('trash'):
svg = SVG()
self.palette_sprs[n][self.orientation].set_shape(
@@ -1186,7 +1248,8 @@ class TurtleArtWindow():
if hasattr(spr, 'type'):
if spr.type == 'selector':
self._select_category(spr)
- elif spr.type == 'category':
+ elif spr.type in ['category', 'category-shift-horizontal',
+ 'category-shift-vertical']:
if hide_button_hit(spr, x, y):
self.hideshow_palette(False)
elif spr.type == 'palette':
@@ -1210,6 +1273,8 @@ class TurtleArtWindow():
self.activity.palette_buttons[i].set_icon(
palette_names[i] + 'on')
self.show_palette(i)
+ elif spr.name == _('shift'):
+ self._shift_toolbar_palette(self.selected_palette)
else:
self.orientation = 1 - self.orientation
self.palette_button[self.orientation].set_layer(TAB_LAYER)
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 6d17c63..a6a3ae5 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -40,9 +40,10 @@ except ImportError:
HAS_TOOLBARBOX = False
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.radiotoolbutton import RadioToolButton
+from sugar.graphics.alert import ConfirmationAlert
+from sugar.graphics import style
from sugar.datastore import datastore
from sugar import profile
-from sugar.graphics.alert import ConfirmationAlert
import os
import tarfile
@@ -55,7 +56,8 @@ import tempfile
# import TurtleArt.tagettext
from gettext import gettext as _
-from TurtleArt.tapalette import palette_names, help_strings
+from TurtleArt.tapalette import palette_names, help_strings, help_palettes, \
+ help_windows
from TurtleArt.taconstants import ICON_SIZE, BLOCK_SCALE, XO1, XO15, XO175, \
XO30
from TurtleArt.taexporthtml import save_html
@@ -66,7 +68,7 @@ from TurtleArt.tawindow import TurtleArtWindow
from TurtleArt.tacollaboration import Collaboration
if HAS_TOOLBARBOX:
- from util.helpbutton import HelpButton
+ from util.helpbutton import HelpButton, add_section, add_paragraph
class TurtleArtActivity(activity.Activity):
@@ -502,37 +504,39 @@ class TurtleArtActivity(activity.Activity):
def _setup_toolbar(self):
''' Setup toolbar according to Sugar version. '''
if self.has_toolbarbox:
+ self._setup_toolbar_help()
self._toolbox = ToolbarBox()
- activity_toolbar_button = ActivityToolbarButton(self)
+ self.activity_toolbar_button = ActivityToolbarButton(self)
edit_toolbar = gtk.Toolbar()
- edit_toolbar_button = ToolbarButton(label=_('Edit'),
+ self.edit_toolbar_button = ToolbarButton(label=_('Edit'),
page=edit_toolbar,
icon_name='toolbar-edit')
+
view_toolbar = gtk.Toolbar()
- view_toolbar_button = ToolbarButton(label=_('View'),
+ self.view_toolbar_button = ToolbarButton(label=_('View'),
page=view_toolbar,
icon_name='toolbar-view')
self._palette_toolbar = gtk.Toolbar()
- self._palette_toolbar_button = ToolbarButton(
+ self.palette_toolbar_button = ToolbarButton(
page=self._palette_toolbar, icon_name='palette')
- self._help_button = HelpButton()
+ self._help_button = HelpButton(self)
- self._make_load_save_buttons(activity_toolbar_button)
+ self._make_load_save_buttons(self.activity_toolbar_button)
- activity_toolbar_button.show()
- self._toolbox.toolbar.insert(activity_toolbar_button, -1)
- edit_toolbar_button.show()
- self._toolbox.toolbar.insert(edit_toolbar_button, -1)
- view_toolbar_button.show()
- self._toolbox.toolbar.insert(view_toolbar_button, -1)
- self._palette_toolbar_button.show()
- self._toolbox.toolbar.insert(self._palette_toolbar_button, -1)
+ self.activity_toolbar_button.show()
+ self._toolbox.toolbar.insert(self.activity_toolbar_button, -1)
+ self.edit_toolbar_button.show()
+ self._toolbox.toolbar.insert(self.edit_toolbar_button, -1)
+ self.view_toolbar_button.show()
+ self._toolbox.toolbar.insert(self.view_toolbar_button, -1)
+ self.palette_toolbar_button.show()
+ self._toolbox.toolbar.insert(self.palette_toolbar_button, -1)
self.set_toolbar_box(self._toolbox)
- self._palette_toolbar_button.set_expanded(True)
+ self.palette_toolbar_button.set_expanded(True)
else:
self._toolbox = activity.ActivityToolbox(self)
self.set_toolbox(self._toolbox)
@@ -612,6 +616,106 @@ class TurtleArtActivity(activity.Activity):
self._toolbox.toolbar.insert(stop_button, -1)
stop_button.show()
+ def _setup_toolbar_help(self):
+ ''' Set up a help palette for the main toolbars '''
+ help_box = gtk.VBox()
+ help_box.set_homogeneous(False)
+ help_palettes['main-toolbar'] = help_box
+ help_windows['main-toolbar'] = gtk.ScrolledWindow()
+ help_windows['main-toolbar'].set_size_request(
+ int(gtk.gdk.screen_width() / 3),
+ gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3)
+ help_windows['main-toolbar'].set_policy(
+ gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ help_windows['main-toolbar'].add_with_viewport(
+ help_palettes['main-toolbar'])
+ help_palettes['main-toolbar'].show()
+
+ add_section(help_box, _('Save/Load'), icon='turtleoff')
+ add_section(help_box, _('Edit'), icon='toolbar-edit')
+ add_section(help_box, _('View'), icon='toolbar-view')
+ add_section(help_box, _('Project'), icon='palette')
+ add_paragraph(help_box, _('Clean'), icon='eraseron')
+ add_paragraph(help_box, _('Run'), icon='run-fastoff')
+ add_paragraph(help_box, _('Step'), icon='run-slowoff')
+ add_paragraph(help_box, _('Debug'), icon='debugoff')
+ add_paragraph(help_box, _('Stop turtle'), icon='stopitoff')
+ add_paragraph(help_box, _('Load example'), icon='ta-open')
+ add_paragraph(help_box, _('Help'), icon='help-toolbar')
+ add_paragraph(help_box, _('Stop'), icon='activity-stop')
+
+ help_box = gtk.VBox()
+ help_box.set_homogeneous(False)
+ help_palettes['activity-toolbar'] = help_box
+ help_windows['activity-toolbar'] = gtk.ScrolledWindow()
+ help_windows['activity-toolbar'].set_size_request(
+ int(gtk.gdk.screen_width() / 3),
+ gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3)
+ help_windows['activity-toolbar'].set_policy(
+ gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ help_windows['activity-toolbar'].add_with_viewport(
+ help_palettes['activity-toolbar'])
+ help_palettes['activity-toolbar'].show()
+
+ if gtk.gdk.screen_width() < 1200:
+ add_paragraph(help_box, _('Save/Load'), icon='save-load')
+ else:
+ add_section(help_box, _('Save/Load'), icon='turtleoff')
+ add_paragraph(help_box, _('Save as image'), icon='image-saveoff')
+ add_paragraph(help_box, _('Save as HTML'), icon='htmloff')
+ add_paragraph(help_box, _('Save as Logo'), icon='logo-saveoff')
+ add_paragraph(help_box, _('Save snapshot'), icon='filesaveoff')
+ add_paragraph(help_box, _('Load project'), icon='load-from-journal')
+ home = os.environ['HOME']
+ if activity.get_bundle_path()[0:len(home)] == home:
+ add_paragraph(help_box, _('Load plugin'), icon='pluginoff')
+ add_paragraph(help_box, _('Load Python block'),
+ icon='pippy-openoff')
+
+ help_box = gtk.VBox()
+ help_box.set_homogeneous(False)
+ help_palettes['edit-toolbar'] = help_box
+ help_windows['edit-toolbar'] = gtk.ScrolledWindow()
+ help_windows['edit-toolbar'].set_size_request(
+ int(gtk.gdk.screen_width() / 3),
+ gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3)
+ help_windows['edit-toolbar'].set_policy(
+ gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ help_windows['edit-toolbar'].add_with_viewport(
+ help_palettes['edit-toolbar'])
+ help_palettes['edit-toolbar'].show()
+
+ add_section(help_box, _('Edit'), icon='toolbar-edit')
+ add_paragraph(help_box, _('Copy'), icon='edit-copy')
+ add_paragraph(help_box, _('Paste'), icon='edit-paste')
+
+ help_box = gtk.VBox()
+ help_box.set_homogeneous(False)
+ help_palettes['view-toolbar'] = help_box
+ help_windows['view-toolbar'] = gtk.ScrolledWindow()
+ help_windows['view-toolbar'].set_size_request(
+ int(gtk.gdk.screen_width() / 3),
+ gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3)
+ help_windows['view-toolbar'].set_policy(
+ gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ help_windows['view-toolbar'].add_with_viewport(
+ help_palettes['view-toolbar'])
+ help_palettes['view-toolbar'].show()
+
+ add_section(help_box, _('View'), icon='toolbar-view')
+ add_paragraph(help_box, _('Fullscreen'), icon='view-fullscreen')
+ add_paragraph(help_box, _('Cartesian coordinates'),
+ icon='view-Cartesian')
+ add_paragraph(help_box, _('Polar coordinates'), icon='view-polar')
+ if get_hardware() in [XO1, XO15, XO175]:
+ add_paragraph(help_box, _('Metric coordinates'),
+ icon='view-metric')
+ add_paragraph(help_box, _('Rescale coordinates up'),
+ icon='expand-coordinates')
+ add_paragraph(help_box, _('Grow blocks'), icon='resize+')
+ add_paragraph(help_box, _('Shrink blocks'), icon='resize-')
+ add_paragraph(help_box, _('Turn off hover help'), icon='help-off')
+
def _setup_palette_toolbar(self):
''' The palette toolbar must be setup *after* plugins are loaded. '''
if self.has_toolbarbox:
diff --git a/images/palettehshift.svg b/images/palettehshift.svg
new file mode 100644
index 0000000..38158aa
--- /dev/null
+++ b/images/palettehshift.svg
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="16"
+ height="16"
+ id="svg2">
+ <metadata
+ id="metadata8">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs9">
+ <linearGradient
+ x1="0"
+ y1="17.200001"
+ x2="37"
+ y2="17.200001"
+ id="linearGradient5678"
+ xlink:href="#linearGradient1234"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ id="linearGradient1234">
+ <stop
+ id="stop3087"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3089"
+ style="stop-color:#a0ff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ </defs>
+ <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:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <g
+ transform="matrix(0,-1.3333333,1.3333333,0,-2.6666664,18.666666)"
+ id="g3924">
+ <path
+ d="m 8,4 0,8"
+ id="path3106"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ <g
+ transform="translate(0.0303029,-0.060606)"
+ id="g3896">
+ <path
+ d="M 7.939394,4.060606 6,6"
+ id="path3108"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ d="M 8,4.060606 9.9393942,6"
+ id="path3108-6"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ <g
+ transform="matrix(1,0,0,-1,0.0303029,16.060606)"
+ id="g3896-4">
+ <path
+ d="M 7.939394,4.060606 6,6"
+ id="path3108-0"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ d="M 8,4.060606 9.9393942,6"
+ id="path3108-6-8"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ </g>
+</svg>
diff --git a/images/palettevshift.svg b/images/palettevshift.svg
new file mode 100644
index 0000000..504272f
--- /dev/null
+++ b/images/palettevshift.svg
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="16"
+ height="16"
+ id="svg2">
+ <metadata
+ id="metadata8">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs9">
+ <linearGradient
+ x1="0"
+ y1="17.200001"
+ x2="37"
+ y2="17.200001"
+ id="linearGradient5678"
+ xlink:href="#linearGradient1234"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ id="linearGradient1234">
+ <stop
+ id="stop3087"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3089"
+ style="stop-color:#a0ff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ </defs>
+ <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:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <g
+ transform="matrix(1.3333333,0,0,1.3333333,-2.6666664,-2.6666664)"
+ id="g3924">
+ <path
+ d="m 8,4 0,8"
+ id="path3106"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ <g
+ transform="translate(0.0303029,-0.060606)"
+ id="g3896">
+ <path
+ d="M 7.939394,4.060606 6,6"
+ id="path3108"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ d="M 8,4.060606 9.9393942,6"
+ id="path3108-6"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ <g
+ transform="matrix(1,0,0,-1,0.0303029,16.060606)"
+ id="g3896-4">
+ <path
+ d="M 7.939394,4.060606 6,6"
+ id="path3108-0"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ d="M 8,4.060606 9.9393942,6"
+ id="path3108-6-8"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ </g>
+</svg>
diff --git a/util/helpbutton.py b/util/helpbutton.py
index 879320e..47a36cd 100644
--- a/util/helpbutton.py
+++ b/util/helpbutton.py
@@ -24,6 +24,8 @@ from gettext import gettext as _
import gtk
from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.icon import Icon
+from sugar.graphics import style
from TurtleArt.tapalette import palette_names, help_windows
@@ -33,7 +35,8 @@ _logger = logging.getLogger('turtleart-activity')
class HelpButton(gtk.ToolItem):
- def __init__(self, **kwargs):
+ def __init__(self, activity):
+ self._activity = activity
self._current_palette = 'turtle'
gtk.ToolItem.__init__(self)
@@ -48,14 +51,68 @@ class HelpButton(gtk.ToolItem):
help_button.connect('clicked', self.__help_button_clicked_cb)
def set_current_palette(self, name):
- _logger.debug(name)
self._current_palette = name
def __help_button_clicked_cb(self, button):
- if not (self._current_palette in help_windows):
- _logger.debug('name %s not found' % (self._current_palette))
- return
- self._palette.set_content(help_windows[self._current_palette])
- help_windows[self._current_palette].show_all()
+ if self._activity.palette_toolbar_button.is_expanded():
+ if not (self._current_palette in help_windows):
+ _logger.debug('name %s not found' % (self._current_palette))
+ return
+ self._palette.set_content(help_windows[self._current_palette])
+ help_windows[self._current_palette].show_all()
+ elif self._activity.edit_toolbar_button.is_expanded():
+ self._palette.set_content(help_windows['edit-toolbar'])
+ help_windows['edit-toolbar'].show_all()
+ elif self._activity.view_toolbar_button.is_expanded():
+ self._palette.set_content(help_windows['view-toolbar'])
+ help_windows['view-toolbar'].show_all()
+ elif self._activity.activity_toolbar_button.is_expanded():
+ self._palette.set_content(help_windows['activity-toolbar'])
+ help_windows['activity-toolbar'].show_all()
+ else:
+ self._palette.set_content(help_windows['main-toolbar'])
+ help_windows['main-toolbar'].show_all()
self._palette.popup(immediate=True, state=1)
+
+
+def add_section(help_box, section_text, icon=None):
+ ''' Add a section to the help palette. From helpbutton.py by
+ Gonzalo Odiard '''
+ max_text_width = int(gtk.gdk.screen_width() / 3) - 20
+ hbox = gtk.HBox()
+ label = gtk.Label()
+ label.set_use_markup(True)
+ label.set_markup('<b>%s</b>' % section_text)
+ label.set_line_wrap(True)
+ label.set_size_request(max_text_width, -1)
+ hbox.add(label)
+ if icon is not None:
+ _icon = Icon(icon_name=icon)
+ hbox.add(_icon)
+ label.set_size_request(max_text_width - 20, -1)
+ else:
+ label.set_size_request(max_text_width, -1)
+
+ hbox.show_all()
+ help_box.pack_start(hbox, False, False, padding=5)
+
+
+def add_paragraph(help_box, text, icon=None):
+ ''' Add an entry to the help palette. From helpbutton.py by
+ Gonzalo Odiard '''
+ max_text_width = int(gtk.gdk.screen_width() / 3) - 20
+ hbox = gtk.HBox()
+ label = gtk.Label(text)
+ label.set_justify(gtk.JUSTIFY_LEFT)
+ label.set_line_wrap(True)
+ hbox.add(label)
+ if icon is not None:
+ _icon = Icon(icon_name=icon)
+ hbox.add(_icon)
+ label.set_size_request(max_text_width - 20, -1)
+ else:
+ label.set_size_request(max_text_width, -1)
+
+ hbox.show_all()
+ help_box.pack_start(hbox, False, False, padding=5)