Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/help.py
blob: 1759c7c24302be3fd39b316ba0c98f2709152d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
""" 'Help' and 'About' information."""
# Copyright (C) 2012-2013 S. Daniel Francis <francis@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 Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

from gettext import gettext as _
from gi.repository import Gtk

import stock
from item import Item
from itemgroup import ItemGroup
import info


class AboutItem(Item):
    def __init__(self, parent):
        Item.__init__(self, Gtk.STOCK_ABOUT)
        self.parent = parent

    def do_activate(self):
        dialog = Gtk.AboutDialog()
        dialog.set_name(info.name)
        dialog.set_version(info.version)
        dialog.set_transient_for(self.parent)
        dialog.set_comments(info.description)
        dialog.set_copyright(info.copyright)
        dialog.set_website(info.url)
        dialog.set_authors(info.authors)
        dialog.set_license(info.license)
        dialog.set_wrap_license(True)
        dialog.set_logo_icon_name(info.lower_name)
        dialog.run()
        dialog.destroy()


class Help(ItemGroup):
    """
    This class makes the help menu on desktops and a HelpButton on Sugar.
    """
    def __init__(self, box):
        """Constructor.
        box -- sweetener.ItemBox where append it
        """
        title = stock.get_label(Gtk.STOCK_HELP, False)
        ItemGroup.__init__(self, box, title, 'toolbar-help')
        stock.register('sweetener-help-contents', title,
                       'F1', 'gtk-help')
        contents = Item('sweetener-help-contents')
        contents.connect('activate', lambda w: Gtk.show_uri(None,
                                                         info.documentation,
                                                Gtk.get_current_event_time()))
        self.append_item(contents)
        about = AboutItem(box._parent)
        self.append_item(about)