Ok, <br>I uploaded this patch to the remote repository [1]<br>I commited the deprecation corrections [2] <br>And I uploaded some help corrections [3]<br><br>I think the help must be only the utility and the description. In the<br>
start/end (I'm not sure), a paragraph describing something like 'Type:<br>
"{command} --help" to see it's usage'<br><br>I like your idea, it's simple and more friendly for the children.<br>Let's go!<br><br>[1] <a href="http://git.sugarlabs.org/terminal/mainline/commit/e44a2997">git.sugarlabs.org/terminal/mainline/commit/e44a2997</a><br>
[2] <a href="http://git.sugarlabs.org/terminal/mainline/commit/6f706a0c">git.sugarlabs.org/terminal/mainline/commit/6f706a0c</a><br>[3] <a href="http://git.sugarlabs.org/terminal/mainline/commit/1f3c5148">git.sugarlabs.org/terminal/mainline/commit/1f3c5148</a><br>
<br>Regards,<br>aguz<br><br><div class="gmail_quote">2012/6/22 Rafael Ortiz <span dir="ltr"><<a href="mailto:rafael@activitycentral.com" target="_blank">rafael@activitycentral.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Agus.<br>
<div><div class="h5"><br>
On 6/21/12, Agustin Zubiaga <<a href="mailto:aguz@sugarlabs.org">aguz@sugarlabs.org</a>> wrote:<br>
> Gonzalo's button ported to GTK3<br>
> Bugs:<br>
> Wrap mode doesn't work<br>
> Grey background<br>
><br>
> Signed-off-by: Agustin Zubiaga <<a href="mailto:aguz@sugarlabs.org">aguz@sugarlabs.org</a>><br>
> ---<br>
> helpbutton.py | 85<br>
> +++++++++++++++++++++++++++++++++++++++++++++++++++<br>
> icons/help-icon.svg | 14 +++++++++<br>
> terminal.py | 33 ++++++++++++++++++++<br>
> 3 files changed, 132 insertions(+)<br>
> create mode 100644 helpbutton.py<br>
> create mode 100644 icons/help-icon.svg<br>
><br>
> diff --git a/helpbutton.py b/helpbutton.py<br>
> new file mode 100644<br>
> index 0000000..1f01851<br>
> --- /dev/null<br>
> +++ b/helpbutton.py<br>
> @@ -0,0 +1,85 @@<br>
> +#!/usr/bin/env python<br>
> +# -*- coding: utf-8 -*-<br>
> +# Copyright (C) 2012, Gonzalo Odiard <<a href="mailto:godiard@gmail.com">godiard@gmail.com</a>><br>
> +<br>
> +# This program is free software; you can redistribute it and/or modify<br>
> +# it under the terms of the GNU General Public License as published by<br>
> +# the Free Software Foundation; either version 3 of the License, or<br>
> +# (at your option) any later version.<br>
> +#<br>
> +# This program is distributed in the hope that it will be useful,<br>
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
> +# GNU General Public License for more details.<br>
> +#<br>
> +# You should have received a copy of the GNU General Public License<br>
> +# along with this program; if not, write to the Free Software<br>
> +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301<br>
> USA<br>
> +<br>
> +# HelpButton widget<br>
> +<br>
> +from gettext import gettext as _<br>
> +<br>
> +from gi.repository import Gtk<br>
> +from gi.repository import Gdk<br>
> +from gi.repository import GObject<br>
> +<br>
> +from sugar3.graphics.toolbutton import ToolButton<br>
> +from sugar3.graphics.icon import Icon<br>
> +from sugar3.graphics import style<br>
> +<br>
> +<br>
> +class HelpButton(Gtk.ToolItem):<br>
> +<br>
> + def __init__(self, **kwargs):<br>
> + GObject.GObject.__init__(self)<br>
> +<br>
> + help_button = ToolButton('help-icon')<br>
> + help_button.set_tooltip(_('Help'))<br>
> + self.add(help_button)<br>
> +<br>
> + self._palette = help_button.get_palette()<br>
> +<br>
> + sw = Gtk.ScrolledWindow()<br>
> + sw.set_size_request(int(Gdk.Screen.width() / 2.8),<br>
> + Gdk.Screen.height() - style.GRID_CELL_SIZE * 3)<br>
> + sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)<br>
> +<br>
> + self._max_text_width = int(Gdk.Screen.width() / 3) - 600<br>
> + self._vbox = Gtk.VBox()<br>
> + self._vbox.set_homogeneous(False)<br>
> +<br>
> + hbox = Gtk.HBox()<br>
> + hbox.pack_start(self._vbox, False, True, 0)<br>
> +<br>
> + sw.add_with_viewport(hbox)<br>
> +<br>
> + self._palette.set_content(sw)<br>
> + sw.show_all()<br>
> +<br>
> + help_button.connect('clicked', self.__help_button_clicked_cb)<br>
> +<br>
> + def __help_button_clicked_cb(self, button):<br>
> + self._palette.popup(immediate=True, state=1)<br>
> +<br>
> + def add_section(self, section_text):<br>
> + hbox = Gtk.HBox()<br>
> + label = Gtk.Label()<br>
> + label.set_use_markup(True)<br>
> + label.set_markup('<b>%s</b>' % section_text)<br>
> + label.set_line_wrap(True)<br>
> + hbox.pack_start(label, False, False, 0)<br>
> + hbox.show_all()<br>
> + self._vbox.pack_start(hbox, False, False, padding=5)<br>
> +<br>
> + def add_paragraph(self, text, icon=None):<br>
> + hbox = Gtk.HBox()<br>
> + label = Gtk.Label(label=text)<br>
> + label.set_justify(Gtk.Justification.LEFT)<br>
> + label.set_line_wrap(True)<br>
> + hbox.pack_start(label, False, False, 0)<br>
> + if icon is not None:<br>
> + _icon = Icon(icon_name=icon)<br>
> + hbox.add(_icon)<br>
> + hbox.show_all()<br>
> + self._vbox.pack_start(hbox, False, False, padding=5)<br>
> diff --git a/icons/help-icon.svg b/icons/help-icon.svg<br>
> new file mode 100644<br>
> index 0000000..f6c92bf<br>
> --- /dev/null<br>
> +++ b/icons/help-icon.svg<br>
> @@ -0,0 +1,14 @@<br>
> +<?xml version="1.0" encoding="UTF-8"?><br>
> +<svg xmlns="<a href="http://www.w3.org/2000/svg" target="_blank">http://www.w3.org/2000/svg</a>" version="1.1" width="55px"<br>
> height="55px"><br>
> + <path<br>
> + style="fill:none;stroke:#ffffff;stroke-width:3;stroke-linejoin:round"<br>
> + d="M 48,28 A 20,20 0 1 1 8,28 A 20,20 0 1 1 48,28 z"/><br>
> + <path<br>
> +<br>
> style="fill:none;stroke:#ffffff;stroke-width:6;stroke-linecap:round;stroke-linejoin:round"<br>
> + d="M 22,20 C 22,20 25,17 29,17 C 33,17 36,19 36,23 C 36,27 31,29 28,29<br>
> L 28,32" /><br>
> + <path<br>
> + style="fill:#ffffff"<br>
> + d="M 25,40<br>
> + a 3,3 0 1 1 6,0<br>
> + a 3,3 0 1 1 -6,0 z" /><br>
> +</svg><br>
> diff --git a/terminal.py b/terminal.py<br>
> index a37e2ac..803fed9 100644<br>
> --- a/terminal.py<br>
> +++ b/terminal.py<br>
> @@ -42,6 +42,9 @@ from sugar3 import env<br>
> from widgets import BrowserNotebook<br>
> from widgets import TabLabel<br>
><br>
> +from helpbutton import HelpButton<br>
> +<br>
> +<br>
> MASKED_ENVIRONMENT = [<br>
> 'DBUS_SESSION_BUS_ADDRESS',<br>
> 'PPID']<br>
> @@ -104,6 +107,10 @@ class TerminalActivity(activity.Activity):<br>
> toolbar_box.toolbar.insert(separator, -1)<br>
> separator.show()<br>
><br>
> + helpbutton = self._create_help_button()<br>
> + toolbar_box.toolbar.insert(helpbutton, -1)<br>
> + helpbutton.show_all()<br>
> +<br>
> stop_button = StopButton(self)<br>
> stop_button.props.accelerator = '<Ctrl><Shift>Q'<br>
> toolbar_box.toolbar.insert(stop_button, -1)<br>
> @@ -183,6 +190,32 @@ class TerminalActivity(activity.Activity):<br>
> def __fullscreen_cb(self, button):<br>
> self.fullscreen()<br>
><br>
> + def _create_help_button(self):<br>
> + helpitem = HelpButton()<br>
> +<br>
> + helpitem.add_section(_('Useful commands'))<br>
> + helpitem.add_section(_('cd'))<br>
> + helpitem.add_paragraph(_('Change directory'))<br>
> + helpitem.add_paragraph(_('To use it, write: cd directory'))<br>
> + helpitem.add_paragraph(_('If you call it without parameters, will<br>
> change\nto the user directory'))<br>
> + helpitem.add_section(_('ls'))<br>
> + helpitem.add_paragraph(_('List the content of a directory.'))<br>
> + helpitem.add_paragraph(_('To use it, write: ls directory'))<br>
> + helpitem.add_paragraph(_('If you call it without parameters, will<br>
> list\nthe working directory'))<br>
> + helpitem.add_section(_('cp'))<br>
> + helpitem.add_paragraph(_('Copy a file to a specific location'))<br>
> + helpitem.add_paragraph(_('Call it with the file and the new<br>
> location'))<br>
> + helpitem.add_paragraph(_('Use: cp file directory/'))<br>
> + helpitem.add_section(_('rm'))<br>
> + helpitem.add_paragraph(_('Removes a file in any path'))<br>
> + helpitem.add_paragraph(_('Use: rm file'))<br>
> + helpitem.add_section(_('su'))<br>
> + helpitem.add_paragraph(_('Login as superuser (root)'))<br>
> + helpitem.add_paragraph(_('The root user is the administrator of the<br>
> system'))<br>
> + helpitem.add_paragraph(_('You must be careful, because you can<br>
> modify system files'))<br>
> +<br>
> + return helpitem<br>
> +<br>
> def _create_tab_toolbar(self):<br>
> tab_toolbar = Gtk.Toolbar()<br>
> new_tab_button = ToolButton('tab-add')<br>
> --<br>
> 1.7.10.2<br>
><br>
</div></div><div class="im">> _______________________________________________<br>
> Sugar-devel mailing list<br>
> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
><br>
<br>
</div>A comment about the code, please use Gtk.Box instead of<br>
GtkHBox/GtkVBox as they are now deprecated.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Rafael Ortiz<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><img src="https://lh3.googleusercontent.com/wx48FqQfbwg6DcUZL0ey4HpG6bX0GMyl1VWk_JJdi21Hgonb24D3lJCKSqn1iYq4sJnxbWDh8cwLnPtfg-UV8XuXXw" height="50" width="141"><br>
<br>