diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-03-28 19:52:55 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-03-28 19:52:55 (GMT) |
commit | 9b13d372bddbb203c0f6801f6548ded6cf3cde8a (patch) | |
tree | d5e1c63af2ed0aa9d638ba6d3fd1837d92f618b2 /util | |
parent | bdac4cd120b96aa7c7dcab330f179da37dac42e0 (diff) | |
parent | bb4e221f042e65e30a39dac799e531f7cf537341 (diff) |
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
Diffstat (limited to 'util')
-rw-r--r-- | util/helpbutton.py | 71 |
1 files changed, 7 insertions, 64 deletions
diff --git a/util/helpbutton.py b/util/helpbutton.py index 47a36cd..879320e 100644 --- a/util/helpbutton.py +++ b/util/helpbutton.py @@ -24,8 +24,6 @@ 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 @@ -35,8 +33,7 @@ _logger = logging.getLogger('turtleart-activity') class HelpButton(gtk.ToolItem): - def __init__(self, activity): - self._activity = activity + def __init__(self, **kwargs): self._current_palette = 'turtle' gtk.ToolItem.__init__(self) @@ -51,68 +48,14 @@ 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 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() + 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) - - -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) |