From 25e5093ca74f824268ee81523de9c54f3cc5afa1 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Wed, 07 Mar 2012 06:13:31 +0000 Subject: Add help The intention of this help is use it in other activities. Signed-off-by: Gonzalo Odiard Signed-off-by: Agustin Zubiaga --- diff --git a/activity.py b/activity.py index 3202c1a..71425e3 100644 --- a/activity.py +++ b/activity.py @@ -47,6 +47,7 @@ from sugar.datastore import datastore from charts import Chart from readers import StopWatchReader from readers import MeasureReader +import simplegraphhelp # Mime types STOPWATCH_MIME_TYPE = "application/x-stopwatch-activity" @@ -273,6 +274,8 @@ class SimpleGraph(activity.Activity): separator.set_expand(True) toolbarbox.toolbar.insert(separator, -1) + simplegraphhelp.create_help(toolbarbox.toolbar) + stopbtn = StopButton(self) toolbarbox.toolbar.insert(stopbtn, -1) diff --git a/helpbutton.py b/helpbutton.py new file mode 100644 index 0000000..f27af70 --- /dev/null +++ b/helpbutton.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2012, Gonzalo Odiard + +# 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 sugar.graphics.icon import Icon +from sugar.graphics import style + + +class HelpButton(gtk.ToolItem): + + def __init__(self, **kwargs): + gtk.ToolItem.__init__(self) + + help_button = ToolButton('help-icon') + help_button.set_tooltip(_('Help')) + self.add(help_button) + + self._palette = help_button.get_palette() + + sw = gtk.ScrolledWindow() + sw.set_size_request(int(gtk.gdk.screen_width() / 3), + gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3) + sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + + self._max_text_width = int(gtk.gdk.screen_width() / 3) - 20 + self._vbox = gtk.VBox() + self._vbox.set_homogeneous(False) + sw.add_with_viewport(self._vbox) + + self._palette.set_content(sw) + sw.show_all() + + help_button.connect('clicked', self.__help_button_clicked_cb) + + def __help_button_clicked_cb(self, button): + self._palette.popup(immediate=True, state=1) + + def add_section(self, section_text): + hbox = gtk.HBox() + label = gtk.Label() + label.set_use_markup(True) + label.set_markup('%s' % section_text) + label.set_line_wrap(True) + label.set_size_request(self._max_text_width, -1) + hbox.add(label) + hbox.show_all() + self._vbox.pack_start(hbox, False, False, padding=5) + + def add_paragraph(self, text, icon=None): + 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._vbox.pack_start(hbox, False, False, padding=5) diff --git a/icons/help-icon.svg b/icons/help-icon.svg new file mode 100644 index 0000000..f6c92bf --- /dev/null +++ b/icons/help-icon.svg @@ -0,0 +1,14 @@ + + + + + + diff --git a/simplegraphhelp.py b/simplegraphhelp.py new file mode 100644 index 0000000..74aafeb --- /dev/null +++ b/simplegraphhelp.py @@ -0,0 +1,37 @@ +# Help for SimpleGraphActivity + +from gettext import gettext as _ + +from helpbutton import HelpButton + + +def create_help(toolbar): + helpitem = HelpButton() + toolbar.insert(helpitem, -1) + helpitem.show() + helpitem.add_section(_('Basic usage')) + helpitem.add_paragraph(_('First you need add data to create the graphic')) + helpitem.add_paragraph(_('You can add data with this button'), + 'row-insert') + helpitem.add_paragraph(_('...or remove data with this button'), + 'row-remove') + helpitem.add_paragraph(_('To change the graphic title, just change the activity title')) + + helpitem.add_paragraph(_('Next you can change the type of graphic')) + helpitem.add_paragraph(_('Vertical bars'), 'vbar') + helpitem.add_paragraph(_('Horizontal bars'), 'hbar') + helpitem.add_paragraph(_('Lines'), 'line') + helpitem.add_paragraph(_('Pie'), 'pie') + + helpitem.add_section(_('Configs')) + helpitem.add_paragraph(_('You can change the colors or the horizontal and vertical labels in the configs toolbar'), + 'preferences-system') + + helpitem.add_section(_('Saving as a image')) + helpitem.add_paragraph(_('In the activity toolbar you have button to save the graphic as a image'), + 'save-as-image') + + helpitem.add_section(_('Reading data from other activities')) + helpitem.add_paragraph(_('In the activity toolbar you have buttons to read data from other activities')) + helpitem.add_paragraph(_('You can use times measured in the StopWatch activity'), 'import-stopwatch') + helpitem.add_paragraph(_('...or data from the Measure activity'), 'import-measure') -- cgit v0.9.1