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.py109
-rw-r--r--TurtleArt/tawindow.py31
-rw-r--r--TurtleArtActivity.py56
-rw-r--r--icons/help-off.svg54
-rw-r--r--icons/help-on.svg57
-rw-r--r--images/help.svg50
-rw-r--r--images/print.svg50
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py36
-rwxr-xr-xturtleart.py14
-rw-r--r--util/helpbutton.py61
11 files changed, 432 insertions, 88 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index 74291fc..efdc1e8 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -143,7 +143,7 @@ OVERLAY_SHAPES = ['Cartesian', 'Cartesian_labeled', 'polar', 'metric']
STATUS_SHAPES = ['status', 'info', 'nostack', 'dupstack', 'noinput',
'emptyheap', 'emptybox', 'nomedia', 'nocode', 'overflowerror',
'negroot', 'syntaxerror', 'nofile', 'nojournal', 'zerodivide',
- 'notanumber', 'incompatible']
+ 'notanumber', 'incompatible', 'help']
#
# Emulate Sugar toolbar when running from outside of Sugar
diff --git a/TurtleArt/tapalette.py b/TurtleArt/tapalette.py
index be9d999..da80386 100644
--- a/TurtleArt/tapalette.py
+++ b/TurtleArt/tapalette.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-#Copyright (c) 2011 Walter Bender
+#Copyright (c) 2011,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
@@ -19,6 +19,8 @@
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.
+help_palettes = {}
+help_windows = {}
palette_names = []
palette_blocks = []
block_colors = []
@@ -75,6 +77,12 @@ block_styles = {'basic-style': [],
'portfolio-style-2x1': [],
'portfolio-style-1x2': []}
+
+import gtk
+
+from sugar.graphics.icon import Icon
+from sugar.graphics import style
+
from taconstants import EXPANDABLE_STYLE
from tautils import debug_output
@@ -94,10 +102,25 @@ class Palette():
self._special_name = _(name)
self._colors = colors
self._help = None
+ self._max_text_width = int(gtk.gdk.screen_width() / 3) - 20
- '''
- self._fd = open('/home/walter/Desktop/turtleblocks/doc/%s-palette.page' % (name), 'a')
- '''
+ # Prepare a vbox for the help palette
+ if not (self._name in help_palettes):
+ self._help_box = gtk.VBox()
+ self._help_box.set_homogeneous(False)
+ help_palettes[self._name] = self._help_box
+ else:
+ self._help_box = help_palettes[self._name]
+
+ help_windows[self._name] = gtk.ScrolledWindow()
+ help_windows[self._name].set_size_request(
+ int(gtk.gdk.screen_width() / 3),
+ gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3)
+ help_windows[self._name].set_policy(
+ gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ help_windows[self._name].add_with_viewport(
+ help_palettes[self._name])
+ help_palettes[self._name].show()
def add_palette(self, position=None):
if self._name is None:
@@ -117,28 +140,6 @@ class Palette():
palette_names.insert(i, self._name)
palette_blocks.insert(i, [])
block_colors.insert(i, self._colors)
-
- '''
- self._fd.write('<page xmlns="http://projectmallard.org/1.0/"\n\
- type="guide"\n\
- id="%s-palette"\n\
- xmlns:its="http://www.w3.org/2005/11/its"\n\
- its:version="1.0">\n\
-<info>\n\
- <link type="guide" xref="index"/>\n\
- <link type="topic" xref="palettes"/>\n\
- <its:rules version="1.0">\n\
- <its:translateRule selector="//path | //cmd" translate="no"/>\n\
- </its:rules>\n\
-</info>\n\
-<title>The %s Palette</title>\n\
-<p>\n\
-%s\n\
-</p>\n\
-<terms>\n\
-' % (self._name, self._name, self._help))
- '''
-
else:
# debug_output('Palette %s already defined' % (self._name))
return
@@ -150,8 +151,48 @@ 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):
self._help = help
+ if hasattr(self, '_help_box'):
+ self.add_section(self._help, icon=self._name + 'off')
def set_special_name(self, name):
self._special_name = name
@@ -178,6 +219,14 @@ class Palette():
block.set_logo_command(logo_command)
if help_string is not None:
block.set_help(help_string)
+ if not hidden:
+ if special_name is None:
+ if type(label) == list:
+ self.add_paragraph('%s: %s' % (label[0], help_string))
+ else:
+ self.add_paragraph('%s: %s' % (label, help_string))
+ else:
+ self.add_paragraph('%s: %s' % (special_name, help_string))
if colors is not None:
block.set_colors(colors)
block.set_value_block(value_block)
@@ -187,14 +236,6 @@ class Palette():
block.set_hidden()
block.add_block()
- '''
- self._fd.write(' <item>\n\
- <title>%s</title>\n\
- <p>%s</p>\n\
- </item>\n\
-' % (block_name, help_string))
- '''
-
def make_palette(palette_name, colors=None, help_string=None, position=None):
""" Palette helper function """
if colors is None:
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index b324c7b..e5984d2 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -124,6 +124,9 @@ class TurtleArtWindow():
self.height = gtk.gdk.screen_height()
self.rect = gtk.gdk.Rectangle(0, 0, 0, 0)
+ self.no_help = False
+ self.last_label = None
+
self.keypress = ''
self.keyvalue = 0
self.dead_key = ''
@@ -651,6 +654,10 @@ class TurtleArtWindow():
p[0].move((x + p[0].save_xy[0], y + p[0].save_xy[1]))
if p[1] is not None:
p[1].move((x + p[1].save_xy[0], y + p[1].save_xy[1]))
+
+ self.status_spr.move((x + self.status_spr.save_xy[0],
+ y + self.status_spr.save_xy[1]))
+
# To do: set save_xy for blocks in Trash
for blk in self.trash_stack:
for gblk in find_group(blk):
@@ -1729,6 +1736,8 @@ class TurtleArtWindow():
def _do_show_popup(self, block_name):
""" Fetch the help text and display it. """
+ if self.no_help:
+ return 0
if block_name in special_names:
special_block_name = special_names[block_name]
elif block_name in block_names:
@@ -1738,18 +1747,13 @@ class TurtleArtWindow():
else:
special_block_name = _(block_name)
if block_name in help_strings:
- if special_block_name == '':
- label = help_strings[block_name]
- else:
- label = special_block_name + ": " + help_strings[block_name]
+ label = help_strings[block_name]
else:
label = special_block_name
- if self.running_sugar:
- self.activity.hover_help_label.set_text(label)
- self.activity.hover_help_label.show()
- else:
- if self.interactive_mode:
- self.parent.set_title(_("Turtle Art") + " — " + label)
+ if self.last_label == label:
+ return 0
+ self.showlabel('help', label=label)
+ self.last_label = label
return 0
def _buttonrelease_cb(self, win, event):
@@ -3073,7 +3077,12 @@ class TurtleArtWindow():
if shp == 'info':
self.status_spr.move((PALETTE_WIDTH, self.height - 400))
else:
- self.status_spr.move((PALETTE_WIDTH, self.height - 200))
+ # Adjust vertical position based on scrolled window adjustment
+ if self.running_sugar:
+ self.status_spr.move((0, self.height - 200 + \
+ self.activity.sw.get_vadjustment().get_value()))
+ elif self.interactive_mode:
+ self.status_spr.move((0, self.height - 100))
def calc_position(self, template):
""" Relative placement of portfolio objects (deprecated) """
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index fb32fd1..147f199 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -58,6 +58,9 @@ from TurtleArt.tautils import data_to_file, data_to_string, data_from_string, \
from TurtleArt.tawindow import TurtleArtWindow
from TurtleArt.tacollaboration import Collaboration
+if HAS_TOOLBARBOX:
+ from util.helpbutton import HelpButton
+
class TurtleArtActivity(activity.Activity):
''' Activity subclass for Turtle Art '''
@@ -87,7 +90,8 @@ class TurtleArtActivity(activity.Activity):
_logger.debug('_setup_palette_toolbar')
self._setup_palette_toolbar()
self._setup_extra_controls()
- self._setup_help_toolbar()
+ if not self.has_toolbarbox:
+ self._setup_help_toolbar()
_logger.debug('_setup_sharing')
self._setup_sharing()
@@ -258,9 +262,27 @@ class TurtleArtActivity(activity.Activity):
return
if not self.has_toolbarbox:
self.palette_buttons[i].set_icon(palette_names[i] + 'on')
+ else:
+ _logger.debug('setting help button palette to %s' % (palette_names[i]))
+ self._help_button.set_current_palette(palette_names[i])
self.tw.show_palette(n=i)
self.do_showpalette()
+ def _do_hover_help_toggle(self, button):
+ ''' Toggle hover help '''
+ if self.tw.no_help:
+ _logger.debug('turning hover help on')
+ self.tw.no_help = False
+ self._hover_help_toggle.set_icon('help-off')
+ self._hover_help_toggle.set_tooltip(_('Turn off hover help'))
+ else:
+ _logger.debug('turning hover help off')
+ self.tw.no_help = True
+ self.tw.last_label = None
+ self.tw.status_spr.hide()
+ self._hover_help_toggle.set_icon('help-on')
+ self._hover_help_toggle.set_tooltip(_('Turn on hover help'))
+
# These methods are called both from toolbar buttons and blocks.
def do_hidepalette(self):
@@ -484,10 +506,9 @@ class TurtleArtActivity(activity.Activity):
self._palette_toolbar = gtk.Toolbar()
self._palette_toolbar_button = ToolbarButton(
page=self._palette_toolbar, icon_name='palette')
- self._help_toolbar = gtk.Toolbar()
- self._help_toolbar_button = ToolbarButton(label=_('Help'),
- page=self._help_toolbar,
- icon_name='help-toolbar')
+
+
+ self._help_button = HelpButton()
self._make_load_save_buttons(activity_toolbar_button)
@@ -515,8 +536,6 @@ class TurtleArtActivity(activity.Activity):
self._toolbox.add_toolbar(_('Edit'), edit_toolbar)
journal_toolbar = gtk.Toolbar()
self._toolbox.add_toolbar(_('Save/Load'), journal_toolbar)
- self._help_toolbar = gtk.Toolbar()
- self._toolbox.add_toolbar(_('Help'), self._help_toolbar)
self._make_palette_buttons(self._project_toolbar,
palette_button=True)
@@ -549,10 +568,13 @@ class TurtleArtActivity(activity.Activity):
self.resize_down_button = self._add_button(
'resize-', _('Shrink blocks'), self.do_shrink_blocks_cb,
view_toolbar)
+ self._hover_help_toggle = self._add_button(
+ 'help-off', _('Turn off hover help'), self._do_hover_help_toggle,
+ view_toolbar)
+
edit_toolbar.show()
view_toolbar.show()
- self._help_toolbar.show()
self._toolbox.show()
if not self.has_toolbarbox:
@@ -574,28 +596,14 @@ class TurtleArtActivity(activity.Activity):
'ta-open', _('Load example'), self.do_samples_cb,
self._toolbox.toolbar)
- self._help_toolbar_button.show()
- self._toolbox.toolbar.insert(self._help_toolbar_button, -1)
+ self._toolbox.toolbar.insert(self._help_button, -1)
+ self._help_button.show()
stop_button = StopButton(self)
stop_button.props.accelerator = '<Ctrl>Q'
self._toolbox.toolbar.insert(stop_button, -1)
stop_button.show()
- def _setup_help_toolbar(self):
- ''' The help toolbar must be setup we determine what hardware
- is in use. '''
- # FIXME: Temporary work-around gtk problem with XO175
- if get_hardware() not in [XO1, XO15, XO175, XO30] and \
- (gtk.gtk_version[0] > 2 or gtk.gtk_version[1] > 16):
- self.hover_help_label = self._add_label(
- _('Move the cursor over the orange palette for help.'),
- self._help_toolbar, gtk.gdk.screen_width() - 2 * ICON_SIZE)
- else:
- self.hover_help_label = self._add_label(
- _('Move the cursor over the orange palette for help.'),
- self._help_toolbar)
-
def _setup_palette_toolbar(self):
''' The palette toolbar must be setup *after* plugins are loaded. '''
if self.has_toolbarbox:
diff --git a/icons/help-off.svg b/icons/help-off.svg
new file mode 100644
index 0000000..7a038b6
--- /dev/null
+++ b/icons/help-off.svg
@@ -0,0 +1,54 @@
+<?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"
+ version="1.0"
+ width="55"
+ height="55"
+ viewBox="0 0 55 55"
+ id="svg2">
+ <metadata
+ id="metadata11">
+ <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">
+
+</defs>
+ <path
+ d="m 50,27.625 c 0,12.3431 -10.1569,22.5 -22.5,22.5 C 15.1569,50.125 5,39.9681 5,27.625 5,15.2819 15.1569,5.125 27.5,5.125 c 12.3431,0 22.5,10.1569 22.5,22.5 z"
+ id="path3"
+ style="fill:#ffffff" />
+ <path
+ d="m 23.956,27.167 c 0,-1.621 1.8,-1.89 3.645,-2.386 1.8,-0.495 3.6,-1.215 3.6,-3.825 0,-1.98 -1.845,-3.42 -3.734,-3.42 -3.78,0 -4.365,4.455 -7.246,4.455 -1.62,0 -2.745,-1.26 -2.745,-3.24 0,-4.726 5.94,-7.425 9.991,-7.425 5.806,0 10.756,3.6 10.756,9.631 0,4.995 -3.15,7.921 -7.785,9.091 l 0,1.619 c 0,1.801 -1.351,3.105 -3.241,3.105 -2.025,0 -3.24,-1.305 -3.24,-3.105 l 0,-4.5 -0.001,0 z m -0.27,13.77 c 0,-1.935 1.575,-3.51 3.51,-3.51 1.936,0 3.51,1.575 3.51,3.51 0,1.936 -1.574,3.512 -3.51,3.512 -1.935,-10e-4 -3.51,-1.577 -3.51,-3.512 z"
+ id="path5"
+ style="fill:#282828;stroke:#282828;stroke-width:0.25;stroke-miterlimit:4" />
+ <g
+ transform="matrix(0.90000005,0,0,0.90000005,1.5999984,5.2999976)"
+ id="g3850">
+ <rect
+ width="12"
+ height="12"
+ x="40"
+ y="37"
+ id="rect3848"
+ style="fill:#ffffff;fill-opacity:1;stroke:none" />
+ <path
+ d="M 45.999999,33 C 40.475555,33 36,37.478222 36,42.998666 36,48.524 40.475555,53 45.999999,53 c 5.524889,0 10,-4.476 10,-10.001334 0,-5.520444 -4.475555,-9.998666 -10,-9.998666 z m 4.532889,12.515111 c 0.557334,0.558222 0.558667,1.462666 0,2.02 -0.279111,0.279555 -0.644889,0.419111 -1.010666,0.419111 -0.365334,0 -0.730667,-0.139556 -1.008889,-0.417778 l -2.56,-2.560444 -2.56,2.560444 c -0.278667,0.278222 -0.644,0.417778 -1.009334,0.417778 -0.365777,0 -0.732,-0.139556 -1.011111,-0.419111 -0.557333,-0.557334 -0.557333,-1.461778 0.0018,-2.02 L 43.933777,42.956 41.374666,40.396889 c -0.559111,-0.557334 -0.559111,-1.463112 -0.0018,-2.020445 0.557778,-0.557333 1.463111,-0.559555 2.020445,0 l 2.56,2.559556 2.56,-2.559556 c 0.556444,-0.559555 1.461333,-0.557333 2.019555,0 0.558667,0.557333 0.557334,1.463111 0,2.020445 l -2.559111,2.559111 2.559111,2.559111 z"
+ id="path3067"
+ style="fill:#282828;fill-opacity:1;display:inline" />
+ </g>
+</svg>
diff --git a/icons/help-on.svg b/icons/help-on.svg
new file mode 100644
index 0000000..c818f84
--- /dev/null
+++ b/icons/help-on.svg
@@ -0,0 +1,57 @@
+<?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"
+ version="1.0"
+ width="55"
+ height="55"
+ viewBox="0 0 55 55"
+ id="svg2">
+ <metadata
+ id="metadata3971">
+ <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="defs3969" />
+ <path
+ d="m 50,27.625 c 0,12.3431 -10.1569,22.5 -22.5,22.5 C 15.1569,50.125 5,39.9681 5,27.625 5,15.2819 15.1569,5.125 27.5,5.125 c 12.3431,0 22.5,10.1569 22.5,22.5 z"
+ id="path3963"
+ style="fill:#ffffff" />
+ <path
+ d="m 23.956,27.167 c 0,-1.621 1.8,-1.89 3.645,-2.386 1.8,-0.495 3.6,-1.215 3.6,-3.825 0,-1.98 -1.845,-3.42 -3.734,-3.42 -3.78,0 -4.365,4.455 -7.246,4.455 -1.62,0 -2.745,-1.26 -2.745,-3.24 0,-4.726 5.94,-7.425 9.991,-7.425 5.806,0 10.756,3.6 10.756,9.631 0,4.995 -3.15,7.921 -7.785,9.091 l 0,1.619 c 0,1.801 -1.351,3.105 -3.241,3.105 -2.025,0 -3.24,-1.305 -3.24,-3.105 l 0,-4.5 -0.001,0 z m -0.27,13.77 c 0,-1.935 1.575,-3.51 3.51,-3.51 1.936,0 3.51,1.575 3.51,3.51 0,1.936 -1.574,3.512 -3.51,3.512 -1.935,-10e-4 -3.51,-1.577 -3.51,-3.512 z"
+ id="path3965"
+ style="fill:#282828;stroke:#282828;stroke-width:0.25;stroke-miterlimit:4" />
+ <g
+ id="g4559">
+ <rect
+ width="12"
+ height="12"
+ x="37"
+ y="38"
+ id="rect3848"
+ style="fill:#ffffff;fill-opacity:1;stroke:none" />
+ <g
+ transform="matrix(0.4,0,0,0.4,32,33)"
+ id="dialog-ok"
+ style="fill:#282828;fill-opacity:1;display:block">
+ <path
+ d="M 27.498,5 C 15.071,5 5,15.071 5,27.498 5,39.923 15.071,50 27.498,50 39.927,50 50,39.923 50,27.498 50,15.071 39.927,5 27.498,5 z M 41.419,19.886 24.706,40.208 13.789,29.29 c -1.258,-1.254 -1.258,-3.292 -0.003,-4.546 1.254,-1.255 3.292,-1.255 4.547,0 L 24.241,30.648 36.452,15.8 c 1.127,-1.368 3.153,-1.568 4.525,-0.438 1.37,1.127 1.569,3.153 0.442,4.524 z"
+ id="path4021"
+ style="fill:#282828;fill-opacity:1;display:inline" />
+
+</g>
+ </g>
+</svg>
diff --git a/images/help.svg b/images/help.svg
new file mode 100644
index 0000000..3281351
--- /dev/null
+++ b/images/help.svg
@@ -0,0 +1,50 @@
+<?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"
+ version="1.0"
+ width="767"
+ height="38"
+ id="svg2">
+ <metadata
+ id="metadata17">
+ <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="defs27" />
+ <path
+ d="M 15,37.5 C 11.5,37.5 8,35 5.5,32.5 3,30 0.5,26.5 0.5,23 l 0,-8 c 0,-3.25 2.5,-8.5 5,-10.5 2.5,-2 6,-4 9.5,-4 l 736.5,0 c 2.5,0 7,1 10.5,4 3.5,2.75 4.5,7.5 4.5,10.5 l 0,8 c 0,3.5 -2,7 -4.5,9.5 -2.5,2.5 -6.5,5 -10.5,5 L 15,37.5 z"
+ id="path4"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#e0e0e0;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <g
+ transform="translate(656,65.625)"
+ id="g6">
+ <path
+ d="m 79.5,438.5 c 0,4.5 -3.75,8 -8.5,8 -4.5,0 -8.25,-3.5 -8.25,-8 0,-4.5 3.75,-8.25 8.25,-8.25 4.75,0 8.5,3.75 8.5,8.25 l 0,0 z"
+ transform="translate(24,-485)"
+ id="path8"
+ style="fill:#ff4040;fill-opacity:1;fill-rule:nonzero;stroke:#ff4040;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <text
+ id="text10"
+ style="font-size:12px;font-weight:bold;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans">
+ <tspan
+ x="91"
+ y="-42"
+ id="tspan12"
+ style="font-size:12px">X</tspan>
+ </text>
+ </g>
+</svg>
diff --git a/images/print.svg b/images/print.svg
new file mode 100644
index 0000000..9f48a36
--- /dev/null
+++ b/images/print.svg
@@ -0,0 +1,50 @@
+<?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"
+ version="1.0"
+ width="767"
+ height="38"
+ id="svg2">
+ <metadata
+ id="metadata17">
+ <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="defs27" />
+ <path
+ d="M 15,37.5 C 11.5,37.5 8,35 5.5,32.5 3,30 0.5,26.5 0.5,23 l 0,-8 c 0,-3.25 2.5,-8.5 5,-10.5 2.5,-2 6,-4 9.5,-4 l 736.5,0 c 2.5,0 7,1 10.5,4 3.5,2.75 4.5,7.5 4.5,10.5 l 0,8 c 0,3.5 -2,7 -4.5,9.5 -2.5,2.5 -6.5,5 -10.5,5 L 15,37.5 z"
+ id="path4"
+ style="fill:#80ffff;fill-opacity:1;fill-rule:evenodd;stroke:#00e0e0;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <g
+ transform="translate(656,65.625)"
+ id="g6">
+ <path
+ d="m 79.5,438.5 c 0,4.5 -3.75,8 -8.5,8 -4.5,0 -8.25,-3.5 -8.25,-8 0,-4.5 3.75,-8.25 8.25,-8.25 4.75,0 8.5,3.75 8.5,8.25 l 0,0 z"
+ transform="translate(24,-485)"
+ id="path8"
+ style="fill:#ff4040;fill-opacity:1;fill-rule:nonzero;stroke:#ff4040;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <text
+ id="text10"
+ style="font-size:12px;font-weight:bold;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans">
+ <tspan
+ x="91"
+ y="-42"
+ id="tspan12"
+ style="font-size:12px">X</tspan>
+ </text>
+ </g>
+</svg>
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index dfe8356..8052e3a 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -609,6 +609,15 @@ module found in the Journal'))
special_name=_('bottom'),
help_string=_('bottom of a collapsible stack'))
+ palette.add_block('sandwichtop_no_arm_no_label',
+ hidden=True,
+ colors=["#FF0000", "#A00000"],
+ style='collapsible-top-no-arm-no-label',
+ label=[' ', _('click to open')],
+ prim_name='nop',
+ help_string=_('collapsed stack: click to open'))
+
+ # deprecated blocks
palette.add_block('sandwichcollapsed',
hidden=True,
colors=["#FF0000", "#A00000"],
@@ -618,7 +627,6 @@ module found in the Journal'))
help_string=_('bottom block in a collapsed stack: \
click to open'))
- # deprecated blocks
palette.add_block('sandwichtop',
hidden=True,
colors=["#FF0000", "#A00000"],
@@ -637,14 +645,6 @@ click to open'))
prim_name='comment',
help_string=_('top of stack'))
- palette.add_block('sandwichtop_no_arm_no_label',
- hidden=True,
- colors=["#FF0000", "#A00000"],
- style='collapsible-top-no-arm-no-label',
- label=[' ', _('click to open')],
- prim_name='nop',
- help_string=_('top of stack'))
-
def _portfolio_palette(self):
palette = make_palette('portfolio',
@@ -1010,7 +1010,7 @@ bullets'))
if flag and (self.tw.hide or self.tw.step_time == 0):
return
if type(n) == list:
- self.tw.showlabel('status', n)
+ self.tw.showlabel('print', n)
elif type(n) == str or type(n) == unicode:
if n[0:6] == 'media_' and \
n[6:].lower not in media_blocks_dictionary:
@@ -1022,27 +1022,27 @@ bullets'))
except:
debug_output("Couldn't open %s" % (n[6:]),
self.tw.running_sugar)
- self.tw.showlabel('status', dsobject.metadata['title'])
+ self.tw.showlabel('print', dsobject.metadata['title'])
dsobject.destroy()
else:
- self.tw.showlabel('status', n[6:])
+ self.tw.showlabel('print', n[6:])
except IOError:
- self.tw.showlabel('status', n)
+ self.tw.showlabel('print', n)
else:
- self.tw.showlabel('status', n)
+ self.tw.showlabel('print', n)
elif type(n) == int:
- self.tw.showlabel('status', n)
+ self.tw.showlabel('print', n)
else:
- self.tw.showlabel('status',
+ self.tw.showlabel('print',
str(round_int(n)).replace('.', self.tw.decimal_point))
def _prim_printheap(self):
""" Display contents of heap """
heap_as_string = str(self.tw.lc.heap)
if len(heap_as_string) > 80:
- self.tw.showlabel('status', str(self.tw.lc.heap)[0:79] + '…')
+ self.tw.showlabel('print', str(self.tw.lc.heap)[0:79] + '…')
else:
- self.tw.showlabel('status', str(self.tw.lc.heap))
+ self.tw.showlabel('print', str(self.tw.lc.heap))
def _prim_push(self, val):
""" Push value onto FILO """
diff --git a/turtleart.py b/turtleart.py
index c2fbc1f..30a2efc 100755
--- a/turtleart.py
+++ b/turtleart.py
@@ -343,6 +343,10 @@ class TurtleMain():
self._do_resize_cb, 0.667)
MenuBuilder.make_menu_item(menu, _('Reset block size'),
self._do_resize_cb, -1)
+ MenuBuilder.make_menu_item(menu, _('Turn off hover help'),
+ self._do_hover_help_off_cb)
+ MenuBuilder.make_menu_item(menu, _('Turn on hover help'),
+ self._do_hover_help_on_cb)
view_menu = MenuBuilder.make_sub_menu(menu, _('View'))
menu = gtk.Menu()
@@ -498,6 +502,16 @@ class TurtleMain():
self.tw.overlay_shapes['Cartesian_labeled'].set_layer(
OVERLAY_LAYER)
+ def _do_hover_help_on_cb(self, button):
+ ''' Turn hover help on '''
+ self.tw.no_help = False
+
+ def _do_hover_help_off_cb(self, button):
+ ''' Turn hover help off '''
+ self.tw.no_help = True
+ self.tw.last_label = None
+ self.tw.status_spr.hide()
+
def _do_palette_cb(self, widget):
''' Callback to show/hide palette of blocks. '''
self.tw.show_palette(self.i)
diff --git a/util/helpbutton.py b/util/helpbutton.py
new file mode 100644
index 0000000..879320e
--- /dev/null
+++ b/util/helpbutton.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2012, Gonzalo Odiard <godiard@gmail.com>
+# Copyright (C) 2012, Walter Bender <walter@sugarlabs.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+# HelpButton widget
+
+from gettext import gettext as _
+
+import gtk
+
+from sugar.graphics.toolbutton import ToolButton
+
+from TurtleArt.tapalette import palette_names, help_windows
+
+import logging
+_logger = logging.getLogger('turtleart-activity')
+
+
+class HelpButton(gtk.ToolItem):
+
+ def __init__(self, **kwargs):
+ self._current_palette = 'turtle'
+
+ gtk.ToolItem.__init__(self)
+
+ help_button = ToolButton('help-toolbar')
+ help_button.set_tooltip(_('Help'))
+ self.add(help_button)
+ help_button.show()
+
+ self._palette = help_button.get_palette()
+
+ 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()
+
+ self._palette.popup(immediate=True, state=1)