Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-09-25 22:08:17 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-09-25 22:16:38 (GMT)
commit0b6fbb2fbd43102f7b9f6385801b45c2d55cb9c0 (patch)
tree17880d6c5f1fd1c78f68da2fe86a6d6682dd6d10
parente13ac71a8bc4c25e80d01140e469022f2cfce03f (diff)
Replace the help top bar by a HelpButton
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--budgetscreen.py2
-rw-r--r--chartscreen.py3
-rw-r--r--finance.py38
-rw-r--r--helpbutton.py90
-rw-r--r--registerscreen.py7
5 files changed, 106 insertions, 34 deletions
diff --git a/budgetscreen.py b/budgetscreen.py
index 4115d79..24eadbe 100644
--- a/budgetscreen.py
+++ b/budgetscreen.py
@@ -144,8 +144,6 @@ class BudgetScreen(Gtk.VBox):
self.show_all()
- self.activity.set_help(BUDGET_HELP)
-
def bar_draw_cb(self, widget, cr, category):
bounds = widget.get_allocation()
diff --git a/chartscreen.py b/chartscreen.py
index f1c40cd..a6fc9a5 100644
--- a/chartscreen.py
+++ b/chartscreen.py
@@ -121,9 +121,6 @@ class ChartScreen(Gtk.HBox):
self.show_all()
- # Update the help text.
- self.activity.set_help(CHART_HELP)
-
def chart_draw_cb(self, widget, context):
# Draw pie chart.
bounds = widget.get_allocation()
diff --git a/finance.py b/finance.py
index 6ba89cc..b3fedaf 100644
--- a/finance.py
+++ b/finance.py
@@ -26,6 +26,7 @@ import locale
import registerscreen
import chartscreen
import budgetscreen
+from helpbutton import HelpButton
from gettext import gettext as _
from port import json
@@ -141,14 +142,6 @@ class Finance(Activity):
self.screens = []
self.screenbox = Gtk.VBox()
- # Add the context sensitive help.
- self.helplabel = Gtk.Label()
- self.helplabel.set_padding(10, 10)
- self.helpbox = Gtk.EventBox()
- parse, color = Gdk.Color.parse('#000000')
- self.helpbox.modify_bg(Gtk.StateType.NORMAL, color)
- self.helpbox.add(self.helplabel)
-
# Add the header.
self.periodlabel = Gtk.Label()
self.periodlabel.set_padding(10, 0)
@@ -170,7 +163,6 @@ class Finance(Activity):
vbox = Gtk.VBox()
- vbox.pack_start(self.helpbox, False, False, 10)
vbox.pack_start(headerbox, False, False, 10)
vbox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL),
False, False, 0)
@@ -269,10 +261,8 @@ class Finance(Activity):
viewbar.insert(budgetbtn, -1)
viewbar.insert(chartbtn, -1)
- helpbtn = ToggleToolButton('help')
- helpbtn.set_active(True)
- helpbtn.set_tooltip(_("Show Help"))
- helpbtn.connect('clicked', self.help_cb)
+ helpbutton = self._create_help_button()
+ helpbutton.show_all()
self.toolbar_box = ToolbarBox()
@@ -307,26 +297,26 @@ class Finance(Activity):
self.toolbar_box.toolbar.insert(self.nextperiodbtn, -1)
self.toolbar_box.toolbar.insert(self.thisperiodbtn, -1)
+ self.toolbar_box.toolbar.insert(helpbutton, -1)
+
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
self.toolbar_box.toolbar.insert(separator, -1)
- self.toolbar_box.toolbar.insert(helpbtn, -1)
self.toolbar_box.toolbar.insert(StopButton(self), -1)
self.set_toolbar_box(self.toolbar_box)
self.toolbar_box.show_all()
- def set_help(self, text):
- if self.helplabel != None:
- self.helplabel.set_markup('<span size="8000" color="#ffffff">' +
- text + '</span>')
-
- def help_cb(self, widget):
- if widget.get_active():
- self.helpbox.show()
- else:
- self.helpbox.hide()
+ def _create_help_button(self):
+ helpitem = HelpButton()
+ helpitem.add_section(_('Register'), icon='view-list')
+ helpitem.add_paragraph(registerscreen.REGISTER_HELP)
+ helpitem.add_section(_('Budget'), icon='budget')
+ helpitem.add_paragraph(budgetscreen.BUDGET_HELP)
+ helpitem.add_section(_('Chart'), icon='chart')
+ helpitem.add_paragraph(chartscreen.CHART_HELP)
+ return helpitem
def register_cb(self, widget):
self.pop_screen()
diff --git a/helpbutton.py b/helpbutton.py
new file mode 100644
index 0000000..a9561db
--- /dev/null
+++ b/helpbutton.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2012, Gonzalo Odiard <godiard@gmail.com>
+
+# 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 _
+
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
+
+from sugar3.graphics.toolbutton import ToolButton
+from sugar3.graphics.icon import Icon
+from sugar3.graphics import style
+
+
+class HelpButton(Gtk.ToolItem):
+
+ def __init__(self, **kwargs):
+ GObject.GObject.__init__(self)
+
+ help_button = ToolButton('toolbar-help')
+ help_button.set_tooltip(_('Help'))
+ self.add(help_button)
+
+ self._palette = help_button.get_palette()
+
+ sw = Gtk.ScrolledWindow()
+ sw.set_size_request(int(Gdk.Screen.width() / 2.8),
+ Gdk.Screen.height() - style.GRID_CELL_SIZE * 3)
+ sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
+
+ self._max_text_width = int(Gdk.Screen.width() / 3) - 600
+ self._vbox = Gtk.Box()
+ self._vbox.set_orientation(Gtk.Orientation.VERTICAL)
+ self._vbox.set_homogeneous(False)
+
+ hbox = Gtk.Box()
+ hbox.pack_start(self._vbox, False, True, 0)
+
+ sw.add_with_viewport(hbox)
+
+ 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, icon=None):
+ hbox = Gtk.Box()
+ label = Gtk.Label()
+ label.set_use_markup(True)
+ label.set_markup('<b>%s</b>' % section_text)
+ label.set_line_wrap(True)
+ hbox.pack_start(label, True, True, 0)
+ if icon is not None:
+ _icon = Icon(icon_name=icon)
+ hbox.pack_start(_icon, False, False, 0)
+ hbox.show_all()
+ self._vbox.pack_start(hbox, False, False, padding=5)
+
+ def add_paragraph(self, text, icon=None):
+ hbox = Gtk.Box()
+ label = Gtk.Label(label=text)
+ label.set_justify(Gtk.Justification.LEFT)
+ label.set_line_wrap(True)
+ label.props.max_width_chars = 35
+ hbox.pack_start(label, False, False, 0)
+ if icon is not None:
+ _icon = Icon(icon_name=icon)
+ hbox.add(_icon)
+ hbox.show_all()
+ self._vbox.pack_start(hbox, False, False, padding=5)
diff --git a/registerscreen.py b/registerscreen.py
index 8bc6053..45cece3 100644
--- a/registerscreen.py
+++ b/registerscreen.py
@@ -30,8 +30,8 @@ locale.setlocale(locale.LC_ALL, '')
import finance
REGISTER_HELP = _(
- '<b>Welcome to Finance!</b> This activity keeps track of income '
- 'and expenses for anything that earns\nor spends money, like a school '
+ 'Welcome to Finance! This activity keeps track of income '
+ 'and expenses for anything that earns or spends money, like a school '
'club. To get started, use the Transaction box to add credits and '
'debits.\nOnce you have entered some transactions, visit the Chart '
'and Budget views to see more.')
@@ -105,9 +105,6 @@ class RegisterScreen(Gtk.VBox):
for t in self.activity.visible_transactions:
self.liststore.append((t['id'],))
- # Update the help text.
- self.activity.set_help(REGISTER_HELP)
-
def description_render_cb(self, column, cell_renderer, model, iter, data):
id = model.get_value(iter, 0)
t = self.activity.transaction_map[id]